390 lines
12 KiB
Java
390 lines
12 KiB
Java
package com.scb.phone.view.custom.common;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.text.InputFilter;
|
|
import android.text.TextWatcher;
|
|
import android.text.method.DigitsKeyListener;
|
|
import android.util.AttributeSet;
|
|
import android.view.KeyEvent;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageButton;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import butterknife.BindView;
|
|
import butterknife.ButterKnife;
|
|
import com.scb.phone.R;
|
|
import com.scb.phone.view.custom.common.ClearableEditText;
|
|
import o.C15715hv;
|
|
import o.InterfaceC12827fIb;
|
|
import o.fJJ;
|
|
import o.nMh;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public class ClearableEditText extends RelativeLayout {
|
|
public int a;
|
|
private View.OnClickListener b;
|
|
private Drawable c;
|
|
|
|
@BindView
|
|
ImageButton clearButton;
|
|
private Drawable d;
|
|
private String e;
|
|
|
|
@BindView
|
|
ImageView editTextIcon;
|
|
|
|
@BindView
|
|
TextView errorText;
|
|
private IeS f;
|
|
private View.OnFocusChangeListener g;
|
|
private boolean h;
|
|
private String i;
|
|
|
|
@BindView
|
|
public CustomNoteEditText inputEditText;
|
|
|
|
@BindView
|
|
View inputTextLayout;
|
|
private boolean j;
|
|
private boolean m;
|
|
private TextWatcher n;
|
|
|
|
/* renamed from: o, reason: collision with root package name */
|
|
private RVV f8017o;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public interface IeS {
|
|
void e();
|
|
}
|
|
|
|
/* loaded from: classes5.dex */
|
|
public interface RVV {
|
|
boolean c(String str);
|
|
}
|
|
|
|
protected int b() {
|
|
return R.layout.2131558855;
|
|
}
|
|
|
|
public ClearableEditText(Context context) {
|
|
super(context);
|
|
this.h = false;
|
|
this.a = 40;
|
|
this.e = "";
|
|
this.f8017o = null;
|
|
this.f = null;
|
|
this.j = false;
|
|
this.n = new fJJ(this) { // from class: com.scb.phone.view.custom.common.ClearableEditText.1
|
|
private ClearableEditText b;
|
|
|
|
{
|
|
this.b = this;
|
|
}
|
|
|
|
@Override // o.fJJ, android.text.TextWatcher
|
|
public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
this.b.clearButton.setVisibility((charSequence.length() <= 0 || !this.b.m) ? 8 : 0);
|
|
if (this.b.h) {
|
|
this.b.setErrorVisible(false);
|
|
}
|
|
}
|
|
};
|
|
this.g = new View.OnFocusChangeListener(this) { // from class: o.eBf
|
|
private ClearableEditText e;
|
|
|
|
@Override // android.view.View.OnFocusChangeListener
|
|
public final void onFocusChange(View view, boolean z) {
|
|
ClearableEditText.c(this.e, z);
|
|
}
|
|
|
|
{
|
|
this.e = this;
|
|
}
|
|
};
|
|
this.b = new View.OnClickListener(this) { // from class: o.eBh
|
|
private ClearableEditText d;
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
this.d.inputEditText.setText("");
|
|
}
|
|
|
|
{
|
|
this.d = this;
|
|
}
|
|
};
|
|
this.m = true;
|
|
aov_(context, null);
|
|
}
|
|
|
|
public ClearableEditText(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.h = false;
|
|
this.a = 40;
|
|
this.e = "";
|
|
this.f8017o = null;
|
|
this.f = null;
|
|
this.j = false;
|
|
this.n = new fJJ(this) { // from class: com.scb.phone.view.custom.common.ClearableEditText.1
|
|
private ClearableEditText b;
|
|
|
|
{
|
|
this.b = this;
|
|
}
|
|
|
|
@Override // o.fJJ, android.text.TextWatcher
|
|
public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
this.b.clearButton.setVisibility((charSequence.length() <= 0 || !this.b.m) ? 8 : 0);
|
|
if (this.b.h) {
|
|
this.b.setErrorVisible(false);
|
|
}
|
|
}
|
|
};
|
|
this.g = new View.OnFocusChangeListener(this) { // from class: o.eBf
|
|
private ClearableEditText e;
|
|
|
|
@Override // android.view.View.OnFocusChangeListener
|
|
public final void onFocusChange(View view, boolean z) {
|
|
ClearableEditText.c(this.e, z);
|
|
}
|
|
|
|
{
|
|
this.e = this;
|
|
}
|
|
};
|
|
this.b = new View.OnClickListener(this) { // from class: o.eBh
|
|
private ClearableEditText d;
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
this.d.inputEditText.setText("");
|
|
}
|
|
|
|
{
|
|
this.d = this;
|
|
}
|
|
};
|
|
this.m = true;
|
|
aov_(context, attributeSet);
|
|
}
|
|
|
|
public ClearableEditText(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.h = false;
|
|
this.a = 40;
|
|
this.e = "";
|
|
this.f8017o = null;
|
|
this.f = null;
|
|
this.j = false;
|
|
this.n = new fJJ(this) { // from class: com.scb.phone.view.custom.common.ClearableEditText.1
|
|
private ClearableEditText b;
|
|
|
|
{
|
|
this.b = this;
|
|
}
|
|
|
|
@Override // o.fJJ, android.text.TextWatcher
|
|
public final void onTextChanged(CharSequence charSequence, int i2, int i22, int i3) {
|
|
this.b.clearButton.setVisibility((charSequence.length() <= 0 || !this.b.m) ? 8 : 0);
|
|
if (this.b.h) {
|
|
this.b.setErrorVisible(false);
|
|
}
|
|
}
|
|
};
|
|
this.g = new View.OnFocusChangeListener(this) { // from class: o.eBf
|
|
private ClearableEditText e;
|
|
|
|
@Override // android.view.View.OnFocusChangeListener
|
|
public final void onFocusChange(View view, boolean z) {
|
|
ClearableEditText.c(this.e, z);
|
|
}
|
|
|
|
{
|
|
this.e = this;
|
|
}
|
|
};
|
|
this.b = new View.OnClickListener(this) { // from class: o.eBh
|
|
private ClearableEditText d;
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
this.d.inputEditText.setText("");
|
|
}
|
|
|
|
{
|
|
this.d = this;
|
|
}
|
|
};
|
|
this.m = true;
|
|
aov_(context, attributeSet);
|
|
}
|
|
|
|
private void aov_(Context context, AttributeSet attributeSet) {
|
|
LayoutInflater.from(getContext()).inflate(b(), (ViewGroup) this, true);
|
|
ButterKnife.c(this);
|
|
setEnabledEditTextIcon(false);
|
|
this.inputEditText.addTextChangedListener(this.n);
|
|
this.clearButton.setOnClickListener(this.b);
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C15715hv.jbe.ClearableEditText);
|
|
setMaxLength(obtainStyledAttributes.getInteger(8, this.a));
|
|
this.i = obtainStyledAttributes.getString(7);
|
|
this.e = obtainStyledAttributes.getString(5);
|
|
setInputType(obtainStyledAttributes.getInt(1, 0));
|
|
setImeOptions(obtainStyledAttributes.getInt(2, 0));
|
|
if (obtainStyledAttributes.hasValue(3)) {
|
|
this.inputEditText.setNextFocusForwardId(obtainStyledAttributes.getInt(4, 0));
|
|
}
|
|
Drawable drawable = obtainStyledAttributes.getDrawable(4);
|
|
if (drawable != null) {
|
|
this.d = drawable;
|
|
this.inputTextLayout.setBackground(drawable);
|
|
} else {
|
|
this.d = nMh.getDrawable(context, R.drawable.shape_gray_rounded_rectangle);
|
|
}
|
|
Drawable drawable2 = obtainStyledAttributes.getDrawable(6);
|
|
if (drawable2 != null) {
|
|
this.c = drawable2;
|
|
} else {
|
|
this.c = nMh.getDrawable(context, R.drawable.shape_red_reounded_reactangle_border);
|
|
}
|
|
if (obtainStyledAttributes.hasValue(0)) {
|
|
setDigitsFilter(obtainStyledAttributes.getString(0));
|
|
}
|
|
this.m = obtainStyledAttributes.getBoolean(9, true);
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
setHint(this.i);
|
|
this.inputEditText.setOnFocusChangeListener(this.g);
|
|
this.inputEditText.setOnEditorActionListener(new TextView.OnEditorActionListener(this) { // from class: o.eBb
|
|
private ClearableEditText c;
|
|
|
|
@Override // android.widget.TextView.OnEditorActionListener
|
|
public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
|
return ClearableEditText.c(this.c, i);
|
|
}
|
|
|
|
{
|
|
this.c = this;
|
|
}
|
|
});
|
|
this.errorText.setText(this.e);
|
|
}
|
|
|
|
public void setHint(String str) {
|
|
this.inputEditText.setHint(str);
|
|
}
|
|
|
|
public void setEnabledEditTextIcon(boolean z) {
|
|
ImageView imageView = this.editTextIcon;
|
|
if (imageView != null) {
|
|
imageView.setVisibility(z ? 0 : 8);
|
|
}
|
|
}
|
|
|
|
public void setInputType(int i) {
|
|
if (i != 0) {
|
|
this.inputEditText.setInputType(i);
|
|
}
|
|
}
|
|
|
|
public void setImeOptions(int i) {
|
|
if (i != 0) {
|
|
this.inputEditText.setImeOptions(i);
|
|
}
|
|
}
|
|
|
|
public void setDigitsFilter(String str) {
|
|
if (str != null) {
|
|
this.inputEditText.setKeyListener(DigitsKeyListener.getInstance(str));
|
|
}
|
|
}
|
|
|
|
public void setErrorVisible(boolean z) {
|
|
this.h = z;
|
|
this.errorText.setVisibility(z ? 0 : 8);
|
|
this.inputTextLayout.setBackground(z ? this.c : this.d);
|
|
}
|
|
|
|
public void setHighlight(boolean z) {
|
|
this.inputTextLayout.setBackground(z ? this.c : this.d);
|
|
}
|
|
|
|
protected void a() {
|
|
RVV rvv;
|
|
String obj = this.inputEditText.getText().toString();
|
|
if (this.j || obj.length() <= 0 || (rvv = this.f8017o) == null) {
|
|
return;
|
|
}
|
|
setErrorVisible(!rvv.c(this.inputEditText.getText().toString()));
|
|
}
|
|
|
|
public void setText(String str) {
|
|
this.inputEditText.removeTextChangedListener(this.n);
|
|
this.inputEditText.setText(str);
|
|
setSelection(str.length());
|
|
this.inputEditText.addTextChangedListener(this.n);
|
|
}
|
|
|
|
public void setSelection(int i) {
|
|
this.inputEditText.setSelection(i);
|
|
}
|
|
|
|
public void setMaxLength(int i) {
|
|
this.a = i;
|
|
this.inputEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.a)});
|
|
}
|
|
|
|
public void setErrorText(String str) {
|
|
this.errorText.setText(str);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setEnabled(boolean z) {
|
|
int color;
|
|
this.inputEditText.setEnabled(z);
|
|
CustomNoteEditText customNoteEditText = this.inputEditText;
|
|
if (z) {
|
|
color = nMh.getColor(getContext(), R.color.f2982131099805);
|
|
} else {
|
|
color = nMh.getColor(getContext(), R.color.f3412131099849);
|
|
}
|
|
customNoteEditText.setTextColor(color);
|
|
}
|
|
|
|
public void setEditTextKeyboardActionListener(InterfaceC12827fIb interfaceC12827fIb) {
|
|
this.inputEditText.setEditTextKeyboardActionListener(interfaceC12827fIb);
|
|
}
|
|
|
|
public static /* synthetic */ void c(ClearableEditText clearableEditText, boolean z) {
|
|
clearableEditText.j = z;
|
|
clearableEditText.a();
|
|
}
|
|
|
|
public static /* synthetic */ boolean c(ClearableEditText clearableEditText, int i) {
|
|
if (i != 6) {
|
|
return false;
|
|
}
|
|
clearableEditText.inputEditText.clearFocus();
|
|
IeS ieS = clearableEditText.f;
|
|
if (ieS == null) {
|
|
return false;
|
|
}
|
|
ieS.e();
|
|
return false;
|
|
}
|
|
|
|
public void setValidateInputListener(RVV rvv) {
|
|
this.f8017o = rvv;
|
|
}
|
|
|
|
public void setKeyInputListener(IeS ieS) {
|
|
this.f = ieS;
|
|
}
|
|
}
|