Search in sources :

Example 21 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class CheckEmailFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    mNextButton = view.findViewById(R.id.button_next);
    mProgressBar = view.findViewById(R.id.top_progress_bar);
    // Email field and validator
    mEmailLayout = view.findViewById(R.id.email_layout);
    mEmailEditText = view.findViewById(R.id.email);
    mEmailFieldValidator = new EmailFieldValidator(mEmailLayout);
    mEmailLayout.setOnClickListener(this);
    mEmailEditText.setOnClickListener(this);
    // Hide header
    TextView headerText = view.findViewById(R.id.header_text);
    if (headerText != null) {
        headerText.setVisibility(View.GONE);
    }
    ImeHelper.setImeOnDoneListener(mEmailEditText, this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && getFlowParams().enableHints) {
        mEmailEditText.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
    }
    mNextButton.setOnClickListener(this);
    TextView termsText = view.findViewById(R.id.email_tos_and_pp_text);
    TextView footerText = view.findViewById(R.id.email_footer_tos_and_pp_text);
    FlowParameters flowParameters = getFlowParams();
    if (!flowParameters.shouldShowProviderChoice()) {
        PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicyText(requireContext(), flowParameters, termsText);
    } else {
        termsText.setVisibility(View.GONE);
        PrivacyDisclosureUtils.setupTermsOfServiceFooter(requireContext(), flowParameters, footerText);
    }
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) EmailFieldValidator(com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator) TextView(android.widget.TextView)

Example 22 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class AuthMethodPickerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FlowParameters params = getFlowParams();
    customLayout = params.authMethodPickerLayout;
    mHandler = new ViewModelProvider(this).get(SocialProviderResponseHandler.class);
    mHandler.init(params);
    mProviders = new ArrayList<>();
    if (customLayout != null) {
        setContentView(customLayout.getMainLayout());
        // Setup using custom layout
        populateIdpListCustomLayout(params.providers);
    } else {
        setContentView(R.layout.fui_auth_method_picker_layout);
        // UI only with default layout
        mProgressBar = findViewById(R.id.top_progress_bar);
        mProviderHolder = findViewById(R.id.btn_holder);
        populateIdpList(params.providers);
        int logoId = params.logoId;
        if (logoId == AuthUI.NO_LOGO) {
            findViewById(R.id.logo).setVisibility(View.GONE);
            ConstraintLayout layout = findViewById(R.id.root);
            ConstraintSet constraints = new ConstraintSet();
            constraints.clone(layout);
            constraints.setHorizontalBias(R.id.container, 0.5f);
            constraints.setVerticalBias(R.id.container, 0.5f);
            constraints.applyTo(layout);
        } else {
            ImageView logo = findViewById(R.id.logo);
            logo.setImageResource(logoId);
        }
    }
    boolean tosAndPpConfigured = getFlowParams().isPrivacyPolicyUrlProvided() && getFlowParams().isTermsOfServiceUrlProvided();
    int termsTextId = customLayout == null ? R.id.main_tos_and_pp : customLayout.getTosPpView();
    if (termsTextId >= 0) {
        TextView termsText = findViewById(termsTextId);
        // No ToS or PP provided, so we should hide the view entirely
        if (!tosAndPpConfigured) {
            termsText.setVisibility(View.GONE);
        } else {
            PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicyText(this, getFlowParams(), termsText);
        }
    }
    // Handler for both
    mHandler.getOperation().observe(this, new ResourceObserver<IdpResponse>(this, R.string.fui_progress_dialog_signing_in) {

        @Override
        protected void onSuccess(@NonNull IdpResponse response) {
            startSaveCredentials(mHandler.getCurrentUser(), response, null);
        }

        @Override
        protected void onFailure(@NonNull Exception e) {
            if (e instanceof UserCancellationException) {
                // User pressed back, there is no error.
                return;
            }
            if (e instanceof FirebaseAuthAnonymousUpgradeException) {
                finish(ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT, ((FirebaseAuthAnonymousUpgradeException) e).getResponse().toIntent());
            } else if (e instanceof FirebaseUiException) {
                FirebaseUiException fue = (FirebaseUiException) e;
                finish(RESULT_CANCELED, IdpResponse.from(fue).toIntent());
            } else {
                String text = getString(R.string.fui_error_unknown);
                Toast.makeText(AuthMethodPickerActivity.this, text, Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) UserCancellationException(com.firebase.ui.auth.data.model.UserCancellationException) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) SocialProviderResponseHandler(com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler) UserCancellationException(com.firebase.ui.auth.data.model.UserCancellationException) TextView(android.widget.TextView) ImageView(android.widget.ImageView) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) ViewModelProvider(androidx.lifecycle.ViewModelProvider) IdpResponse(com.firebase.ui.auth.IdpResponse)

Example 23 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class GenericIdpAnonymousUpgradeLinkingHandler method startSignIn.

@Override
public void startSignIn(@NonNull FirebaseAuth auth, @NonNull HelperActivityBase activity, @NonNull String providerId) {
    setResult(Resource.forLoading());
    FlowParameters flowParameters = activity.getFlowParams();
    OAuthProvider provider = buildOAuthProvider(providerId, auth);
    if (flowParameters != null && AuthOperationManager.getInstance().canUpgradeAnonymous(auth, flowParameters)) {
        handleAnonymousUpgradeLinkingFlow(activity, provider, flowParameters);
        return;
    }
    handleNormalSignInFlow(auth, activity, provider);
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) OAuthProvider(com.google.firebase.auth.OAuthProvider)

Example 24 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class LinkingSocialProviderResponseHandlerTest method setUp.

@Before
public void setUp() {
    TestHelper.initialize();
    MockitoAnnotations.initMocks(this);
    mHandler = new LinkingSocialProviderResponseHandler((Application) ApplicationProvider.getApplicationContext());
    FlowParameters testParams = TestHelper.getFlowParameters(Collections.singletonList(GoogleAuthProvider.PROVIDER_ID));
    mHandler.initializeForTesting(testParams, mMockAuth, null);
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) LinkingSocialProviderResponseHandler(com.firebase.ui.auth.viewmodel.idp.LinkingSocialProviderResponseHandler) Application(android.app.Application) Before(org.junit.Before)

Example 25 with FlowParameters

use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.

the class SocialProviderResponseHandlerTest method setupAnonymousUpgrade.

private void setupAnonymousUpgrade() {
    // enableAnonymousUpgrade must be set to true
    FlowParameters testParams = TestHelper.getFlowParameters(AuthUI.SUPPORTED_PROVIDERS, /* enableAnonymousUpgrade */
    true);
    mHandler.initializeForTesting(testParams, mMockAuth, null);
    when(mUser.isAnonymous()).thenReturn(true);
    when(mMockAuth.getCurrentUser()).thenReturn(mUser);
}
Also used : FlowParameters(com.firebase.ui.auth.data.model.FlowParameters)

Aggregations

FlowParameters (com.firebase.ui.auth.data.model.FlowParameters)27 Before (org.junit.Before)10 Application (android.app.Application)9 Test (org.junit.Test)4 AuthUI (com.firebase.ui.auth.AuthUI)3 OAuthProvider (com.google.firebase.auth.OAuthProvider)3 HashMap (java.util.HashMap)3 TextView (android.widget.TextView)2 FirebaseAuthAnonymousUpgradeException (com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException)2 FirebaseUiException (com.firebase.ui.auth.FirebaseUiException)2 IdpResponse (com.firebase.ui.auth.IdpResponse)2 UserCancellationException (com.firebase.ui.auth.data.model.UserCancellationException)2 SocialProviderResponseHandler (com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler)2 Intent (android.content.Intent)1 ImageView (android.widget.ImageView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 RestrictTo (androidx.annotation.RestrictTo)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ConstraintLayout (androidx.constraintlayout.widget.ConstraintLayout)1