@@ -52,6 +52,8 @@ public class AuthUiActivity extends AppCompatActivity {
52
52
private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME" ;
53
53
private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/" ;
54
54
private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/" ;
55
+ private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/" ;
56
+ private static final String FIREBASE_PRIVACY_POLICY_URL = "https://firebase.google.com/terms/analytics/#7_privacy" ;
55
57
private static final int RC_SIGN_IN = 100 ;
56
58
57
59
@ BindView (R .id .default_theme )
@@ -69,6 +71,9 @@ public class AuthUiActivity extends AppCompatActivity {
69
71
@ BindView (R .id .email_provider )
70
72
CheckBox mUseEmailProvider ;
71
73
74
+ @ BindView (R .id .phone_provider )
75
+ CheckBox mUsePhoneProvider ;
76
+
72
77
@ BindView (R .id .google_provider )
73
78
CheckBox mUseGoogleProvider ;
74
79
@@ -84,6 +89,12 @@ public class AuthUiActivity extends AppCompatActivity {
84
89
@ BindView (R .id .firebase_tos )
85
90
RadioButton mUseFirebaseTos ;
86
91
92
+ @ BindView (R .id .google_privacy )
93
+ RadioButton mUseGooglePrivacyPolicy ;
94
+
95
+ @ BindView (R .id .firebase_privacy )
96
+ RadioButton mUseFirebasePrivacyPolicy ;
97
+
87
98
@ BindView (R .id .sign_in )
88
99
Button mSignIn ;
89
100
@@ -99,8 +110,11 @@ public class AuthUiActivity extends AppCompatActivity {
99
110
@ BindView (R .id .no_logo )
100
111
RadioButton mNoLogo ;
101
112
102
- @ BindView (R .id .smartlock_enabled )
103
- CheckBox mEnableSmartLock ;
113
+ @ BindView (R .id .credential_selector_enabled )
114
+ CheckBox mEnableCredentialSelector ;
115
+
116
+ @ BindView (R .id .hint_selector_enabled )
117
+ CheckBox mEnableHintSelector ;
104
118
105
119
@ BindView (R .id .allow_new_email_accounts )
106
120
CheckBox mAllowNewEmailAccounts ;
@@ -120,22 +134,22 @@ public class AuthUiActivity extends AppCompatActivity {
120
134
@ BindView (R .id .google_scope_drive_file )
121
135
CheckBox mGoogleScopeDriveFile ;
122
136
123
- @ BindView (R .id .google_scope_games )
124
- CheckBox mGoogleScopeGames ;
137
+ @ BindView (R .id .google_scope_youtube_data )
138
+ CheckBox mGoogleScopeYoutubeData ;
125
139
126
140
@ Override
127
141
public void onCreate (Bundle savedInstanceState ) {
128
142
super .onCreate (savedInstanceState );
143
+ setContentView (R .layout .auth_ui_layout );
144
+ ButterKnife .bind (this );
129
145
130
146
FirebaseAuth auth = FirebaseAuth .getInstance ();
131
147
if (auth .getCurrentUser () != null ) {
132
- startActivity ( SignedInActivity . createIntent ( this , null ) );
148
+ startSignedInActivity ( null );
133
149
finish ();
150
+ return ;
134
151
}
135
152
136
- setContentView (R .layout .auth_ui_layout );
137
- ButterKnife .bind (this );
138
-
139
153
if (!isGoogleConfigured ()) {
140
154
mUseGoogleProvider .setChecked (false );
141
155
mUseGoogleProvider .setEnabled (false );
@@ -183,9 +197,11 @@ public void signIn(View view) {
183
197
AuthUI .getInstance ().createSignInIntentBuilder ()
184
198
.setTheme (getSelectedTheme ())
185
199
.setLogo (getSelectedLogo ())
186
- .setProviders (getSelectedProviders ())
200
+ .setAvailableProviders (getSelectedProviders ())
187
201
.setTosUrl (getSelectedTosUrl ())
188
- .setIsSmartLockEnabled (mEnableSmartLock .isChecked ())
202
+ .setPrivacyPolicyUrl (getSelectedPrivacyPolicyUrl ())
203
+ .setIsSmartLockEnabled (mEnableCredentialSelector .isChecked (),
204
+ mEnableHintSelector .isChecked ())
189
205
.setAllowNewEmailAccounts (mAllowNewEmailAccounts .isChecked ())
190
206
.build (),
191
207
RC_SIGN_IN );
@@ -208,7 +224,7 @@ private void handleSignInResponse(int resultCode, Intent data) {
208
224
209
225
// Successfully signed in
210
226
if (resultCode == ResultCodes .OK ) {
211
- startActivity ( SignedInActivity . createIntent ( this , response ) );
227
+ startSignedInActivity ( response );
212
228
finish ();
213
229
return ;
214
230
} else {
@@ -233,11 +249,25 @@ private void handleSignInResponse(int resultCode, Intent data) {
233
249
showSnackbar (R .string .unknown_sign_in_response );
234
250
}
235
251
252
+ private void startSignedInActivity (IdpResponse response ) {
253
+ startActivity (
254
+ SignedInActivity .createIntent (
255
+ this ,
256
+ response ,
257
+ new SignedInActivity .SignedInConfig (
258
+ getSelectedLogo (),
259
+ getSelectedTheme (),
260
+ getSelectedProviders (),
261
+ getSelectedTosUrl (),
262
+ mEnableCredentialSelector .isChecked (),
263
+ mEnableHintSelector .isChecked ())));
264
+ }
265
+
236
266
@ MainThread
237
267
private void setGoogleScopesEnabled (boolean enabled ) {
238
268
mGoogleScopesLabel .setEnabled (enabled );
239
269
mGoogleScopeDriveFile .setEnabled (enabled );
240
- mGoogleScopeGames .setEnabled (enabled );
270
+ mGoogleScopeYoutubeData .setEnabled (enabled );
241
271
}
242
272
243
273
@ MainThread
@@ -280,12 +310,11 @@ private int getSelectedLogo() {
280
310
private List <IdpConfig > getSelectedProviders () {
281
311
List <IdpConfig > selectedProviders = new ArrayList <>();
282
312
283
- if (mUseEmailProvider .isChecked ()) {
284
- selectedProviders .add (new IdpConfig .Builder (AuthUI .EMAIL_PROVIDER ).build ());
285
- }
286
-
287
- if (mUseTwitterProvider .isChecked ()) {
288
- selectedProviders .add (new IdpConfig .Builder (AuthUI .TWITTER_PROVIDER ).build ());
313
+ if (mUseGoogleProvider .isChecked ()) {
314
+ selectedProviders .add (
315
+ new IdpConfig .Builder (AuthUI .GOOGLE_PROVIDER )
316
+ .setPermissions (getGooglePermissions ())
317
+ .build ());
289
318
}
290
319
291
320
if (mUseFacebookProvider .isChecked ()) {
@@ -295,11 +324,17 @@ private List<IdpConfig> getSelectedProviders() {
295
324
.build ());
296
325
}
297
326
298
- if (mUseGoogleProvider .isChecked ()) {
327
+ if (mUseTwitterProvider .isChecked ()) {
328
+ selectedProviders .add (new IdpConfig .Builder (AuthUI .TWITTER_PROVIDER ).build ());
329
+ }
330
+
331
+ if (mUseEmailProvider .isChecked ()) {
332
+ selectedProviders .add (new IdpConfig .Builder (AuthUI .EMAIL_PROVIDER ).build ());
333
+ }
334
+
335
+ if (mUsePhoneProvider .isChecked ()) {
299
336
selectedProviders .add (
300
- new IdpConfig .Builder (AuthUI .GOOGLE_PROVIDER )
301
- .setPermissions (getGooglePermissions ())
302
- .build ());
337
+ new IdpConfig .Builder (AuthUI .PHONE_VERIFICATION_PROVIDER ).build ());
303
338
}
304
339
305
340
return selectedProviders ;
@@ -314,6 +349,15 @@ private String getSelectedTosUrl() {
314
349
return FIREBASE_TOS_URL ;
315
350
}
316
351
352
+ @ MainThread
353
+ private String getSelectedPrivacyPolicyUrl () {
354
+ if (mUseGooglePrivacyPolicy .isChecked ()) {
355
+ return GOOGLE_PRIVACY_POLICY_URL ;
356
+ }
357
+
358
+ return FIREBASE_PRIVACY_POLICY_URL ;
359
+ }
360
+
317
361
@ MainThread
318
362
private boolean isGoogleConfigured () {
319
363
return !UNCHANGED_CONFIG_VALUE .equals (
@@ -356,8 +400,8 @@ private List<String> getFacebookPermissions() {
356
400
@ MainThread
357
401
private List <String > getGooglePermissions () {
358
402
List <String > result = new ArrayList <>();
359
- if (mGoogleScopeGames .isChecked ()) {
360
- result .add (Scopes . GAMES );
403
+ if (mGoogleScopeYoutubeData .isChecked ()) {
404
+ result .add ("https://www.googleapis.com/auth/youtube.readonly" );
361
405
}
362
406
if (mGoogleScopeDriveFile .isChecked ()) {
363
407
result .add (Scopes .DRIVE_FILE );
0 commit comments