com.firebase.ui.auth.AuthUI Java Examples

The following examples show how to use com.firebase.ui.auth.AuthUI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActivity.java    From cannonball-android with Apache License 2.0 7 votes vote down vote up
private void setUpPhoneAuthButton() {
    phoneButton = (Button) findViewById(R.id.phone_button);

    phoneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            List<AuthUI.IdpConfig> providers = Arrays.asList(
                    new AuthUI.IdpConfig.PhoneBuilder().build()
            );

            startActivityForResult(
                    AuthUI.getInstance()
                            .createSignInIntentBuilder()
                            .setAvailableProviders(providers)
                            .build(),
                    RC_SIGN_IN
            );
        }
    });
}
 
Example #2
Source File: SignedInActivity.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.sign_out)
public void signOut() {
    AuthUI.getInstance()
            .signOut(this)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        startActivity(AuthUiActivity.createIntent(SignedInActivity.this));
                        finish();
                    } else {
                        Log.w(TAG, "signOut:failure", task.getException());
                        showSnackbar(R.string.sign_out_failed);
                    }
                }
            });
}
 
Example #3
Source File: MainActivity.java    From CloudFunctionsExample with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case R.id.subscribe:
            FirebaseMessaging.getInstance().subscribeToTopic("pushNotifications");
            Toast.makeText(MainActivity.this, "Subscribed to Topic: Push Notifications", Toast.LENGTH_SHORT).show();
            break;
        case R.id.unsubscribe:
            FirebaseMessaging.getInstance().unsubscribeFromTopic("pushNotifications");
            Toast.makeText(MainActivity.this, "Unsubscribed to Topic: Push Notifications", Toast.LENGTH_SHORT).show();
            break;
        case R.id.sign_out_menu:
            AuthUI.getInstance().signOut(this);
            break;

        default:
            return super.onOptionsItemSelected(item);

    }
return true;}
 
Example #4
Source File: MainActivity.java    From firestore-android-arch-components with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO: 10/30/17 respect the design remove repository from here.
    MainRepository repository = viewModel.getRepository();
    switch (item.getItemId()) {
        case R.id.menu_add_items:
            repository.addRestaurants(this);
            break;
        case R.id.menu_sign_out:
            AuthUI.getInstance().signOut(this);
            startSignIn();
            break;
        case R.id.menu_delete:
            repository.deleteAll();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example #5
Source File: AboutActivity.java    From cannonball-android with Apache License 2.0 6 votes vote down vote up
private void setUpSignOut() {
    final TextView bt = (TextView) findViewById(R.id.deactivate_accounts);
    final Context ctx = this;

    bt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AuthUI.getInstance()
                    .signOut(ctx)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        public void onComplete(Task<Void> Task) {
                            mFirebaseAnalytics.logEvent("logout", null);
                            Toast.makeText(getApplicationContext(), "Signed out",
                                    Toast.LENGTH_SHORT).show();
                            startActivity(new Intent(ctx, LoginActivity.class));
                        }
                    });
        }
    });
}
 
Example #6
Source File: GenericIdpSignInHandlerTest.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    TestHelper.initialize();
    MockitoAnnotations.initMocks(this);

    FlowParameters testParams
            = TestHelper.getFlowParameters(
            Arrays.asList(MICROSOFT_PROVIDER, GoogleAuthProvider.PROVIDER_ID),
            /* enableAnonymousUpgrade= */ true);
    when(mMockActivity.getFlowParams()).thenReturn(testParams);

    mHandler = new GenericIdpSignInHandler(
            (Application) ApplicationProvider.getApplicationContext());

    Map<String, String> customParams = new HashMap<>();
    customParams.put(CUSTOM_PARAMETER_KEY, CUSTOM_PARAMETER_VALUE);

    AuthUI.IdpConfig config
            = new AuthUI.IdpConfig.MicrosoftBuilder()
            .setScopes(Arrays.asList(SCOPE))
            .setCustomParameters(customParams)
            .build();
    mHandler.initializeForTesting(config);
    mHandler.getOperation().observeForever(mResponseObserver);
}
 
Example #7
Source File: GenericIdpAnonymousUpgradeLinkingHandlerTest.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    TestHelper.initialize();
    MockitoAnnotations.initMocks(this);

    FlowParameters testParams
            = TestHelper.getFlowParameters(
            Arrays.asList(MICROSOFT_PROVIDER, GoogleAuthProvider.PROVIDER_ID),
            /* enableAnonymousUpgrade= */ true);
    when(mMockActivity.getFlowParams()).thenReturn(testParams);
    when(mMockWelcomeBackIdpPrompt.getFlowParams()).thenReturn(testParams);

    mHandler = new GenericIdpAnonymousUpgradeLinkingHandler(
            (Application) ApplicationProvider.getApplicationContext());

    Map<String, String> customParams = new HashMap<>();
    customParams.put(CUSTOM_PARAMETER_KEY, CUSTOM_PARAMETER_VALUE);

    AuthUI.IdpConfig config
            = new AuthUI.IdpConfig.MicrosoftBuilder()
            .setScopes(Arrays.asList(SCOPE))
            .setCustomParameters(customParams)
            .build();
    mHandler.initializeForTesting(config);
    mHandler.getOperation().observeForever(mResponseObserver);
}
 
Example #8
Source File: EmailActivityTest.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@Test
public void testOnCreate_emailLinkLinkingFlow_expectSendEmailLinkFlowStarted() {
    // This is normally done by EmailLinkSendEmailHandler, saving the IdpResponse is done
    // in EmailActivity but it will not be saved if we haven't previously set the email
    EmailLinkPersistenceManager.getInstance().saveEmail(ApplicationProvider.getApplicationContext(),
            EMAIL, TestConstants.SESSION_ID, TestConstants.UID);

    EmailActivity emailActivity = createActivity(AuthUI.EMAIL_LINK_PROVIDER, true);

    EmailLinkFragment fragment = (EmailLinkFragment) emailActivity
            .getSupportFragmentManager().findFragmentByTag(EmailLinkFragment.TAG);
    assertThat(fragment).isNotNull();

    EmailLinkPersistenceManager persistenceManager = EmailLinkPersistenceManager.getInstance();
    IdpResponse response = persistenceManager.retrieveSessionRecord(
            ApplicationProvider.getApplicationContext()).getIdpResponseForLinking();

    assertThat(response.getProviderType()).isEqualTo(GoogleAuthProvider.PROVIDER_ID);
    assertThat(response.getEmail()).isEqualTo(EMAIL);
    assertThat(response.getIdpToken()).isEqualTo(ID_TOKEN);
    assertThat(response.getIdpSecret()).isEqualTo(SECRET);
}
 
Example #9
Source File: FirebaseUIActivity.java    From snippets-android with Apache License 2.0 6 votes vote down vote up
public void createSignInIntent() {
    // [START auth_fui_create_intent]
    // Choose authentication providers
    List<AuthUI.IdpConfig> providers = Arrays.asList(
            new AuthUI.IdpConfig.EmailBuilder().build(),
            new AuthUI.IdpConfig.PhoneBuilder().build(),
            new AuthUI.IdpConfig.GoogleBuilder().build(),
            new AuthUI.IdpConfig.FacebookBuilder().build(),
            new AuthUI.IdpConfig.TwitterBuilder().build());

    // Create and launch sign-in intent
    startActivityForResult(
            AuthUI.getInstance()
                    .createSignInIntentBuilder()
                    .setAvailableProviders(providers)
                    .build(),
            RC_SIGN_IN);
    // [END auth_fui_create_intent]
}
 
Example #10
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
public static String providerIdToProviderName(@NonNull String providerId) {
    switch (providerId) {
        case GoogleAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_google);
        case FacebookAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_facebook);
        case TwitterAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_twitter);
        case GithubAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_github);
        case PhoneAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_phone);
        case EmailAuthProvider.PROVIDER_ID:
        case EMAIL_LINK_PROVIDER:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_email);
        default:
            return null;
    }
}
 
Example #11
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@AuthUI.SupportedProvider
public static String accountTypeToProviderId(@NonNull String accountType) {
    switch (accountType) {
        case IdentityProviders.GOOGLE:
            return GoogleAuthProvider.PROVIDER_ID;
        case IdentityProviders.FACEBOOK:
            return FacebookAuthProvider.PROVIDER_ID;
        case IdentityProviders.TWITTER:
            return TwitterAuthProvider.PROVIDER_ID;
        case GITHUB_IDENTITY:
            return GithubAuthProvider.PROVIDER_ID;
        case PHONE_IDENTITY:
            return PhoneAuthProvider.PROVIDER_ID;
        default:
            return null;
    }
}
 
Example #12
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Translate a Firebase Auth provider ID (such as {@link GoogleAuthProvider#PROVIDER_ID}) to a
 * Credentials API account type (such as {@link IdentityProviders#GOOGLE}).
 */
public static String providerIdToAccountType(
        @AuthUI.SupportedProvider @NonNull String providerId) {
    switch (providerId) {
        case GoogleAuthProvider.PROVIDER_ID:
            return IdentityProviders.GOOGLE;
        case FacebookAuthProvider.PROVIDER_ID:
            return IdentityProviders.FACEBOOK;
        case TwitterAuthProvider.PROVIDER_ID:
            return IdentityProviders.TWITTER;
        case GithubAuthProvider.PROVIDER_ID:
            return GITHUB_IDENTITY;
        case PhoneAuthProvider.PROVIDER_ID:
            return PHONE_IDENTITY;
        // The account type for email/password creds is null
        case EmailAuthProvider.PROVIDER_ID:
        default:
            return null;
    }
}
 
Example #13
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@NonNull
@AuthUI.SupportedProvider
public static String signInMethodToProviderId(@NonNull String method) {
    switch (method) {
        case GoogleAuthProvider.GOOGLE_SIGN_IN_METHOD:
            return GoogleAuthProvider.PROVIDER_ID;
        case FacebookAuthProvider.FACEBOOK_SIGN_IN_METHOD:
            return FacebookAuthProvider.PROVIDER_ID;
        case TwitterAuthProvider.TWITTER_SIGN_IN_METHOD:
            return TwitterAuthProvider.PROVIDER_ID;
        case GithubAuthProvider.GITHUB_SIGN_IN_METHOD:
            return GithubAuthProvider.PROVIDER_ID;
        case PhoneAuthProvider.PHONE_SIGN_IN_METHOD:
            return PhoneAuthProvider.PROVIDER_ID;
        case EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD:
            return EmailAuthProvider.PROVIDER_ID;
        case EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD:
            return EMAIL_LINK_PROVIDER;
        default:
            return method;
    }
}
 
Example #14
Source File: LoginActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    for (String provider : AuthUI.SUPPORTED_PROVIDERS) {
        Log.v(this.getClass().getName(), provider);
    }

    mAuth = FirebaseAuth.getInstance();
    mDatabase = FirebaseDatabase.getInstance().getReference();
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            updateInfo();
        }
    };

    startActivityForResult(
            AuthUI.getInstance()
                    .createSignInIntentBuilder()
                    .setIsSmartLockEnabled(false)
                    .setAvailableProviders(providers)
                    .setLogo(R.drawable.stayfit)
                    .build(),
            RC_SIGN_IN);
}
 
Example #15
Source File: AuthMethodPickerActivityTest.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@Test
public void testAllProvidersArePopulated() {
    // Exclude Facebook until the `NoClassDefFoundError: com/facebook/common/R$style` exception
    // is fixed.
    List<String> providers = Arrays.asList(
            GoogleAuthProvider.PROVIDER_ID,
            TwitterAuthProvider.PROVIDER_ID,
            EmailAuthProvider.PROVIDER_ID,
            PhoneAuthProvider.PROVIDER_ID,
            AuthUI.ANONYMOUS_PROVIDER);

    AuthMethodPickerActivity authMethodPickerActivity = createActivity(providers);

    assertEquals(providers.size(),
            ((LinearLayout) authMethodPickerActivity.findViewById(R.id.btn_holder))
                    .getChildCount());
}
 
Example #16
Source File: BaseActivity.java    From stockita-point-of-sale with MIT License 6 votes vote down vote up
/**
 * This method to sign out, from both the email sign or google sign
 */
protected void signOut() {

    AuthUI.getInstance()
            .signOut(this)
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    // user is now sign out

                    // Get back to the sign in page
                    startActivity(new Intent(getBaseContext(), SignInUI.class));
                    finish();
                }
            });
}
 
Example #17
Source File: ResourceObserver.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@Override
public final void onChanged(Resource<T> resource) {
    if (resource.getState() == State.LOADING) {
        mProgressView.showProgress(mLoadingMessage);
        return;
    }
    mProgressView.hideProgress();

    if (resource.isUsed()) { return; }

    if (resource.getState() == State.SUCCESS) {
        onSuccess(resource.getValue());
    } else if (resource.getState() == State.FAILURE) {
        Exception e = resource.getException();
        boolean unhandled;
        if (mFragment == null) {
            unhandled = FlowUtils.unhandled(mActivity, e);
        } else {
            unhandled = FlowUtils.unhandled(mFragment, e);
        }
        if (unhandled) {
            Log.e(AuthUI.TAG, "A sign-in error occurred.", e);
            onFailure(e);
        }
    }
}
 
Example #18
Source File: ChooserActivity.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (AuthUI.canHandleIntent(getIntent())) {
        Intent intent = new Intent(ChooserActivity.this, AuthUiActivity
                .class);
        intent.putExtra(ExtraConstants.EMAIL_LINK_SIGN_IN, getIntent().getData().toString());
        startActivity(intent);
        finish();
        return;
    }

    setContentView(R.layout.activity_chooser);
    ButterKnife.bind(this);

    mActivities.setLayoutManager(new LinearLayoutManager(this));
    mActivities.setAdapter(new ActivityChooserAdapter());
    mActivities.setHasFixedSize(true);
}
 
Example #19
Source File: SocialProviderResponseHandlerTest.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    TestHelper.initialize();
    MockitoAnnotations.initMocks(this);

    mHandler = new SocialProviderResponseHandler((Application) ApplicationProvider.getApplicationContext());
    FlowParameters testParams = TestHelper.getFlowParameters(AuthUI.SUPPORTED_PROVIDERS);

    mHandler.initializeForTesting(testParams, mMockAuth, null, null);
}
 
Example #20
Source File: SignInKickstarter.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void startAuthMethodChoice() {
    // If there is only one provider selected, launch the flow directly
    if (!getArguments().shouldShowProviderChoice()) {
        AuthUI.IdpConfig firstIdpConfig = getArguments().providers.get(0);
        String firstProvider = firstIdpConfig.getProviderId();
        switch (firstProvider) {
            case EMAIL_LINK_PROVIDER:
            case EmailAuthProvider.PROVIDER_ID:
                setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                        EmailActivity.createIntent(getApplication(), getArguments()),
                        RequestCodes.EMAIL_FLOW)));
                break;
            case PhoneAuthProvider.PROVIDER_ID:
                setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                        PhoneActivity.createIntent(
                                getApplication(), getArguments(), firstIdpConfig.getParams()),
                        RequestCodes.PHONE_FLOW)));
                break;
            default:
                redirectSignIn(firstProvider, null);
                break;
        }
    } else {
        setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                AuthMethodPickerActivity.createIntent(getApplication(), getArguments()),
                RequestCodes.AUTH_PICKER_FLOW)));
    }
}
 
Example #21
Source File: AuthMethodPickerActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void populateIdpList(List<IdpConfig> providerConfigs) {

        ViewModelProvider supplier = ViewModelProviders.of(this);
        mProviders = new ArrayList<>();
        for (IdpConfig idpConfig : providerConfigs) {
            @LayoutRes int buttonLayout;

            final String providerId = idpConfig.getProviderId();
            switch (providerId) {
                case GoogleAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_idp_button_google;
                    break;
                case FacebookAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_idp_button_facebook;
                    break;
                case EMAIL_LINK_PROVIDER:
                case EmailAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_provider_button_email;
                    break;
                case PhoneAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_provider_button_phone;
                    break;
                case AuthUI.ANONYMOUS_PROVIDER:
                    buttonLayout = R.layout.fui_provider_button_anonymous;
                    break;
                default:
                    if (!TextUtils.isEmpty(
                            idpConfig.getParams().getString(GENERIC_OAUTH_PROVIDER_ID))) {
                        buttonLayout = idpConfig.getParams().getInt(GENERIC_OAUTH_BUTTON_ID);
                        break;
                    }
                    throw new IllegalStateException("Unknown provider: " + providerId);
            }

            View loginButton = getLayoutInflater().inflate(buttonLayout, mProviderHolder, false);
            handleSignInOperation(idpConfig, loginButton);
            mProviderHolder.addView(loginButton);
        }
    }
 
Example #22
Source File: LinkingSocialProviderResponseHandler.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private boolean isGenericIdpLinkingFlow(@NonNull String providerId) {
    // TODO(lsirac): Remove use of SUPPORTED_OAUTH_PROVIDERS when we decide to support all IDPs
    return AuthUI.SUPPORTED_OAUTH_PROVIDERS.contains(providerId)
            && mRequestedSignInCredential != null
            && getAuth().getCurrentUser() != null
            && !getAuth().getCurrentUser().isAnonymous();
}
 
Example #23
Source File: EmailLinkSignInHandlerTest.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("all")
public void testStartSignIn_normalFlowWithAnonymousUpgrade_expectSuccessfulMerge() {
    mHandler.getOperation().observeForever(mResponseObserver);
    setupAnonymousUpgrade();
    when(mMockAuth.isSignInWithEmailLink(any(String.class))).thenReturn(true);

    mPersistenceManager.saveEmail(ApplicationProvider.getApplicationContext(), TestConstants.EMAIL,
            TestConstants.SESSION_ID, TestConstants.UID);

    when(mMockAuth.getCurrentUser().linkWithCredential(any(AuthCredential.class)))
            .thenReturn(new AutoContinueTask<>(mMockAuthResult,
                    mMockAuthResult,
                    true,
                    null));

    mHandler.startSignIn();

    ArgumentCaptor<Resource<IdpResponse>> captor =
            ArgumentCaptor.forClass(Resource.class);

    InOrder inOrder = inOrder(mResponseObserver);

    inOrder.verify(mResponseObserver)
            .onChanged(argThat(ResourceMatchers.<IdpResponse>isLoading()));
    inOrder.verify(mResponseObserver).onChanged(captor.capture());

    IdpResponse response = captor.getValue().getValue();

    assertThat(response.getUser().getProviderId()).isEqualTo(AuthUI.EMAIL_LINK_PROVIDER);
    assertThat(response.getUser().getEmail()).isEqualTo(mMockAuthResult.getUser()
            .getEmail());
    assertThat(response.getUser().getName()).isEqualTo(mMockAuthResult.getUser()
            .getDisplayName());
    assertThat(response.getUser().getPhotoUri()).isEqualTo(mMockAuthResult.getUser()
            .getPhotoUrl());

    assertThat(mPersistenceManager.retrieveSessionRecord(ApplicationProvider.getApplicationContext()))
            .isNull();
}
 
Example #24
Source File: EmailLinkPersistanceManagerTest.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private IdpResponse buildIdpResponse() {
    User user = new User.Builder(AuthUI.EMAIL_LINK_PROVIDER, TestConstants.EMAIL)
            .build();

    return new IdpResponse.Builder(user)
            .setToken(TestConstants.TOKEN)
            .setSecret(TestConstants.SECRET)
            .build();
}
 
Example #25
Source File: ConfigurationUtils.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@NonNull
public static List<AuthUI.IdpConfig> getConfiguredProviders(@NonNull Context context) {
    List<AuthUI.IdpConfig> providers = new ArrayList<>();

    if (!isGoogleMisconfigured(context)) {
        providers.add(new AuthUI.IdpConfig.GoogleBuilder().build());
    }

    if (!isFacebookMisconfigured(context)) {
        providers.add(new AuthUI.IdpConfig.FacebookBuilder().build());
    }

    ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder()
            .setAndroidPackageName("com.firebase.uidemo", true, null)
            .setHandleCodeInApp(true)
            .setUrl("https://google.com")
            .build();

    providers.add(new AuthUI.IdpConfig.EmailBuilder()
            .setAllowNewAccounts(true)
            .enableEmailLinkSignIn()
            .setActionCodeSettings(actionCodeSettings)
            .build());

    providers.add(new AuthUI.IdpConfig.TwitterBuilder().build());
    providers.add(new AuthUI.IdpConfig.PhoneBuilder().build());
    providers.add(new AuthUI.IdpConfig.MicrosoftBuilder().build());
    providers.add(new AuthUI.IdpConfig.YahooBuilder().build());
    providers.add(new AuthUI.IdpConfig.AppleBuilder().build());

    return providers;
}
 
Example #26
Source File: AuthUiActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@DrawableRes
private int getSelectedLogo() {
    if (mFirebaseLogo.isChecked()) {
        return R.drawable.firebase_auth_120dp;
    } else if (mGoogleLogo.isChecked()) {
        return R.drawable.ic_googleg_color_144dp;
    }
    return AuthUI.NO_LOGO;
}
 
Example #27
Source File: AuthUiActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@StyleRes
private int getSelectedTheme() {
    if (mGreenTheme.isChecked()) {
        return R.style.GreenTheme;
    }

    if (mPurpleTheme.isChecked()) {
        return R.style.PurpleTheme;
    }

    return AuthUI.getDefaultTheme();
}
 
Example #28
Source File: MainActivity.java    From Shipr-Community-Android with GNU General Public License v3.0 5 votes vote down vote up
private void authStateCheck() {
    mAuthStateListener = firebaseAuth -> {
        FirebaseUser user = firebaseAuth.getCurrentUser();
        if (user != null) {
            //User is signed in
            //onSignedInInitialize(user.getDisplayName());
        } else {
            // User is signed out
            //  onSignedOutCleanup();
            startActivityForResult(
                    AuthUI.getInstance()
                            .createSignInIntentBuilder()
                            .setLogo(R.mipmap.ic_launcher)
                            .setTheme(R.style.AppTheme)
                            .setAvailableProviders(
                                    Arrays.asList(
                                            new AuthUI.IdpConfig.EmailBuilder().build(),
                                            new AuthUI.IdpConfig.GoogleBuilder().build()
                                            //new AuthUI.IdpConfig.GitHubBuilder().build()
                                    ))
                            .build(),
                    RC_SIGN_IN);


        }

    };
}
 
Example #29
Source File: Preconditions.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public static void checkConfigured(@NonNull Context context,
                                   @Nullable String message,
                                   @StringRes int... ids) {
    for (int id : ids) {
        if (context.getString(id).equals(AuthUI.UNCONFIGURED_CONFIG_VALUE)) {
            throw new IllegalStateException(message);
        }
    }
}
 
Example #30
Source File: AuthUiActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.sign_in_silent)
public void silentSignIn() {
    AuthUI.getInstance().silentSignIn(this, getSelectedProviders())
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        startSignedInActivity(null);
                    } else {
                        showSnackbar(R.string.sign_in_failed);
                    }
                }
            });
}