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 ;
@@ -163,74 +157,6 @@ public static int getDefaultTheme() {
163
157
return R .style .FirebaseUI ;
164
158
}
165
159
166
- /**
167
- * Signs the current user out, if one is signed in.
168
- *
169
- * @param activity The activity requesting the user be signed out.
170
- * @return a task which, upon completion, signals that the user has been signed out ({@code
171
- * result.isSuccess()}, or that the sign-out attempt failed unexpectedly ({@code
172
- * !result.isSuccess()}).
173
- * @deprecated use {@link #signOut(FragmentActivity)} instead
174
- */
175
- @ Deprecated
176
- public Task <Void > signOut (@ NonNull Activity activity ) {
177
- // Get helper for Google Sign In and Credentials API
178
- GoogleApiClientTaskHelper taskHelper = GoogleApiClientTaskHelper .getInstance (activity );
179
- taskHelper .getBuilder ()
180
- .addApi (Auth .CREDENTIALS_API )
181
- .addApi (Auth .GOOGLE_SIGN_IN_API , GoogleSignInOptions .DEFAULT_SIGN_IN );
182
-
183
- // Get Credentials Helper
184
- CredentialTaskApi credentialsHelper = CredentialsApiHelper .getInstance (taskHelper );
185
-
186
- // Firebase Sign out
187
- mAuth .signOut ();
188
-
189
- // Disable credentials auto sign-in
190
- Task <Status > disableCredentialsTask = credentialsHelper .disableAutoSignIn ();
191
-
192
- // Google sign out
193
- Task <Void > googleSignOutTask = taskHelper .getConnectedGoogleApiClient ()
194
- .continueWith (new Continuation <GoogleApiClient , Void >() {
195
- @ Override
196
- public Void then (@ NonNull Task <GoogleApiClient > task ) throws Exception {
197
- if (task .isSuccessful ()) {
198
- Auth .GoogleSignInApi .signOut (task .getResult ());
199
- }
200
- return null ;
201
- }
202
- });
203
-
204
- // Facebook sign out
205
- LoginManager .getInstance ().logOut ();
206
-
207
- // Twitter sign out
208
- if (!Fabric .isInitialized ()) TwitterProvider .initialize (activity );
209
- Twitter .logOut ();
210
-
211
- // Wait for all tasks to complete
212
- return Tasks .whenAll (disableCredentialsTask , googleSignOutTask );
213
- }
214
-
215
- /**
216
- * Delete the use from FirebaseAuth and delete any associated credentials from the Credentials
217
- * API. Returns a {@code Task} that succeeds if the Firebase Auth user deletion succeeds and
218
- * fails if the Firebase Auth deletion fails. Credentials deletion failures are handled
219
- * silently.
220
- *
221
- * @param activity the calling {@link Activity}.
222
- * @deprecated use {@link #delete(FragmentActivity)} instead
223
- */
224
- @ Deprecated
225
- public Task <Void > delete (@ NonNull Activity activity ) {
226
- // Initialize SmartLock helper
227
- GoogleApiClientTaskHelper gacHelper = GoogleApiClientTaskHelper .getInstance (activity );
228
- gacHelper .getBuilder ().addApi (Auth .CREDENTIALS_API );
229
- CredentialTaskApi credentialHelper = CredentialsApiHelper .getInstance (gacHelper );
230
-
231
- return getDeleteTask (credentialHelper );
232
- }
233
-
234
160
/**
235
161
* Signs the current user out, if one is signed in.
236
162
*
@@ -241,16 +167,16 @@ public Task<Void> delete(@NonNull Activity activity) {
241
167
*/
242
168
public Task <Void > signOut (@ NonNull FragmentActivity activity ) {
243
169
// Get Credentials Helper
244
- GoogleSignInHelper credentialsHelper = GoogleSignInHelper .getInstance (activity );
170
+ GoogleSignInHelper signInHelper = GoogleSignInHelper .getInstance (activity );
245
171
246
172
// Firebase Sign out
247
173
mAuth .signOut ();
248
174
249
175
// Disable credentials auto sign-in
250
- Task <Status > disableCredentialsTask = credentialsHelper .disableAutoSignIn ();
176
+ Task <Status > disableCredentialsTask = signInHelper .disableAutoSignIn ();
251
177
252
178
// Google sign out
253
- Task <Status > signOutTask = credentialsHelper .signOut ();
179
+ Task <Status > signOutTask = signInHelper .signOut ();
254
180
255
181
// Facebook sign out
256
182
LoginManager .getInstance ().logOut ();
@@ -273,12 +199,8 @@ public Task<Void> signOut(@NonNull FragmentActivity activity) {
273
199
*/
274
200
public Task <Void > delete (@ NonNull FragmentActivity activity ) {
275
201
// Initialize SmartLock helper
276
- CredentialTaskApi credentialHelper = GoogleSignInHelper .getInstance (activity );
277
-
278
- return getDeleteTask (credentialHelper );
279
- }
202
+ GoogleSignInHelper signInHelper = GoogleSignInHelper .getInstance (activity );
280
203
281
- private Task <Void > getDeleteTask (CredentialTaskApi credentialHelper ) {
282
204
FirebaseUser firebaseUser = FirebaseAuth .getInstance ().getCurrentUser ();
283
205
if (firebaseUser == null ) {
284
206
// If the current user is null, return a failed task immediately
@@ -294,7 +216,7 @@ private Task<Void> getDeleteTask(CredentialTaskApi credentialHelper) {
294
216
// For each Credential in the list, create a task to delete it.
295
217
List <Task <?>> credentialTasks = new ArrayList <>();
296
218
for (Credential credential : credentials ) {
297
- credentialTasks .add (credentialHelper .delete (credential ));
219
+ credentialTasks .add (signInHelper .delete (credential ));
298
220
}
299
221
300
222
// Create a combined task that will succeed when all credential delete operations
@@ -549,39 +471,6 @@ public T setProviders(@NonNull List<IdpConfig> idpConfigs) {
549
471
return (T ) this ;
550
472
}
551
473
552
- /**
553
- * Specifies the set of supported authentication providers. At least one provider
554
- * must be specified, and the set of providers must be a subset of
555
- * {@link #SUPPORTED_PROVIDERS}. There may only be one instance of each provider.
556
- * <p>
557
- * <p>If no providers are explicitly specified by calling this method, then
558
- * {@link #EMAIL_PROVIDER email} is the default supported provider.
559
- *
560
- * @see #EMAIL_PROVIDER
561
- * @see #FACEBOOK_PROVIDER
562
- * @see #GOOGLE_PROVIDER
563
- */
564
- @ Deprecated
565
- public T setProviders (@ NonNull String ... providers ) {
566
- mProviders .clear (); // clear the default email provider
567
- for (String provider : providers ) {
568
- if (isIdpAlreadyConfigured (provider )) {
569
- throw new IllegalArgumentException ("Provider already configured: " + provider );
570
- }
571
- mProviders .add (new IdpConfig .Builder (provider ).build ());
572
- }
573
- return (T ) this ;
574
- }
575
-
576
- private boolean isIdpAlreadyConfigured (@ NonNull String providerId ) {
577
- for (IdpConfig config : mProviders ) {
578
- if (config .getProviderId ().equals (providerId )) {
579
- return true ;
580
- }
581
- }
582
- return false ;
583
- }
584
-
585
474
/**
586
475
* Enables or disables the use of Smart Lock for Passwords in the sign in flow.
587
476
* <p>
0 commit comments