Java Code Examples for android.support.design.widget.TextInputLayout#setErrorEnabled()

The following examples show how to use android.support.design.widget.TextInputLayout#setErrorEnabled() . 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: Utils.java    From openshop.io-android with MIT License 6 votes vote down vote up
/**
 * Method checks if text input layout exist and contains some value.
 * If layout is empty, then show error value under the textInputLayout.
 *
 * @param textInputLayout textInputFiled for check.
 * @param errorValue      value displayed when ext input is empty.
 * @return true if everything ok.
 */
public static boolean checkTextInputLayoutValueRequirement(TextInputLayout textInputLayout, String errorValue) {
    if (textInputLayout != null && textInputLayout.getEditText() != null) {
        String text = Utils.getTextFromInputLayout(textInputLayout);
        if (text == null || text.isEmpty()) {
            textInputLayout.setErrorEnabled(true);
            textInputLayout.setError(errorValue);
            Timber.d("Input field %s missing text.", textInputLayout.getHint());
            return false;
        } else {
            textInputLayout.setErrorEnabled(false);
            Timber.d("Input field: %s OK.", textInputLayout.getHint());
            return true;
        }
    } else {
        Timber.e(new RuntimeException(), "Checking null input field during order send.");
        return false;
    }
}
 
Example 2
Source File: FeedbackDialog.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    TextInputLayout et = weakEt.get();
    if (StringUtils.validate(s.toString())) {
        if (et != null) et.setErrorEnabled(false);
        return;
    }
    if (et != null) {
        et.setErrorEnabled(true);
        et.setError(PalmApp.getContext().getString(R.string.illegal_email_format));
    }
}
 
Example 3
Source File: TextInputHelper.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
public static void textInputErrorTwinkle(TextInputLayout il, String str) {
    String error = (String) il.getError();
    if (TextUtils.isEmpty(error)) {
        error = TextUtils.isEmpty(str) ? "!" : str;
    }

    il.setErrorEnabled(false);
    il.setError(error);
    il.setErrorEnabled(true);
}
 
Example 4
Source File: Cuhn.java    From africastalking-android with MIT License 5 votes vote down vote up
private void disableAllFields() {
    TextInputLayout allFields[] = {pinInputLayout, cvvInputLayout, cardNumber, expiryInputLayout};
    for (TextInputLayout field : allFields) {
        field.setEnabled(false);
        field.setErrorEnabled(false);
    }
    Arrays.fill(allFields, null);
}
 
Example 5
Source File: Luhn.java    From Luhn with MIT License 5 votes vote down vote up
private void disableAllFields() {
    TextInputLayout allFields[] = {pinInputLayout, cvvInputLayout, cardNumber, expiryInputLayout};
    for (TextInputLayout field : allFields) {
        field.setEnabled(false);
        field.setErrorEnabled(false);
    }
    Arrays.fill(allFields, null);

}
 
Example 6
Source File: EnrollActivity.java    From Android-Bluetooth-Fingerprint with Apache License 2.0 5 votes vote down vote up
private boolean validateInput(EditText EdTxt, TextInputLayout inputLayout) {
    if (EdTxt.getText().toString().trim().isEmpty()) {
        inputLayout.setError(getString(R.string.err_msg_input));
        requestFocus(EdTxt);
        return false;
    } else {
        inputLayout.setErrorEnabled(false);
    }

    return true;
}
 
Example 7
Source File: EnterKeyActivity.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
/** Called when the activity is first created */
@Override
public void onCreate(Bundle savedInstanceState) {
  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
  if (preferences.getBoolean(AuthenticatorActivity.KEY_DARK_MODE_ENABLED, false)) {
    setTheme(R.style.AuthenticatorTheme_NoActionBar_Dark);
  } else {
    setTheme(R.style.AuthenticatorTheme_NoActionBar);
  }

  super.onCreate(savedInstanceState);
  setContentView(R.layout.enter_key);

  setSupportActionBar((Toolbar) findViewById(R.id.enter_key_toolbar));
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setDisplayShowHomeEnabled(true);

  // Find all the views on the page
  keyEntryField = (EditText) findViewById(R.id.key_value);
  accountName = (EditText) findViewById(R.id.account_name);
  keyEntryFieldInputLayout = (TextInputLayout) findViewById(R.id.key_value_input_layout);

  typeTotp = (RadioButton) findViewById(R.id.type_choice_totp);
  typeHotp = (RadioButton) findViewById(R.id.type_choice_hotp);

  typeTotp.setText(getResources().getStringArray(R.array.type)[OtpType.TOTP.value]);
  typeHotp.setText(getResources().getStringArray(R.array.type)[OtpType.HOTP.value]);

  keyEntryFieldInputLayout.setErrorEnabled(true);

  // Set listeners
  keyEntryField.addTextChangedListener(this);

  findViewById(R.id.add_account_button_enter_key)
      .setOnClickListener(addButtonEnterKeyOnClickListener);
}
 
Example 8
Source File: TextInputLayoutValidator.java    From AwesomeValidation with MIT License 5 votes vote down vote up
@Override
public void execute(ValidationHolder validationHolder, Matcher matcher) {
    TextInputLayout textInputLayout = validationHolder.getTextInputLayout();
    textInputLayout.setErrorTextAppearance(mErrorTextAppearance);
    textInputLayout.setErrorEnabled(true);
    textInputLayout.setError(validationHolder.getErrMsg());
}
 
Example 9
Source File: TextInputLayoutValidator.java    From AwesomeValidation with MIT License 5 votes vote down vote up
@Override
public void halt() {
    for (ValidationHolder validationHolder : mValidationHolderList) {
        if (validationHolder.isSomeSortOfView()) {
            validationHolder.resetCustomError();
        } else {
            TextInputLayout textInputLayout = validationHolder.getTextInputLayout();
            textInputLayout.setErrorEnabled(false);
            textInputLayout.setError(null);
        }
    }
}
 
Example 10
Source File: FolderPresenter.java    From SuperNote with GNU General Public License v3.0 4 votes vote down vote up
private void setEditError(int position, String errorTip) {
    TextInputLayout textInputLayout=(TextInputLayout)mAdapter.getViewByPosition(position,R.id.textinput_edit_folder_name);
    textInputLayout.setErrorEnabled(true);
    textInputLayout.setError(errorTip);
}
 
Example 11
Source File: LoginDialogFragment.java    From openshop.io-android with MIT License 4 votes vote down vote up
/**
 * Check if editTexts are valid view and if user set all required fields.
 *
 * @return true if ok.
 */
private boolean isRequiredFields(TextInputLayout emailWrapper, TextInputLayout passwordWrapper) {
    if (emailWrapper == null || passwordWrapper == null) {
        Timber.e(new RuntimeException(), "Called isRequiredFields with null parameters.");
        MsgUtils.showToast(getActivity(), MsgUtils.TOAST_TYPE_INTERNAL_ERROR, null, MsgUtils.ToastLength.LONG);
        return false;
    } else {
        EditText email = emailWrapper.getEditText();
        EditText password = passwordWrapper.getEditText();
        if (email == null || password == null) {
            Timber.e(new RuntimeException(), "Called isRequiredFields with null editTexts in wrappers.");
            MsgUtils.showToast(getActivity(), MsgUtils.TOAST_TYPE_INTERNAL_ERROR, null, MsgUtils.ToastLength.LONG);
            return false;
        } else {
            boolean isEmail = false;
            boolean isPassword = false;

            if (email.getText().toString().equalsIgnoreCase("")) {
                emailWrapper.setErrorEnabled(true);
                emailWrapper.setError(getString(R.string.Required_field));
            } else {
                emailWrapper.setErrorEnabled(false);
                isEmail = true;
            }

            if (password.getText().toString().equalsIgnoreCase("")) {
                passwordWrapper.setErrorEnabled(true);
                passwordWrapper.setError(getString(R.string.Required_field));
            } else {
                passwordWrapper.setErrorEnabled(false);
                isPassword = true;
            }

            if (isEmail && isPassword) {
                return true;
            } else {
                Timber.e("Some fields are required.");
                return false;
            }
        }
    }
}
 
Example 12
Source File: SignUpActivity.java    From meiShi with Apache License 2.0 4 votes vote down vote up
private void setEditTextError(TextInputLayout layout, int msgId) {
    layout.setErrorEnabled(true);
    layout.setError(getString(msgId));
}
 
Example 13
Source File: ResetPasswordActivity.java    From meiShi with Apache License 2.0 4 votes vote down vote up
private void setEditTextError(TextInputLayout layout, int msgId) {
    layout.setErrorEnabled(true);
    layout.setError(getString(msgId));
}
 
Example 14
Source File: LoginActivity.java    From meiShi with Apache License 2.0 4 votes vote down vote up
private void setEditTextError(TextInputLayout layout, int msgId) {
    layout.setErrorEnabled(true);
    layout.setError(getString(msgId));
}