Search in sources :

Example 1 with EmailFieldValidator

use of com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator in project FirebaseUI-Android by firebase.

the class RecoverPasswordActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fui_forgot_password_layout);
    mHandler = new ViewModelProvider(this).get(RecoverPasswordHandler.class);
    mHandler.init(getFlowParams());
    mHandler.getOperation().observe(this, new ResourceObserver<String>(this, R.string.fui_progress_dialog_sending) {

        @Override
        protected void onSuccess(@NonNull String email) {
            mEmailInputLayout.setError(null);
            showEmailSentDialog(email);
        }

        @Override
        protected void onFailure(@NonNull Exception e) {
            if (e instanceof FirebaseAuthInvalidUserException || e instanceof FirebaseAuthInvalidCredentialsException) {
                // No FirebaseUser exists with this email address, show error.
                mEmailInputLayout.setError(getString(R.string.fui_error_email_does_not_exist));
            } else {
                // Unknown error
                mEmailInputLayout.setError(getString(R.string.fui_error_unknown));
            }
        }
    });
    mProgressBar = findViewById(R.id.top_progress_bar);
    mSubmitButton = findViewById(R.id.button_done);
    mEmailInputLayout = findViewById(R.id.email_layout);
    mEmailEditText = findViewById(R.id.email);
    mEmailFieldValidator = new EmailFieldValidator(mEmailInputLayout);
    String email = getIntent().getStringExtra(ExtraConstants.EMAIL);
    if (email != null) {
        mEmailEditText.setText(email);
    }
    ImeHelper.setImeOnDoneListener(mEmailEditText, this);
    mSubmitButton.setOnClickListener(this);
    TextView footerText = findViewById(R.id.email_footer_tos_and_pp_text);
    PrivacyDisclosureUtils.setupTermsOfServiceFooter(this, getFlowParams(), footerText);
}
Also used : RecoverPasswordHandler(com.firebase.ui.auth.viewmodel.email.RecoverPasswordHandler) FirebaseAuthInvalidUserException(com.google.firebase.auth.FirebaseAuthInvalidUserException) FirebaseAuthInvalidCredentialsException(com.google.firebase.auth.FirebaseAuthInvalidCredentialsException) EmailFieldValidator(com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator) TextView(android.widget.TextView) FirebaseAuthInvalidCredentialsException(com.google.firebase.auth.FirebaseAuthInvalidCredentialsException) FirebaseAuthInvalidUserException(com.google.firebase.auth.FirebaseAuthInvalidUserException) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 2 with EmailFieldValidator

use of com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator in project FirebaseUI-Android by firebase.

the class EmailLinkPromptEmailFragment 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);
    mNextButton.setOnClickListener(this);
    // 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);
    // Set activity title
    getActivity().setTitle(R.string.fui_email_link_confirm_email_header);
    // Set Tos/Pp footer
    TextView footerText = view.findViewById(R.id.email_footer_tos_and_pp_text);
    PrivacyDisclosureUtils.setupTermsOfServiceFooter(requireContext(), getFlowParams(), footerText);
}
Also used : EmailFieldValidator(com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator) TextView(android.widget.TextView)

Example 3 with EmailFieldValidator

use of com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator 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 4 with EmailFieldValidator

use of com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator in project FirebaseUI-Android by firebase.

the class RegisterEmailFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    mNextButton = view.findViewById(R.id.button_create);
    mProgressBar = view.findViewById(R.id.top_progress_bar);
    mEmailEditText = view.findViewById(R.id.email);
    mNameEditText = view.findViewById(R.id.name);
    mPasswordEditText = view.findViewById(R.id.password);
    mEmailInput = view.findViewById(R.id.email_layout);
    mPasswordInput = view.findViewById(R.id.password_layout);
    TextInputLayout nameInput = view.findViewById(R.id.name_layout);
    // Get configuration
    AuthUI.IdpConfig emailConfig = ProviderUtils.getConfigFromIdpsOrThrow(getFlowParams().providers, EmailAuthProvider.PROVIDER_ID);
    boolean requireName = emailConfig.getParams().getBoolean(ExtraConstants.REQUIRE_NAME, true);
    mPasswordFieldValidator = new PasswordFieldValidator(mPasswordInput, getResources().getInteger(R.integer.fui_min_password_length));
    mNameValidator = requireName ? new RequiredFieldValidator(nameInput, getResources().getString(R.string.fui_missing_first_and_last_name)) : new NoOpValidator(nameInput);
    mEmailFieldValidator = new EmailFieldValidator(mEmailInput);
    ImeHelper.setImeOnDoneListener(mPasswordEditText, this);
    mEmailEditText.setOnFocusChangeListener(this);
    mNameEditText.setOnFocusChangeListener(this);
    mPasswordEditText.setOnFocusChangeListener(this);
    mNextButton.setOnClickListener(this);
    // Only show the name field if required
    nameInput.setVisibility(requireName ? View.VISIBLE : View.GONE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && getFlowParams().enableCredentials) {
        mEmailEditText.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
    }
    TextView footerText = view.findViewById(R.id.email_footer_tos_and_pp_text);
    PrivacyDisclosureUtils.setupTermsOfServiceFooter(requireContext(), getFlowParams(), footerText);
    // WARNING: Nothing below this line will be executed on rotation
    if (savedInstanceState != null) {
        return;
    }
    // If email is passed in, fill in the field and move down to the name field.
    String email = mUser.getEmail();
    if (!TextUtils.isEmpty(email)) {
        mEmailEditText.setText(email);
    }
    // If name is passed in, fill in the field and move down to the password field.
    String name = mUser.getName();
    if (!TextUtils.isEmpty(name)) {
        mNameEditText.setText(name);
    }
    // See http://stackoverflow.com/questions/11082341/android-requestfocus-ineffective#comment51774752_11082523
    if (!requireName || !TextUtils.isEmpty(mNameEditText.getText())) {
        safeRequestFocus(mPasswordEditText);
    } else if (!TextUtils.isEmpty(mEmailEditText.getText())) {
        safeRequestFocus(mNameEditText);
    } else {
        safeRequestFocus(mEmailEditText);
    }
}
Also used : NoOpValidator(com.firebase.ui.auth.util.ui.fieldvalidators.NoOpValidator) EmailFieldValidator(com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator) TextView(android.widget.TextView) TextInputLayout(com.google.android.material.textfield.TextInputLayout) PasswordFieldValidator(com.firebase.ui.auth.util.ui.fieldvalidators.PasswordFieldValidator) RequiredFieldValidator(com.firebase.ui.auth.util.ui.fieldvalidators.RequiredFieldValidator) AuthUI(com.firebase.ui.auth.AuthUI)

Aggregations

TextView (android.widget.TextView)4 EmailFieldValidator (com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator)4 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 AuthUI (com.firebase.ui.auth.AuthUI)1 FlowParameters (com.firebase.ui.auth.data.model.FlowParameters)1 NoOpValidator (com.firebase.ui.auth.util.ui.fieldvalidators.NoOpValidator)1 PasswordFieldValidator (com.firebase.ui.auth.util.ui.fieldvalidators.PasswordFieldValidator)1 RequiredFieldValidator (com.firebase.ui.auth.util.ui.fieldvalidators.RequiredFieldValidator)1 RecoverPasswordHandler (com.firebase.ui.auth.viewmodel.email.RecoverPasswordHandler)1 TextInputLayout (com.google.android.material.textfield.TextInputLayout)1 FirebaseAuthInvalidCredentialsException (com.google.firebase.auth.FirebaseAuthInvalidCredentialsException)1 FirebaseAuthInvalidUserException (com.google.firebase.auth.FirebaseAuthInvalidUserException)1