added input type check for edit text
This commit is contained in:
parent
d19593a51e
commit
98842a6bbc
|
|
@ -25,6 +25,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.AppCompatEditText;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.SingleLineTransformationMethod;
|
||||
|
|
@ -160,6 +161,12 @@ public class TypefacedEditText extends AppCompatEditText {
|
|||
"textSize required parameter. If it's dynamic then use '0sp'");
|
||||
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_inputType"), true,
|
||||
"inputType required parameter");
|
||||
|
||||
final int inputType = typedArray.getInt(AttributesUtils.getField(androidRes, "TextView_inputType"), -1);
|
||||
if (inputType == InputType.TYPE_CLASS_NUMBER || inputType == InputType.TYPE_DATETIME_VARIATION_NORMAL) {
|
||||
errors.add("use inputType phone instead of number");
|
||||
}
|
||||
|
||||
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_imeOptions"), true,
|
||||
"imeOptions required parameter");
|
||||
}
|
||||
|
|
@ -299,6 +306,14 @@ public class TypefacedEditText extends AppCompatEditText {
|
|||
Lc.assertion(new IllegalStateException(AttributesUtils.viewError(this, "Do not specify ellipsize for EditText")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputType(final int type) {
|
||||
if (type == InputType.TYPE_CLASS_NUMBER || type == InputType.TYPE_NUMBER_VARIATION_NORMAL) {
|
||||
Lc.assertion(new IllegalStateException(AttributesUtils.viewError(this, "Do not specify number InputType for EditText, use phone instead")));
|
||||
}
|
||||
super.setInputType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets typeface from 'assets/fonts' folder by name.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue