|
31 | 31 |
|
32 | 32 | import com.facebook.login.LoginManager; |
33 | 33 | import com.firebase.ui.auth.data.model.FlowParameters; |
34 | | -import com.firebase.ui.auth.provider.TwitterProvider; |
| 34 | +import com.firebase.ui.auth.data.remote.FacebookSignInHandler; |
| 35 | +import com.firebase.ui.auth.data.remote.TwitterSignInHandler; |
35 | 36 | import com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity; |
36 | 37 | import com.firebase.ui.auth.util.ExtraConstants; |
37 | 38 | import com.firebase.ui.auth.util.GoogleApiUtils; |
|
59 | 60 | import com.google.firebase.auth.PhoneAuthProvider; |
60 | 61 | import com.google.firebase.auth.TwitterAuthProvider; |
61 | 62 | import com.google.firebase.auth.UserInfo; |
| 63 | +import com.twitter.sdk.android.core.TwitterCore; |
62 | 64 |
|
63 | 65 | import java.lang.annotation.Retention; |
64 | 66 | import java.lang.annotation.RetentionPolicy; |
@@ -177,10 +179,10 @@ public class AuthUI { |
177 | 179 | */ |
178 | 180 | public static final Set<String> SUPPORTED_PROVIDERS = |
179 | 181 | Collections.unmodifiableSet(new HashSet<>(Arrays.asList( |
180 | | - EmailAuthProvider.PROVIDER_ID, |
181 | 182 | GoogleAuthProvider.PROVIDER_ID, |
182 | 183 | FacebookAuthProvider.PROVIDER_ID, |
183 | 184 | TwitterAuthProvider.PROVIDER_ID, |
| 185 | + EmailAuthProvider.PROVIDER_ID, |
184 | 186 | PhoneAuthProvider.PROVIDER_ID |
185 | 187 | ))); |
186 | 188 |
|
@@ -276,7 +278,7 @@ public Task<Void> signOut(@NonNull Context context) { |
276 | 278 | .disableAutoSignIn() |
277 | 279 | .continueWithTask(new Continuation<Void, Task<Void>>() { |
278 | 280 | @Override |
279 | | - public Task<Void> then(@NonNull Task<Void> task) throws Exception { |
| 281 | + public Task<Void> then(@NonNull Task<Void> task) { |
280 | 282 | // We want to ignore a specific exception, since it's not a good reason |
281 | 283 | // to fail (see Issue 1156). |
282 | 284 | if (!task.isSuccessful() && (task.getException() instanceof ApiException)) { |
@@ -357,22 +359,12 @@ public Task<Void> then(@NonNull Task<Void> task) { |
357 | 359 | } |
358 | 360 |
|
359 | 361 | private Task<Void> signOutIdps(@NonNull Context context) { |
360 | | - try { |
| 362 | + if (FacebookSignInHandler.IS_AVAILABLE) { |
361 | 363 | LoginManager.getInstance().logOut(); |
362 | | - } catch (NoClassDefFoundError e) { |
363 | | - // Do nothing: this is perfectly fine if the dev doesn't include Facebook/Twitter |
364 | | - // support |
365 | 364 | } |
366 | | - |
367 | | - try { |
368 | | - TwitterProvider.signOut(context); |
369 | | - } catch (NoClassDefFoundError e) { |
370 | | - // See comment above |
371 | | - // Note: we need to have separate try/catch statements since devs can include |
372 | | - // _either_ one of the providers. If one crashes, we still need to sign out of |
373 | | - // the other one. |
| 365 | + if (TwitterSignInHandler.IS_AVAILABLE) { |
| 366 | + TwitterCore.getInstance().getSessionManager().clearActiveSession(); |
374 | 367 | } |
375 | | - |
376 | 368 | return GoogleSignIn.getClient(context, GoogleSignInOptions.DEFAULT_SIGN_IN).signOut(); |
377 | 369 | } |
378 | 370 |
|
@@ -787,17 +779,12 @@ public static final class FacebookBuilder extends Builder { |
787 | 779 | public FacebookBuilder() { |
788 | 780 | //noinspection deprecation taking a hit for the backcompat team |
789 | 781 | super(FacebookAuthProvider.PROVIDER_ID); |
790 | | - |
791 | | - try { |
792 | | - //noinspection unused to possibly throw |
793 | | - Class c = com.facebook.FacebookSdk.class; |
794 | | - } catch (NoClassDefFoundError e) { |
| 782 | + if (!FacebookSignInHandler.IS_AVAILABLE) { |
795 | 783 | throw new RuntimeException( |
796 | 784 | "Facebook provider cannot be configured " + |
797 | 785 | "without dependency. Did you forget to add " + |
798 | 786 | "'com.facebook.android:facebook-login:VERSION' dependency?"); |
799 | 787 | } |
800 | | - |
801 | 788 | Preconditions.checkConfigured(getApplicationContext(), |
802 | 789 | "Facebook provider unconfigured. Make sure to add a" + |
803 | 790 | " `facebook_application_id` string. See the docs for more info:" + |
@@ -830,17 +817,12 @@ public static final class TwitterBuilder extends Builder { |
830 | 817 | public TwitterBuilder() { |
831 | 818 | //noinspection deprecation taking a hit for the backcompat team |
832 | 819 | super(TwitterAuthProvider.PROVIDER_ID); |
833 | | - |
834 | | - try { |
835 | | - //noinspection unused to possibly throw |
836 | | - Class c = com.twitter.sdk.android.core.TwitterCore.class; |
837 | | - } catch (NoClassDefFoundError e) { |
| 820 | + if (!TwitterSignInHandler.IS_AVAILABLE) { |
838 | 821 | throw new RuntimeException( |
839 | 822 | "Twitter provider cannot be configured " + |
840 | 823 | "without dependency. Did you forget to add " + |
841 | 824 | "'com.twitter.sdk.android:twitter-core:VERSION' dependency?"); |
842 | 825 | } |
843 | | - |
844 | 826 | Preconditions.checkConfigured(getApplicationContext(), |
845 | 827 | "Twitter provider unconfigured. Make sure to add your key and secret." + |
846 | 828 | " See the docs for more info:" + |
|
0 commit comments