Search in sources :

Example 1 with NoOpValidator

use of com.firebase.ui.auth.util.ui.fieldvalidators.NoOpValidator 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)1 AuthUI (com.firebase.ui.auth.AuthUI)1 EmailFieldValidator (com.firebase.ui.auth.util.ui.fieldvalidators.EmailFieldValidator)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 TextInputLayout (com.google.android.material.textfield.TextInputLayout)1