24
24
import com .firebase .ui .auth .ui .User ;
25
25
import com .firebase .ui .auth .ui .email .RegisterEmailActivity ;
26
26
import com .firebase .ui .auth .ui .idp .AuthMethodPickerActivity ;
27
+ import com .firebase .ui .auth .ui .phone .PhoneVerificationActivity ;
27
28
import com .firebase .ui .auth .util .GoogleApiHelper ;
28
29
import com .firebase .ui .auth .util .GoogleSignInHelper ;
29
30
import com .google .android .gms .auth .api .Auth ;
43
44
import com .google .firebase .auth .FacebookAuthProvider ;
44
45
import com .google .firebase .auth .FirebaseAuthInvalidUserException ;
45
46
import com .google .firebase .auth .GoogleAuthProvider ;
47
+ import com .google .firebase .auth .PhoneAuthProvider ;
46
48
import com .google .firebase .auth .TwitterAuthProvider ;
47
49
import java .util .ArrayList ;
48
50
import java .util .HashMap ;
@@ -64,6 +66,7 @@ public class SignInDelegate extends SmartLockBase<CredentialRequestResult> {
64
66
private static final int RC_IDP_SIGNIN = 3 ;
65
67
private static final int RC_AUTH_METHOD_PICKER = 4 ;
66
68
private static final int RC_EMAIL_FLOW = 5 ;
69
+ private static final int RC_PHONE_FLOW = 6 ;
67
70
68
71
private Credential mCredential ;
69
72
@@ -242,16 +245,22 @@ private void startAuthMethodChoice() {
242
245
243
246
List <IdpConfig > visibleProviders = idpConfigs ;
244
247
245
- // If the only provider is Email, immediately launch the email flow. Otherwise, launch
246
- // the auth method picker screen.
248
+ // If there is only one provider selected, launch the flow directly
247
249
if (visibleProviders .size () == 1 ) {
248
- if (visibleProviders .get (0 ).getProviderId ().equals (EmailAuthProvider .PROVIDER_ID )) {
250
+ String firstProvider = visibleProviders .get (0 ).getProviderId ();
251
+ if (firstProvider .equals (EmailAuthProvider .PROVIDER_ID )) {
252
+ // Go directly to email flow
249
253
startActivityForResult (
250
254
RegisterEmailActivity .createIntent (getContext (), flowParams ),
251
255
RC_EMAIL_FLOW );
256
+ } else if (firstProvider .equals (PhoneAuthProvider .PROVIDER_ID )) {
257
+ // Go directly to phone flow
258
+ startActivityForResult (
259
+ PhoneVerificationActivity .createIntent (getContext (), flowParams , null ),
260
+ RC_PHONE_FLOW );
252
261
} else {
253
- redirectToIdpSignIn ( null , providerIdToAccountType (
254
- visibleProviders . get ( 0 ). getProviderId () ));
262
+ // Launch IDP flow
263
+ redirectToIdpSignIn ( null , providerIdToAccountType ( firstProvider ));
255
264
}
256
265
} else {
257
266
startActivityForResult (
0 commit comments