@@ -65,9 +65,7 @@ public class SignInDelegate extends SmartLock<CredentialRequestResult> {
65
65
private AuthUI .AuthUIResult mAuthUIResult ;
66
66
private FlowParameters mFlowParams ;
67
67
private ProgressDialog mProgressDialog ;
68
-
69
68
private GoogleApiClient mGoogleApiClient ;
70
- private CredentialRequestResult mCredentialRequestResult ;
71
69
private Credential mCredential ;
72
70
73
71
@ Override
@@ -82,7 +80,8 @@ public void onCreate(Bundle savedInstance) {
82
80
new DialogInterface .OnCancelListener () {
83
81
@ Override
84
82
public void onCancel (DialogInterface dialogInterface ) {
85
- Log .w (TAG , "playServices:dialog.onCancel()" );
83
+ Log .w (TAG ,
84
+ "playServices:dialog.onCancel()" );
86
85
finish (RESULT_CANCELED , new Intent ());
87
86
}
88
87
});
@@ -113,36 +112,36 @@ public void onCancel(DialogInterface dialogInterface) {
113
112
114
113
@ Override
115
114
public void onResult (@ NonNull CredentialRequestResult result ) {
116
- mCredentialRequestResult = result ;
117
115
Status status = result .getStatus ();
118
116
119
117
if (status .isSuccess ()) {
120
118
// Auto sign-in success
121
119
handleCredential (result .getCredential ());
122
- delegateSignIn (true );
123
- } else if (status .getStatusCode () == CommonStatusCodes .RESOLUTION_REQUIRED ) {
124
- delegateSignIn (false );
125
- }
126
- }
127
-
128
- private void delegateSignIn (boolean isAutoSignInAvailable ) {
129
- String email = getEmailFromCredential ();
130
- String password = getPasswordFromCredential ();
120
+ String email = getEmailFromCredential ();
121
+ String password = getPasswordFromCredential ();
131
122
132
- // Attempt auto-sign in using SmartLock
133
- if (isAutoSignInAvailable ) {
134
123
if (TextUtils .isEmpty (password )) {
135
124
// log in with id/provider
136
125
redirectToIdpSignIn (email , getAccountTypeFromCredential ());
137
126
} else {
138
127
// Sign in with the email/password retrieved from SmartLock
139
128
signInWithEmailAndPassword (email , password );
140
129
}
141
- } else {
142
- // resolve credential
143
- resolveSavedEmails ();
130
+ } else if (status .getStatusCode () == CommonStatusCodes .RESOLUTION_REQUIRED ) {
131
+ hideProgress ();
132
+ // resolve saved emails
133
+ try {
134
+ startIntentSenderForResult (status .getResolution ().getIntentSender (),
135
+ RC_CREDENTIALS_READ ,
136
+ null ,
137
+ 0 ,
138
+ 0 ,
139
+ 0 ,
140
+ null );
141
+ } catch (IntentSender .SendIntentException e ) {
142
+ Log .e (TAG , "Failed to send Credentials intent." , e );
143
+ }
144
144
}
145
- hideProgress ();
146
145
}
147
146
148
147
@ Override
@@ -252,26 +251,6 @@ private void initGoogleApiClient(String accountName) {
252
251
mGoogleApiClient .connect ();
253
252
}
254
253
255
- private void resolveSavedEmails () {
256
- if (mCredentialRequestResult == null || mCredentialRequestResult .getStatus () == null ) {
257
- return ;
258
- }
259
- Status status = mCredentialRequestResult .getStatus ();
260
- if (status .getStatusCode () == CommonStatusCodes .RESOLUTION_REQUIRED ) {
261
- try {
262
- startIntentSenderForResult (status .getResolution ().getIntentSender (),
263
- RC_CREDENTIALS_READ ,
264
- null ,
265
- 0 ,
266
- 0 ,
267
- 0 ,
268
- null );
269
- } catch (IntentSender .SendIntentException e ) {
270
- Log .e (TAG , "Failed to send Credentials intent." , e );
271
- }
272
- }
273
- }
274
-
275
254
private void startAuthMethodChoice () {
276
255
List <IDPProviderParcel > providers = mFlowParams .providerInfo ;
277
256
@@ -394,6 +373,7 @@ private void finish(int resultCode, Intent data) {
394
373
if (mGoogleApiClient != null ) {
395
374
mGoogleApiClient .disconnect ();
396
375
}
376
+ hideProgress ();
397
377
mAuthUIResult .onResult (resultCode , data );
398
378
getActivity ().getSupportFragmentManager ().beginTransaction ().remove (this ).commit ();
399
379
}
0 commit comments