android.text.InputFilter.LengthFilter Java Examples

The following examples show how to use android.text.InputFilter.LengthFilter. 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 Project: android-card-form   Author: braintree   File: CardEditText.java    License: MIT License 5 votes vote down vote up
private void updateCardType() {
    CardType type = CardType.forCardNumber(getText().toString());
    if (mCardType != type) {
        mCardType = type;

        InputFilter[] filters = { new LengthFilter(mCardType.getMaxCardLength()) };
        setFilters(filters);
        invalidate();

        if (mOnCardTypeChangedListener != null) {
            mOnCardTypeChangedListener.onCardTypeChanged(mCardType);
        }
    }
}
 
Example #2
Source Project: android-card-form   Author: braintree   File: MobileNumberEditText.java    License: MIT License 5 votes vote down vote up
private void init() {
    if (isInEditMode()) {
        return;
    }

    setInputType(InputType.TYPE_CLASS_PHONE);
    InputFilter[] filters = { new LengthFilter(14) };
    setFilters(filters);
    addTextChangedListener(new PhoneNumberFormattingTextWatcher());
}
 
Example #3
Source Project: android-card-form   Author: braintree   File: CvvEditText.java    License: MIT License 5 votes vote down vote up
/**
 * Sets the card type associated with the security code type. {@link CardType#AMEX} has a
 * different icon and length than other card types. Typically handled through
 * {@link com.braintreepayments.cardform.view.CardEditText.OnCardTypeChangedListener#onCardTypeChanged(com.braintreepayments.cardform.utils.CardType)}.
 *
 * @param cardType Type of card represented by the current value of card number input.
 */
public void setCardType(CardType cardType) {
    mCardType = cardType;

    InputFilter[] filters = { new LengthFilter(cardType.getSecurityCodeLength()) };
    setFilters(filters);

    setContentDescription(getContext().getString(cardType.getSecurityCodeName()));
    setFieldHint(cardType.getSecurityCodeName());

    invalidate();
}
 
Example #4
Source Project: android-card-form   Author: braintree   File: CvvEditText.java    License: MIT License 4 votes vote down vote up
private void init() {
    setInputType(InputType.TYPE_CLASS_NUMBER);
    setFilters(new InputFilter[]{new LengthFilter(DEFAULT_MAX_LENGTH)});
    addTextChangedListener(this);
}
 
Example #5
Source Project: android-card-form   Author: braintree   File: ExpirationDateEditText.java    License: MIT License 4 votes vote down vote up
private void setInputFilters() {
    LengthFilter lengthFilter = new LengthFilter(MAX_NUM_CHARS);
    DigitsOnlyFilter digitsOnlyFilter = DigitsOnlyFilter.newInstance(MAX_NUM_CHARS);
    InputFilter[] filters = { lengthFilter, digitsOnlyFilter};
    setFilters(filters);
}
 
Example #6
Source Project: android-card-form   Author: braintree   File: CountryCodeEditText.java    License: MIT License 4 votes vote down vote up
private void init() {
    setInputType(InputType.TYPE_CLASS_PHONE);
    InputFilter[] filters = { new LengthFilter(4) };
    setFilters(filters);
}
 
Example #7
Source Project: android-card-form   Author: braintree   File: PostalCodeEditText.java    License: MIT License 4 votes vote down vote up
private void init() {
    setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
    InputFilter[] filters = { new LengthFilter(16) };
    setFilters(filters);
}
 
Example #8
Source Project: android-card-form   Author: braintree   File: CardholderNameEditText.java    License: MIT License 4 votes vote down vote up
private void init() {
    setInputType(InputType.TYPE_CLASS_TEXT);
    InputFilter[] filters = { new LengthFilter(255) };
    setFilters(filters);
}