@@ -52,6 +52,8 @@ public class AuthUiActivity extends AppCompatActivity {
5252 private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME" ;
5353 private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/" ;
5454 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" ;
5557 private static final int RC_SIGN_IN = 100 ;
5658
5759 @ BindView (R .id .default_theme )
@@ -69,6 +71,9 @@ public class AuthUiActivity extends AppCompatActivity {
6971 @ BindView (R .id .email_provider )
7072 CheckBox mUseEmailProvider ;
7173
74+ @ BindView (R .id .phone_provider )
75+ CheckBox mUsePhoneProvider ;
76+
7277 @ BindView (R .id .google_provider )
7378 CheckBox mUseGoogleProvider ;
7479
@@ -84,6 +89,12 @@ public class AuthUiActivity extends AppCompatActivity {
8489 @ BindView (R .id .firebase_tos )
8590 RadioButton mUseFirebaseTos ;
8691
92+ @ BindView (R .id .google_privacy )
93+ RadioButton mUseGooglePrivacyPolicy ;
94+
95+ @ BindView (R .id .firebase_privacy )
96+ RadioButton mUseFirebasePrivacyPolicy ;
97+
8798 @ BindView (R .id .sign_in )
8899 Button mSignIn ;
89100
@@ -99,8 +110,11 @@ public class AuthUiActivity extends AppCompatActivity {
99110 @ BindView (R .id .no_logo )
100111 RadioButton mNoLogo ;
101112
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 ;
104118
105119 @ BindView (R .id .allow_new_email_accounts )
106120 CheckBox mAllowNewEmailAccounts ;
@@ -120,22 +134,22 @@ public class AuthUiActivity extends AppCompatActivity {
120134 @ BindView (R .id .google_scope_drive_file )
121135 CheckBox mGoogleScopeDriveFile ;
122136
123- @ BindView (R .id .google_scope_games )
124- CheckBox mGoogleScopeGames ;
137+ @ BindView (R .id .google_scope_youtube_data )
138+ CheckBox mGoogleScopeYoutubeData ;
125139
126140 @ Override
127141 public void onCreate (Bundle savedInstanceState ) {
128142 super .onCreate (savedInstanceState );
143+ setContentView (R .layout .auth_ui_layout );
144+ ButterKnife .bind (this );
129145
130146 FirebaseAuth auth = FirebaseAuth .getInstance ();
131147 if (auth .getCurrentUser () != null ) {
132- startActivity ( SignedInActivity . createIntent ( this , null ) );
148+ startSignedInActivity ( null );
133149 finish ();
150+ return ;
134151 }
135152
136- setContentView (R .layout .auth_ui_layout );
137- ButterKnife .bind (this );
138-
139153 if (!isGoogleConfigured ()) {
140154 mUseGoogleProvider .setChecked (false );
141155 mUseGoogleProvider .setEnabled (false );
@@ -183,9 +197,11 @@ public void signIn(View view) {
183197 AuthUI .getInstance ().createSignInIntentBuilder ()
184198 .setTheme (getSelectedTheme ())
185199 .setLogo (getSelectedLogo ())
186- .setProviders (getSelectedProviders ())
200+ .setAvailableProviders (getSelectedProviders ())
187201 .setTosUrl (getSelectedTosUrl ())
188- .setIsSmartLockEnabled (mEnableSmartLock .isChecked ())
202+ .setPrivacyPolicyUrl (getSelectedPrivacyPolicyUrl ())
203+ .setIsSmartLockEnabled (mEnableCredentialSelector .isChecked (),
204+ mEnableHintSelector .isChecked ())
189205 .setAllowNewEmailAccounts (mAllowNewEmailAccounts .isChecked ())
190206 .build (),
191207 RC_SIGN_IN );
@@ -208,7 +224,7 @@ private void handleSignInResponse(int resultCode, Intent data) {
208224
209225 // Successfully signed in
210226 if (resultCode == ResultCodes .OK ) {
211- startActivity ( SignedInActivity . createIntent ( this , response ) );
227+ startSignedInActivity ( response );
212228 finish ();
213229 return ;
214230 } else {
@@ -233,11 +249,25 @@ private void handleSignInResponse(int resultCode, Intent data) {
233249 showSnackbar (R .string .unknown_sign_in_response );
234250 }
235251
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+
236266 @ MainThread
237267 private void setGoogleScopesEnabled (boolean enabled ) {
238268 mGoogleScopesLabel .setEnabled (enabled );
239269 mGoogleScopeDriveFile .setEnabled (enabled );
240- mGoogleScopeGames .setEnabled (enabled );
270+ mGoogleScopeYoutubeData .setEnabled (enabled );
241271 }
242272
243273 @ MainThread
@@ -280,12 +310,11 @@ private int getSelectedLogo() {
280310 private List <IdpConfig > getSelectedProviders () {
281311 List <IdpConfig > selectedProviders = new ArrayList <>();
282312
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 ());
289318 }
290319
291320 if (mUseFacebookProvider .isChecked ()) {
@@ -295,11 +324,17 @@ private List<IdpConfig> getSelectedProviders() {
295324 .build ());
296325 }
297326
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 ()) {
299336 selectedProviders .add (
300- new IdpConfig .Builder (AuthUI .GOOGLE_PROVIDER )
301- .setPermissions (getGooglePermissions ())
302- .build ());
337+ new IdpConfig .Builder (AuthUI .PHONE_VERIFICATION_PROVIDER ).build ());
303338 }
304339
305340 return selectedProviders ;
@@ -314,6 +349,15 @@ private String getSelectedTosUrl() {
314349 return FIREBASE_TOS_URL ;
315350 }
316351
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+
317361 @ MainThread
318362 private boolean isGoogleConfigured () {
319363 return !UNCHANGED_CONFIG_VALUE .equals (
@@ -356,8 +400,8 @@ private List<String> getFacebookPermissions() {
356400 @ MainThread
357401 private List <String > getGooglePermissions () {
358402 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" );
361405 }
362406 if (mGoogleScopeDriveFile .isChecked ()) {
363407 result .add (Scopes .DRIVE_FILE );
0 commit comments