30
30
import com .firebase .ui .auth .provider .TwitterProvider ;
31
31
import com .firebase .ui .auth .ui .FlowParameters ;
32
32
import com .firebase .ui .auth .ui .idp .AuthMethodPickerActivity ;
33
- import com .firebase .ui .auth .util .CredentialTaskApi ;
34
- import com .firebase .ui .auth .util .CredentialsApiHelper ;
35
- import com .firebase .ui .auth .util .GoogleApiClientTaskHelper ;
36
33
import com .firebase .ui .auth .util .GoogleSignInHelper ;
37
34
import com .firebase .ui .auth .util .Preconditions ;
38
35
import com .firebase .ui .auth .util .signincontainer .SmartLockBase ;
39
- import com .google .android .gms .auth .api .Auth ;
40
36
import com .google .android .gms .auth .api .credentials .Credential ;
41
- import com .google .android .gms .auth .api .signin .GoogleSignInOptions ;
42
- import com .google .android .gms .common .api .GoogleApiClient ;
43
37
import com .google .android .gms .common .api .Status ;
44
38
import com .google .android .gms .tasks .Continuation ;
45
39
import com .google .android .gms .tasks .Task ;
@@ -168,81 +162,6 @@ public static int getDefaultTheme() {
168
162
return R .style .FirebaseUI ;
169
163
}
170
164
171
- /**
172
- * Signs the current user out, if one is signed in.
173
- *
174
- * @param activity The activity requesting the user be signed out.
175
- * @return a task which, upon completion, signals that the user has been signed out ({@code
176
- * result.isSuccess()}, or that the sign-out attempt failed unexpectedly ({@code
177
- * !result.isSuccess()}).
178
- * @deprecated use {@link #signOut(FragmentActivity)} instead
179
- */
180
- @ Deprecated
181
- public Task <Void > signOut (@ NonNull Activity activity ) {
182
- // Get helper for Google Sign In and Credentials API
183
- GoogleApiClientTaskHelper taskHelper = GoogleApiClientTaskHelper .getInstance (activity );
184
- taskHelper .getBuilder ()
185
- .addApi (Auth .CREDENTIALS_API )
186
- .addApi (Auth .GOOGLE_SIGN_IN_API , GoogleSignInOptions .DEFAULT_SIGN_IN );
187
-
188
- // Get Credentials Helper
189
- CredentialTaskApi credentialsHelper = CredentialsApiHelper .getInstance (taskHelper );
190
-
191
- // Firebase Sign out
192
- mAuth .signOut ();
193
-
194
- // Disable credentials auto sign-in
195
- Task <Status > disableCredentialsTask = credentialsHelper .disableAutoSignIn ();
196
-
197
- // Google sign out
198
- Task <Void > googleSignOutTask = taskHelper .getConnectedGoogleApiClient ()
199
- .continueWith (new Continuation <GoogleApiClient , Void >() {
200
- @ Override
201
- public Void then (@ NonNull Task <GoogleApiClient > task ) throws Exception {
202
- if (task .isSuccessful ()) {
203
- Auth .GoogleSignInApi .signOut (task .getResult ());
204
- }
205
- return null ;
206
- }
207
- });
208
-
209
- // Facebook sign out
210
- try {
211
- LoginManager .getInstance ().logOut ();
212
- } catch (NoClassDefFoundError e ) {
213
- // do nothing
214
- }
215
-
216
- // Twitter sign out
217
- try {
218
- TwitterProvider .signout (activity );
219
- } catch (NoClassDefFoundError e ) {
220
- // do nothing
221
- }
222
-
223
- // Wait for all tasks to complete
224
- return Tasks .whenAll (disableCredentialsTask , googleSignOutTask );
225
- }
226
-
227
- /**
228
- * Delete the use from FirebaseAuth and delete any associated credentials from the Credentials
229
- * API. Returns a {@code Task} that succeeds if the Firebase Auth user deletion succeeds and
230
- * fails if the Firebase Auth deletion fails. Credentials deletion failures are handled
231
- * silently.
232
- *
233
- * @param activity the calling {@link Activity}.
234
- * @deprecated use {@link #delete(FragmentActivity)} instead
235
- */
236
- @ Deprecated
237
- public Task <Void > delete (@ NonNull Activity activity ) {
238
- // Initialize SmartLock helper
239
- GoogleApiClientTaskHelper gacHelper = GoogleApiClientTaskHelper .getInstance (activity );
240
- gacHelper .getBuilder ().addApi (Auth .CREDENTIALS_API );
241
- CredentialTaskApi credentialHelper = CredentialsApiHelper .getInstance (gacHelper );
242
-
243
- return getDeleteTask (credentialHelper );
244
- }
245
-
246
165
/**
247
166
* Signs the current user out, if one is signed in.
248
167
*
@@ -253,16 +172,16 @@ public Task<Void> delete(@NonNull Activity activity) {
253
172
*/
254
173
public Task <Void > signOut (@ NonNull FragmentActivity activity ) {
255
174
// Get Credentials Helper
256
- GoogleSignInHelper credentialsHelper = GoogleSignInHelper .getInstance (activity );
175
+ GoogleSignInHelper signInHelper = GoogleSignInHelper .getInstance (activity );
257
176
258
177
// Firebase Sign out
259
178
mAuth .signOut ();
260
179
261
180
// Disable credentials auto sign-in
262
- Task <Status > disableCredentialsTask = credentialsHelper .disableAutoSignIn ();
181
+ Task <Status > disableCredentialsTask = signInHelper .disableAutoSignIn ();
263
182
264
183
// Google sign out
265
- Task <Status > signOutTask = credentialsHelper .signOut ();
184
+ Task <Status > signOutTask = signInHelper .signOut ();
266
185
267
186
// Facebook sign out
268
187
try {
@@ -291,12 +210,8 @@ public Task<Void> signOut(@NonNull FragmentActivity activity) {
291
210
*/
292
211
public Task <Void > delete (@ NonNull FragmentActivity activity ) {
293
212
// Initialize SmartLock helper
294
- CredentialTaskApi credentialHelper = GoogleSignInHelper .getInstance (activity );
295
-
296
- return getDeleteTask (credentialHelper );
297
- }
213
+ GoogleSignInHelper signInHelper = GoogleSignInHelper .getInstance (activity );
298
214
299
- private Task <Void > getDeleteTask (CredentialTaskApi credentialHelper ) {
300
215
FirebaseUser firebaseUser = FirebaseAuth .getInstance ().getCurrentUser ();
301
216
if (firebaseUser == null ) {
302
217
// If the current user is null, return a failed task immediately
@@ -312,7 +227,7 @@ private Task<Void> getDeleteTask(CredentialTaskApi credentialHelper) {
312
227
// For each Credential in the list, create a task to delete it.
313
228
List <Task <?>> credentialTasks = new ArrayList <>();
314
229
for (Credential credential : credentials ) {
315
- credentialTasks .add (credentialHelper .delete (credential ));
230
+ credentialTasks .add (signInHelper .delete (credential ));
316
231
}
317
232
318
233
// Create a combined task that will succeed when all credential delete operations
@@ -588,39 +503,6 @@ public T setProviders(@NonNull List<IdpConfig> idpConfigs) {
588
503
return (T ) this ;
589
504
}
590
505
591
- /**
592
- * Specifies the set of supported authentication providers. At least one provider
593
- * must be specified, and the set of providers must be a subset of
594
- * {@link #SUPPORTED_PROVIDERS}. There may only be one instance of each provider.
595
- * <p>
596
- * <p>If no providers are explicitly specified by calling this method, then
597
- * {@link #EMAIL_PROVIDER email} is the default supported provider.
598
- *
599
- * @see #EMAIL_PROVIDER
600
- * @see #FACEBOOK_PROVIDER
601
- * @see #GOOGLE_PROVIDER
602
- */
603
- @ Deprecated
604
- public T setProviders (@ NonNull String ... providers ) {
605
- mProviders .clear (); // clear the default email provider
606
- for (String provider : providers ) {
607
- if (isIdpAlreadyConfigured (provider )) {
608
- throw new IllegalArgumentException ("Provider already configured: " + provider );
609
- }
610
- mProviders .add (new IdpConfig .Builder (provider ).build ());
611
- }
612
- return (T ) this ;
613
- }
614
-
615
- private boolean isIdpAlreadyConfigured (@ NonNull String providerId ) {
616
- for (IdpConfig config : mProviders ) {
617
- if (config .getProviderId ().equals (providerId )) {
618
- return true ;
619
- }
620
- }
621
- return false ;
622
- }
623
-
624
506
/**
625
507
* Enables or disables the use of Smart Lock for Passwords in the sign in flow.
626
508
* To (en)disable hint selector and credential selector independently
0 commit comments