1
00:00:00,840 --> 00:00:01,500
Welcome back.

2
00:00:01,950 --> 00:00:07,620
And this year we are going to implement and use Dexter, which is an Android library that simplifies

3
00:00:07,620 --> 00:00:10,170
the process of requesting permissions at runtime.

4
00:00:10,440 --> 00:00:14,310
And we've seen before that it can be quite some work to implement that.

5
00:00:14,340 --> 00:00:18,960
But that's exactly what X comes, and it really helps us to make this a lot quicker.

6
00:00:19,440 --> 00:00:23,850
So can you, of course, check out this Web site, get help that consulate Kurumi slash Dexter if you

7
00:00:23,850 --> 00:00:29,880
want to know all about it, because here are a bunch of examples of how to use single permissions,

8
00:00:29,940 --> 00:00:33,480
multiple permissions and how to handle Århus and so forth.

9
00:00:34,230 --> 00:00:36,630
And, um, yeah, I would recommend to check that out.

10
00:00:36,930 --> 00:00:39,000
We're going to use some of that functionality.

11
00:00:39,300 --> 00:00:40,950
So let's dive right into it.

12
00:00:41,040 --> 00:00:47,480
And what we're gonna do is, by the way, we are going to have this screen here, which allows us then

13
00:00:47,490 --> 00:00:50,280
to ask what permissions I already gave the permission for this app.

14
00:00:50,280 --> 00:00:52,320
So let's see how we can implement that.

15
00:00:53,190 --> 00:00:59,520
So the first thing we need to do is to add an on click listener for our button, which is our TV ad

16
00:00:59,670 --> 00:01:00,360
image button.

17
00:01:01,020 --> 00:01:02,500
And it's going to be this.

18
00:01:02,880 --> 00:01:03,300
So.

19
00:01:04,450 --> 00:01:11,740
This glass, which is our ad happy place activity, will be the click listener because while it implements

20
00:01:11,740 --> 00:01:13,550
the functionality, here are extensive.

21
00:01:14,220 --> 00:01:14,530
OK.

22
00:01:14,950 --> 00:01:18,650
So then of course, we need to add the idea here as well.

23
00:01:18,670 --> 00:01:20,710
So our dot ideas dot.

24
00:01:21,400 --> 00:01:24,390
And here it was, Ivy Place image.

25
00:01:24,760 --> 00:01:32,530
So if that is the view that was clicked on, then what do we want to do?

26
00:01:33,820 --> 00:01:37,510
Well, first of all, I want to have this little.

27
00:01:38,860 --> 00:01:41,440
Higher alert dialogue here and with two options.

28
00:01:41,620 --> 00:01:43,410
All right, so let's add that alert dialogue.

29
00:01:44,350 --> 00:01:52,450
So Volle picture dialogue, as I'm gonna call it, is going to be an alert dialogue and I'm going to

30
00:01:52,450 --> 00:01:53,830
use the builder to build it.

31
00:01:54,310 --> 00:01:57,460
So a builder with this as the context.

32
00:01:58,210 --> 00:01:58,390
OK.

33
00:01:58,450 --> 00:02:06,580
And then I can set the title of that dialogue with the subtitle method here and I'm gonna say Select

34
00:02:07,570 --> 00:02:08,139
Action.

35
00:02:10,539 --> 00:02:16,360
And then I need to have two different picture dialogue items.

36
00:02:16,990 --> 00:02:25,990
So that's how I'm gonna call them picture dialogue items, which is going to be an array of two values.

37
00:02:26,110 --> 00:02:29,320
So we have select photo from gallery.

38
00:02:32,080 --> 00:02:39,280
And then the other option is capture photo from camera.

39
00:02:40,780 --> 00:02:41,050
All right.

40
00:02:41,530 --> 00:02:42,700
So these are the two options.

41
00:02:42,760 --> 00:02:51,640
And now I can go ahead and use that picture dialogue in order to set the items that it should display.

42
00:02:52,570 --> 00:02:55,090
And it's going to be their picture dialogue items.

43
00:02:55,750 --> 00:02:58,600
And then what do I want to do with it?

44
00:02:59,410 --> 00:03:05,140
Well, depending on the dialogue which was selected.

45
00:03:06,630 --> 00:03:08,100
I want to run some code.

46
00:03:08,400 --> 00:03:10,470
So depending on which.

47
00:03:12,320 --> 00:03:13,490
I want to run coat.

48
00:03:14,390 --> 00:03:14,580
OK.

49
00:03:14,690 --> 00:03:15,890
So we have two options.

50
00:03:16,160 --> 00:03:20,660
Number zero will be select four from gallery.

51
00:03:20,870 --> 00:03:23,120
And no one will be capture photo from camera.

52
00:03:23,870 --> 00:03:27,290
So what I want to do here is four zero.

53
00:03:27,350 --> 00:03:29,060
I want to run some code.

54
00:03:29,810 --> 00:03:33,850
And for one, I also want to run some code here.

55
00:03:33,860 --> 00:03:35,180
I'm just gonna use a toast.

56
00:03:35,390 --> 00:03:35,990
So toast.

57
00:03:36,020 --> 00:03:39,980
Make text which will be displayed for a certain amount of time.

58
00:03:41,860 --> 00:03:45,120
And then, of course, I want to show this dialogue.

59
00:03:45,190 --> 00:03:48,670
So picture dialogue, dot show.

60
00:03:49,570 --> 00:03:51,970
Now, what is it that I want to run?

61
00:03:52,000 --> 00:04:00,580
If we choose to functionality a photo from gallery while I want to run a method here or Rathod method

62
00:04:00,580 --> 00:04:07,870
call choose photo from gallery, and I want will of course need to be created.

63
00:04:08,230 --> 00:04:10,330
So let's create another function here.

64
00:04:10,450 --> 00:04:11,680
Private fun.

65
00:04:12,520 --> 00:04:14,620
Choose photo from gallery.

66
00:04:14,950 --> 00:04:21,519
And this one will of course, then later on allow us the permission or ask for the permission, whether

67
00:04:21,519 --> 00:04:25,120
we may even use a photo from the gallery and so forth.

68
00:04:26,350 --> 00:04:32,340
So we, of course, need to ask for permissions, so let's go to the permission file, which is our

69
00:04:32,350 --> 00:04:32,940
manifest.

70
00:04:34,260 --> 00:04:39,990
And here had a bunch of permissions that we're gonna need and I'm gonna use multiple ones, so I'm just

71
00:04:39,990 --> 00:04:41,040
gonna paste them in here.

72
00:04:41,370 --> 00:04:44,820
So what I will use is the permission to read external storage.

73
00:04:44,910 --> 00:04:45,180
Right.

74
00:04:45,240 --> 00:04:46,790
External storage and camera.

75
00:04:49,680 --> 00:04:50,010
All right.

76
00:04:50,070 --> 00:04:52,460
And then I told you that we were to use Dexter.

77
00:04:52,790 --> 00:04:52,970
OK.

78
00:04:53,070 --> 00:04:55,770
So in order to use Dexter, we need to go to rebuild Gradle.

79
00:04:56,580 --> 00:04:59,790
And then had this library here.

80
00:05:00,060 --> 00:05:03,960
So include a library in the built out cradle and limitation column.

81
00:05:03,960 --> 00:05:06,690
Kotomi, Dexter, six zero one.

82
00:05:08,190 --> 00:05:10,590
So I'm just going to add that here and then click sync.

83
00:05:10,650 --> 00:05:12,530
Now here, the top right hand corner.

84
00:05:15,290 --> 00:05:17,830
Once that is done, we can now use Dexter.

85
00:05:18,500 --> 00:05:20,690
So now we can go back to our happy places.

86
00:05:21,970 --> 00:05:25,810
And use extra in order to ask for permission.

87
00:05:26,230 --> 00:05:27,790
So here, Dexter.

88
00:05:31,210 --> 00:05:34,070
And then I need to import this glossier import, Dexter.

89
00:05:35,080 --> 00:05:35,290
All right.

90
00:05:35,380 --> 00:05:36,130
Now it's available.

91
00:05:36,220 --> 00:05:37,630
Let's look at the imports real quick.

92
00:05:37,870 --> 00:05:42,310
You can see now I'm using the combat Kotomi that dextra that Dexter.

93
00:05:44,390 --> 00:05:47,930
And now I can go ahead and use Dexters functionality.

94
00:05:48,350 --> 00:05:51,230
So here, for example, the method with activity.

95
00:05:51,920 --> 00:05:53,540
So I need to pass on the activity.

96
00:05:54,240 --> 00:05:57,620
Then I go ahead and ask for permissions.

97
00:05:57,830 --> 00:05:59,960
So which permissions do I want to use?

98
00:06:00,890 --> 00:06:07,130
Well, you can see a permission string is what I'm asked to provide.

99
00:06:07,130 --> 00:06:08,870
So many first thought.

100
00:06:08,870 --> 00:06:10,870
Permission thought.

101
00:06:11,110 --> 00:06:12,750
Read on the.

102
00:06:13,160 --> 00:06:14,000
External.

103
00:06:15,650 --> 00:06:16,960
On escort storage.

104
00:06:19,610 --> 00:06:23,060
And here, of course, it's easier if you enter manifest correctly.

105
00:06:24,470 --> 00:06:26,210
And then import manifest.

106
00:06:28,380 --> 00:06:33,480
And I'm going to import the Android manifest, then separated by Chrome on my other permission that

107
00:06:33,480 --> 00:06:34,530
I want to ask for.

108
00:06:34,650 --> 00:06:38,550
So many first thought.

109
00:06:38,640 --> 00:06:40,110
Permission thought.

110
00:06:40,500 --> 00:06:40,950
Right.

111
00:06:40,980 --> 00:06:41,910
External storage.

112
00:06:42,570 --> 00:06:43,080
And then.

113
00:06:44,460 --> 00:06:47,520
I can go ahead and have the listener.

114
00:06:48,000 --> 00:06:52,770
So with a listener and hear, by the way, we can just follow his instructions.

115
00:06:54,420 --> 00:06:59,310
And for us, what's interesting is there's multiple permissions because we are already asking for multiple

116
00:06:59,310 --> 00:06:59,820
permissions.

117
00:06:59,850 --> 00:07:00,120
Right.

118
00:07:00,600 --> 00:07:04,220
So what we need is a new multiple permission listener.

119
00:07:05,120 --> 00:07:05,480
All right.

120
00:07:05,520 --> 00:07:10,800
Even though it's done like this here, what we can do is we can use a different one.

121
00:07:10,920 --> 00:07:12,180
So I'm just gonna copy this.

122
00:07:14,130 --> 00:07:25,600
And what we going to do is we are going to pass pastie object of the multiple permission listener in

123
00:07:25,640 --> 00:07:25,880
here.

124
00:07:26,900 --> 00:07:27,040
OK.

125
00:07:27,270 --> 00:07:33,210
So it's instead of using the nuclear word, um, using an object of type, multiple permission.

126
00:07:33,360 --> 00:07:34,040
Listen to here.

127
00:07:35,650 --> 00:07:40,060
And by the way, it's complaining here, because I forgot the s here, because there is another cold

128
00:07:40,480 --> 00:07:44,140
weather with cold, warm method with permissions.

129
00:07:44,500 --> 00:07:47,340
So that's why it was complaining about this, right?

130
00:07:47,350 --> 00:07:48,070
External storage.

131
00:07:48,100 --> 00:07:48,820
Now it's going to work.

132
00:07:51,770 --> 00:07:52,430
And here.

133
00:07:53,930 --> 00:07:56,580
Because I'm passing in the object, I don't need to Brexiteer here.

134
00:07:59,260 --> 00:08:02,470
And this additional bracket here at the end as well.

135
00:08:05,180 --> 00:08:11,570
Because the court has, of course, Android, because the code is Java code.

136
00:08:11,720 --> 00:08:14,270
So we need to make some more changes.

137
00:08:14,330 --> 00:08:16,070
So here, overwrite.

138
00:08:17,700 --> 00:08:19,020
And then.

139
00:08:20,080 --> 00:08:21,910
I'm using the fund here.

140
00:08:22,600 --> 00:08:24,790
So overwrite fun.

141
00:08:26,120 --> 00:08:27,500
On permission checked.

142
00:08:31,300 --> 00:08:34,150
Then we pass in the multiple permission report.

143
00:08:34,900 --> 00:08:39,909
So what I'm doing here is really just bringing it in the right format and we need to import that as

144
00:08:39,909 --> 00:08:40,210
well.

145
00:08:40,480 --> 00:08:44,450
So multiple permissions as well as the permission request.

146
00:08:44,890 --> 00:08:46,280
We need to import that as well.

147
00:08:47,400 --> 00:08:49,980
And we are going to use the one from Dexter.

148
00:08:51,910 --> 00:08:59,170
So here we have a list of permissions, so permissions kolon, and that will be immutable list so we

149
00:08:59,170 --> 00:09:02,020
can change the list of permissions later on.

150
00:09:03,160 --> 00:09:05,380
So mutable list of permission requests.

151
00:09:06,160 --> 00:09:09,360
And then we need to token, which is going to be a permission token.

152
00:09:09,790 --> 00:09:13,390
So token Collen, permission token.

153
00:09:13,990 --> 00:09:15,460
Then we need to import permission.

154
00:09:15,460 --> 00:09:16,120
Tolkan as well.

155
00:09:17,170 --> 00:09:17,530
All right.

156
00:09:17,920 --> 00:09:19,390
And that's already it.

157
00:09:20,290 --> 00:09:23,140
Now, we, of course, need to implement the code that we want to run.

158
00:09:23,650 --> 00:09:28,450
Wunder permission is checked and Wenda permission Rusciano should be shown.

159
00:09:30,340 --> 00:09:38,350
And by the way, you also saw how easy it is to have just a code from being Java code to becoming codling

160
00:09:38,350 --> 00:09:38,530
code.

161
00:09:38,800 --> 00:09:44,580
So here, instead of the Newquay word, we use the object that we person of type, multiple permissions

162
00:09:44,590 --> 00:09:45,080
listener.

163
00:09:45,550 --> 00:09:51,220
And then, well, you can see what it does want and you can see that it's called the check method.

164
00:09:51,640 --> 00:09:53,410
So now we can, of course, implement those, too.

165
00:09:53,710 --> 00:09:54,910
And what do we want to do there?

166
00:09:55,450 --> 00:09:56,950
Well, let's start with the first one.

167
00:09:57,580 --> 00:10:02,060
So with this report and I'm going to do it like this.

168
00:10:02,110 --> 00:10:03,490
Now it can read everything here.

169
00:10:04,000 --> 00:10:08,770
So I'm gonna say if report exists and all permissions are granted.

170
00:10:08,980 --> 00:10:10,660
So report.

171
00:10:12,540 --> 00:10:14,700
All permissions granted.

172
00:10:16,650 --> 00:10:17,070
Then.

173
00:10:18,100 --> 00:10:20,020
I want to run a in there.

174
00:10:21,770 --> 00:10:22,030
OK.

175
00:10:22,190 --> 00:10:22,970
So here.

176
00:10:25,980 --> 00:10:28,090
This will be toast.

177
00:10:28,370 --> 00:10:29,580
Don't make text.

178
00:10:32,250 --> 00:10:32,970
And so forth.

179
00:10:33,660 --> 00:10:40,260
Okay, so I want to inform the user, so here I'm just gonna say storage, read, write, permissions

180
00:10:40,260 --> 00:10:40,770
are granted.

181
00:10:40,800 --> 00:10:44,400
Now you can select an image from gallery and the text will be.

182
00:10:45,370 --> 00:10:47,710
Displayed very quickly or only shortly.

183
00:10:48,550 --> 00:10:53,890
So this will be called as the permissions are checked and then we see if all the missions are granted.

184
00:10:54,340 --> 00:10:55,930
Then we execute this code.

185
00:10:56,830 --> 00:11:00,870
Now, what shall happen if the rationale should be shown?

186
00:11:01,180 --> 00:11:06,460
So if he needed to tell the user why we needed it, because he maybe pressed Noah or something like

187
00:11:06,460 --> 00:11:06,650
that.

188
00:11:07,480 --> 00:11:08,200
Well, then.

189
00:11:09,450 --> 00:11:11,490
I will show another method.

190
00:11:11,700 --> 00:11:17,670
So I'm going to create in this specific method, which is just going to be there in order to let the

191
00:11:17,670 --> 00:11:18,120
user know.

192
00:11:20,340 --> 00:11:24,170
And I'm going to call this method show rational dialogue for permissions.

193
00:11:24,670 --> 00:11:24,810
OK.

194
00:11:25,100 --> 00:11:26,570
Now, let's implement this method here.

195
00:11:27,440 --> 00:11:29,090
So private fun.

196
00:11:33,220 --> 00:11:41,920
And what I want to display there is an alert dialog, so alert dialogue builder with this as the context

197
00:11:43,000 --> 00:11:45,850
set the message to be heard.

198
00:11:46,030 --> 00:11:55,090
Looks like you have turned off permissions required for this feature.

199
00:11:55,840 --> 00:12:05,470
It can be and tabled under application settings or the the application settings.

200
00:12:06,790 --> 00:12:07,090
All right.

201
00:12:07,690 --> 00:12:10,130
So this is just an example of what you could display.

202
00:12:10,150 --> 00:12:15,400
Of course, you can write a very different text if you want, but generally that is.

203
00:12:16,390 --> 00:12:19,690
What we will do so show rationale for permission.

204
00:12:20,260 --> 00:12:25,920
Then we need to set a positive button, so set positive button.

205
00:12:27,140 --> 00:12:29,450
How should the text be?

206
00:12:29,810 --> 00:12:35,020
Well, the text to be go to settings so that the user presses.

207
00:12:35,060 --> 00:12:35,480
Yes.

208
00:12:35,720 --> 00:12:36,860
Or the positive buttons.

209
00:12:36,890 --> 00:12:41,870
So this go to settings button, then I want to send the user to the settings.

210
00:12:42,870 --> 00:12:43,080
OK.

211
00:12:43,330 --> 00:12:45,840
And how I do that is the following culture.

212
00:12:45,910 --> 00:12:48,460
I'm going to paste it in here.

213
00:12:49,090 --> 00:12:53,230
So we have two variables that we are past, but we are not using them.

214
00:12:53,230 --> 00:12:55,090
So we can just use underscore here.

215
00:12:55,720 --> 00:12:58,060
By the way, we could have done that somewhere else as well.

216
00:12:58,330 --> 00:13:00,130
So here, for example, we're not using dialogue.

217
00:13:00,160 --> 00:13:03,400
So we could have just used underscore because we never using it.

218
00:13:04,220 --> 00:13:04,390
OK.

219
00:13:04,690 --> 00:13:05,710
This is just an example.

220
00:13:06,460 --> 00:13:06,730
Then.

221
00:13:08,740 --> 00:13:11,560
We try to run a certain intent.

222
00:13:11,710 --> 00:13:12,280
Why do we try?

223
00:13:12,340 --> 00:13:13,570
Well, because it could go wrong.

224
00:13:13,990 --> 00:13:18,730
So we run an intent called setting's application details settings.

225
00:13:20,140 --> 00:13:25,830
And what we're using here is we're passing the you or I as well, which is the you arrive our package

226
00:13:25,830 --> 00:13:25,980
name.

227
00:13:26,470 --> 00:13:32,710
So what we want this to do is send the user to the application settings.

228
00:13:33,100 --> 00:13:37,660
We can directly change the user rights or the permissions.

229
00:13:38,380 --> 00:13:38,650
All right.

230
00:13:38,710 --> 00:13:44,620
And then we add this data to the Internet, to your eye, and we start the activity with this intent.

231
00:13:45,810 --> 00:13:49,950
And of course, as this could go wrong, we have a try and a catch surrounding it.

232
00:13:50,370 --> 00:13:54,360
And for example, the error that could arise is to activity not found exception.

233
00:13:55,230 --> 00:13:55,490
All right.

234
00:13:55,500 --> 00:13:59,760
So this is what should happen if the user presses to positive button.

235
00:14:00,440 --> 00:14:05,970
And now what should happen when the user sets the negative button or clicks the negative button?

236
00:14:07,590 --> 00:14:08,130
Well, then.

237
00:14:09,570 --> 00:14:10,540
I want this.

238
00:14:10,590 --> 00:14:15,630
Oh, by the way, I want this button to be saying cancel the text and hear why it's important, which

239
00:14:15,690 --> 00:14:16,420
said negative.

240
00:14:16,440 --> 00:14:20,460
Button you use, because in some cases it accepts certain, others it doesn't.

241
00:14:20,880 --> 00:14:25,100
So you need to have the one where it accepts it and you can see dialogue and which.

242
00:14:25,140 --> 00:14:27,910
And we're gonna use the dialogue that this miss here.

243
00:14:28,830 --> 00:14:29,030
Okay.

244
00:14:29,130 --> 00:14:30,840
So, as I said, which is never used.

245
00:14:30,840 --> 00:14:33,270
So we can rename the two an underscore.

246
00:14:34,680 --> 00:14:41,640
And of course, if we want to display our whole alert dialog, we need to add this show here.

247
00:14:42,830 --> 00:14:47,970
And before we test that, there are two minor things that I still need to change.

248
00:14:48,140 --> 00:14:53,330
And one of them is that when it comes to this Hohn.

249
00:14:54,630 --> 00:14:56,760
Permission, Rusciano, should be shown.

250
00:14:56,970 --> 00:15:03,660
And actually this with listener, when you want to run that, what you need to add is this on a same

251
00:15:03,660 --> 00:15:03,970
thread.

252
00:15:04,000 --> 00:15:06,780
So here we've before just had check.

253
00:15:07,710 --> 00:15:09,120
So here like this.

254
00:15:09,210 --> 00:15:09,810
The check.

255
00:15:10,380 --> 00:15:14,220
And what we actually need to do is on same threat thought.

256
00:15:14,580 --> 00:15:14,910
Check.

257
00:15:15,720 --> 00:15:16,020
OK.

258
00:15:16,290 --> 00:15:17,640
So this is the one line.

259
00:15:18,000 --> 00:15:19,140
And then another thing.

260
00:15:19,290 --> 00:15:19,950
One testing.

261
00:15:19,950 --> 00:15:22,490
I realized that I'm not using the right idea here.

262
00:15:22,500 --> 00:15:24,790
So I'm using Ivy Place image.

263
00:15:24,840 --> 00:15:27,360
But it should be TV ad image.

264
00:15:27,780 --> 00:15:27,980
OK.

265
00:15:28,140 --> 00:15:30,480
So it's superimportant that you use the correct names here.

266
00:15:30,960 --> 00:15:34,020
When entering this, I accidentally entered the wrong name.

267
00:15:34,200 --> 00:15:35,430
So let's test is again.

268
00:15:38,040 --> 00:15:38,450
We are.

269
00:15:39,840 --> 00:15:43,700
Let's click on an image and you can see we can select action.

270
00:15:44,160 --> 00:15:48,530
So select photo from gallery could see we are asked for permission.

271
00:15:48,540 --> 00:15:49,410
I'm gonna deny it.

272
00:15:49,620 --> 00:15:50,740
I'm gonna click once again.

273
00:15:52,400 --> 00:15:57,500
And you can see it says it looks like you have turned off permissions required for this feature.

274
00:15:57,800 --> 00:15:59,990
It can be enabled under the application settings.

275
00:16:00,020 --> 00:16:00,240
OK.

276
00:16:00,290 --> 00:16:01,580
And let's click on Go to Settings.

277
00:16:02,390 --> 00:16:04,730
You can see it goes to the app info directly.

278
00:16:06,130 --> 00:16:08,110
And here we can go to permissions.

279
00:16:10,030 --> 00:16:11,920
And go to camera.

280
00:16:11,980 --> 00:16:16,890
For example, allow camera or here, no emissions allowed.

281
00:16:17,530 --> 00:16:19,420
And we asked for storage.

282
00:16:19,630 --> 00:16:21,460
So let's allow storage here.

283
00:16:22,920 --> 00:16:25,590
We can also allow camera here if we want to.

284
00:16:26,160 --> 00:16:28,950
So now later on, it will not ask us again.

285
00:16:29,800 --> 00:16:38,440
Okay, going back from here and from here, it us back to our application and now and clicking it.

286
00:16:38,580 --> 00:16:42,390
We should get to the point where we can actually select the image.

287
00:16:44,940 --> 00:16:51,450
And by the way, if you were wondering why it didn't show just toes to be created, if all permissions

288
00:16:51,450 --> 00:16:51,900
are granted.

289
00:16:51,930 --> 00:16:54,330
Because currently all permissions are granted.

290
00:16:54,720 --> 00:16:58,800
That has to do with this multiple permissions report not being available.

291
00:16:59,010 --> 00:17:02,910
So we need to make this a nullable and then we can run this again.

292
00:17:03,600 --> 00:17:04,470
And that it will work.

293
00:17:04,740 --> 00:17:06,180
So that is something that is tricky.

294
00:17:06,210 --> 00:17:11,130
That is something that you probably wouldn't come up with yourself, because what we did in this part

295
00:17:11,130 --> 00:17:14,670
of the code is we translated his Java code into Cocklin code.

296
00:17:15,359 --> 00:17:18,630
And then, of course, it's not obvious to use notables here.

297
00:17:18,910 --> 00:17:19,170
Okay.

298
00:17:19,380 --> 00:17:24,270
But now, you know, that's what this causes for at least to a certain degree.

299
00:17:24,359 --> 00:17:25,980
So do you see these things as well?

300
00:17:26,400 --> 00:17:29,310
And you can use it in the future.

301
00:17:29,580 --> 00:17:30,690
So let's click on it.

302
00:17:30,750 --> 00:17:33,690
And you can see storage permissions are granted.

303
00:17:35,360 --> 00:17:38,790
Okay, so let's have a quick look at what we did.

304
00:17:39,090 --> 00:17:43,860
So what we needed to do is we needed to go to our manifest.

305
00:17:44,880 --> 00:17:46,530
We needed to add the permissions in here.

306
00:17:47,370 --> 00:17:50,010
Then we added something to our gradle.

307
00:17:50,340 --> 00:17:55,200
So this line here come Cherubini, Dexter, six zero one.

308
00:17:55,260 --> 00:17:59,570
We sinked this file and then we could go ahead and use his functionality.

309
00:17:59,580 --> 00:18:00,780
So we needed to import it.

310
00:18:00,810 --> 00:18:06,210
Of course, we had it on Click Listener for our buttons so that it does something.

311
00:18:06,300 --> 00:18:10,300
And when we click on that button, we opened a picture dialog.

312
00:18:10,620 --> 00:18:12,270
At least we call this dialogue like this.

313
00:18:12,660 --> 00:18:13,830
And we have two options.

314
00:18:14,310 --> 00:18:17,160
One of them being select the photo.

315
00:18:17,250 --> 00:18:18,840
The other one was capture the photo.

316
00:18:18,960 --> 00:18:26,400
And then if we click on select a camera or capture the photo, then we currently just show a text here.

317
00:18:26,940 --> 00:18:32,430
And otherwise, we call this function called Choose Photo from gallery, which we create ourselves,

318
00:18:32,750 --> 00:18:36,750
in which we then finally use Dexter, which is this library that we're using here.

319
00:18:37,080 --> 00:18:40,830
And we use multiple permissions in this case to read and write permissions.

320
00:18:41,220 --> 00:18:44,170
And we said there are multiple permissions listener.

321
00:18:44,940 --> 00:18:50,700
And there are two on options or top two on functions which are called.

322
00:18:50,760 --> 00:18:55,620
One is when the permissions are checked and one is have permission rational should be shown, which

323
00:18:55,620 --> 00:18:57,660
means to user said no.

324
00:18:58,020 --> 00:19:05,490
And in this case, what we do is we call our own alert dialog where we tell the user that it's really

325
00:19:05,490 --> 00:19:09,210
important that Benito's settings be to be active.

326
00:19:09,360 --> 00:19:10,740
So those permissions to be active.

327
00:19:10,770 --> 00:19:14,070
Otherwise, we cannot run the functionality of the application.

328
00:19:14,490 --> 00:19:18,840
And then what we do is we send him to the application settings, which is pretty useful.

329
00:19:18,870 --> 00:19:23,490
So this is something that you really might need in multiple of your applications.

330
00:19:23,490 --> 00:19:26,160
So that's really something that you should keep in mind.

331
00:19:26,900 --> 00:19:27,180
All right.

332
00:19:27,210 --> 00:19:29,990
And if the user says no, then we just as Mr. Dialogue.

333
00:19:30,840 --> 00:19:31,470
All right, cool.

334
00:19:32,070 --> 00:19:38,940
So that's a very important step, because now you've seen how to use a third party library, which we

335
00:19:39,030 --> 00:19:40,230
have not used before.

336
00:19:41,220 --> 00:19:41,580
OK.

337
00:19:41,880 --> 00:19:46,290
So I'd say let's go to the next video where we're going to implement these further features.

338
00:19:46,370 --> 00:19:46,980
Soucy, they're.

