Skip to content

Commit

Permalink
Merge pull request #42 from aiqfome/develop
Browse files Browse the repository at this point in the history
Release - 2.1.5
  • Loading branch information
lucasvillaverde authored May 12, 2021
2 parents ae60bfc + f977c3d commit aa43a4c
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.InputType;
import android.text.TextUtils;
import android.text.method.DigitsKeyListener;
import android.text.method.KeyListener;
Expand Down Expand Up @@ -33,6 +34,7 @@ public class TextInput extends ConstraintLayout {
private TextInputLayout inputLayout;
private ImageView icon;
private KeyListener inputKeyListener;
private int inputType;

public TextInput(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
Expand All @@ -44,8 +46,8 @@ public TextInput(Context context, @Nullable AttributeSet attrs) {
input = findViewById(R.id.et_input);
inputLayout = findViewById(R.id.input);
icon = findViewById(R.id.iv_selected_icon);

inputKeyListener = input.getKeyListener();
inputType = inputKeyListener.getInputType();

setupAttrs(context, attrs);
setOnClickListener(onClickListener());
Expand Down Expand Up @@ -121,6 +123,7 @@ private void setupAttrs(Context context, @Nullable AttributeSet attrs) {
.getInt(attr, EditorInfo.TYPE_TEXT_VARIATION_NORMAL);

input.setInputType(inputType);
this.inputType = inputType;

} else if (attr == R.styleable.TextInput_android_selectAllOnFocus) {
boolean selectAllOnFocus = styledAttributes.getBoolean(attr, false);
Expand Down Expand Up @@ -166,10 +169,16 @@ public void setEnabled(boolean enabled) {

}


public void setSelectorEnabled(boolean enabled) {
super.setEnabled(enabled);
}

public void setInputType(int inputType) {
this.inputType = inputType;
input.setInputType(inputType);
}

private void setEllipsized(boolean enabled) {
this.input.setCursorVisible(!enabled);
if (enabled) {
Expand All @@ -181,6 +190,7 @@ private void setEllipsized(boolean enabled) {

this.input.setEllipsize(null);
this.input.setKeyListener(inputKeyListener);
this.input.setInputType(inputType);
}

private OnClickListener onClickListener() {
Expand Down

0 comments on commit aa43a4c

Please sign in to comment.