Search in sources :

Example 1 with AuthMethodPickerLayout

use of com.firebase.ui.auth.AuthMethodPickerLayout in project FirebaseUI-Android by firebase.

the class AuthUiActivity method getSignInIntent.

private Intent getSignInIntent(@Nullable String link) {
    AuthUI.SignInIntentBuilder builder = getAuthUI().createSignInIntentBuilder().setTheme(getSelectedTheme()).setLogo(getSelectedLogo()).setAvailableProviders(getSelectedProviders()).setIsSmartLockEnabled(mBinding.credentialSelectorEnabled.isChecked(), mBinding.hintSelectorEnabled.isChecked());
    if (mBinding.customLayout.isChecked()) {
        AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout.Builder(R.layout.auth_method_picker_custom_layout).setGoogleButtonId(R.id.custom_google_signin_button).setEmailButtonId(R.id.custom_email_signin_clickable_text).setTosAndPrivacyPolicyId(R.id.custom_tos_pp).build();
        builder.setTheme(R.style.CustomTheme);
        builder.setAuthMethodPickerLayout(customLayout);
    }
    if (getSelectedTosUrl() != null && getSelectedPrivacyPolicyUrl() != null) {
        builder.setTosAndPrivacyPolicyUrls(getSelectedTosUrl(), getSelectedPrivacyPolicyUrl());
    }
    if (link != null) {
        builder.setEmailLink(link);
    }
    FirebaseAuth auth = FirebaseAuth.getInstance();
    if (auth.getCurrentUser() != null && auth.getCurrentUser().isAnonymous()) {
        builder.enableAnonymousUsersAutoUpgrade();
    }
    return builder.build();
}
Also used : AuthMethodPickerLayout(com.firebase.ui.auth.AuthMethodPickerLayout) AuthUI(com.firebase.ui.auth.AuthUI) FirebaseAuth(com.google.firebase.auth.FirebaseAuth)

Example 2 with AuthMethodPickerLayout

use of com.firebase.ui.auth.AuthMethodPickerLayout in project FirebaseUI-Android by firebase.

the class AuthMethodPickerActivityTest method testCustomAuthMethodPickerLayout.

@Test
public void testCustomAuthMethodPickerLayout() {
    List<String> providers = Arrays.asList(EmailAuthProvider.PROVIDER_ID);
    AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout.Builder(R.layout.fui_provider_button_email).setEmailButtonId(R.id.email_button).build();
    AuthMethodPickerActivity authMethodPickerActivity = createActivityWithCustomLayout(providers, customLayout, false);
    Button emailButton = authMethodPickerActivity.findViewById(R.id.email_button);
    emailButton.performClick();
    // Expected result -> Directing users to EmailActivity
    ShadowActivity.IntentForResult nextIntent = Shadows.shadowOf(authMethodPickerActivity).getNextStartedActivityForResult();
    assertEquals(EmailActivity.class.getName(), nextIntent.intent.getComponent().getClassName());
}
Also used : AuthMethodPickerLayout(com.firebase.ui.auth.AuthMethodPickerLayout) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) EmailActivity(com.firebase.ui.auth.ui.email.EmailActivity) Test(org.junit.Test)

Example 3 with AuthMethodPickerLayout

use of com.firebase.ui.auth.AuthMethodPickerLayout in project FirebaseUI-Android by firebase.

the class AuthMethodPickerActivityTest method testCustomAuthMethodPickerLayoutWithDefaultEmail.

@Test
public void testCustomAuthMethodPickerLayoutWithDefaultEmail() {
    List<String> providers = Arrays.asList(EmailAuthProvider.PROVIDER_ID);
    AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout.Builder(R.layout.fui_provider_button_email).setEmailButtonId(R.id.email_button).build();
    AuthMethodPickerActivity authMethodPickerActivity = createActivityWithCustomLayout(providers, customLayout, true);
    Button emailButton = authMethodPickerActivity.findViewById(R.id.email_button);
    emailButton.performClick();
    // Expected result -> Directing users to EmailActivity
    ShadowActivity.IntentForResult nextIntent = Shadows.shadowOf(authMethodPickerActivity).getNextStartedActivityForResult();
    assertEquals(EmailActivity.class.getName(), nextIntent.intent.getComponent().getClassName());
}
Also used : AuthMethodPickerLayout(com.firebase.ui.auth.AuthMethodPickerLayout) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) EmailActivity(com.firebase.ui.auth.ui.email.EmailActivity) Test(org.junit.Test)

Example 4 with AuthMethodPickerLayout

use of com.firebase.ui.auth.AuthMethodPickerLayout in project FirebaseUI-Android by firebase.

the class AuthMethodPickerActivityTest method testCustomAuthMethodPickerLayoutWithEmailLink.

@Test
public void testCustomAuthMethodPickerLayoutWithEmailLink() {
    List<String> providers = Arrays.asList(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD);
    AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout.Builder(R.layout.fui_provider_button_email).setEmailButtonId(R.id.email_button).build();
    AuthMethodPickerActivity authMethodPickerActivity = createActivityWithCustomLayout(providers, customLayout, false);
    Button emailButton = authMethodPickerActivity.findViewById(R.id.email_button);
    emailButton.performClick();
    // Expected result -> Directing users to EmailActivity
    ShadowActivity.IntentForResult nextIntent = Shadows.shadowOf(authMethodPickerActivity).getNextStartedActivityForResult();
    assertEquals(EmailActivity.class.getName(), nextIntent.intent.getComponent().getClassName());
}
Also used : AuthMethodPickerLayout(com.firebase.ui.auth.AuthMethodPickerLayout) Button(android.widget.Button) ShadowActivity(org.robolectric.shadows.ShadowActivity) EmailActivity(com.firebase.ui.auth.ui.email.EmailActivity) Test(org.junit.Test)

Aggregations

AuthMethodPickerLayout (com.firebase.ui.auth.AuthMethodPickerLayout)4 Button (android.widget.Button)3 EmailActivity (com.firebase.ui.auth.ui.email.EmailActivity)3 Test (org.junit.Test)3 ShadowActivity (org.robolectric.shadows.ShadowActivity)3 AuthUI (com.firebase.ui.auth.AuthUI)1 FirebaseAuth (com.google.firebase.auth.FirebaseAuth)1