package com.scb.phone.view.custom.common; import android.content.Context; import android.content.res.TypedArray; import android.text.Editable; import android.text.InputFilter; import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.ImageButton; import android.widget.RelativeLayout; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import com.scb.phone.R; import com.scb.phone.view.custom.common.InputText; import o.C15715hv; import o.URz; import o.nMh; /* loaded from: classes5.dex */ public class InputText extends RelativeLayout { private String a; private boolean b; private boolean c; @BindView ImageButton clearButton; @BindView TextView counterText; private String d; private int e; @BindView public TextView errorText; private RVV f; private RVV g; private String h; @BindView public EditText inputEditText; private final TextWatcher j; @BindView TextView titleText; /* loaded from: classes5.dex */ public interface RVV { void b(String str); } public InputText(Context context) { this(context, null); } public InputText(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public InputText(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.e = 40; TextWatcher textWatcher = new TextWatcher(this) { // from class: com.scb.phone.view.custom.common.InputText.5 private InputText b; @Override // android.text.TextWatcher public final void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) { } @Override // android.text.TextWatcher public final void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) { } { this.b = this; } @Override // android.text.TextWatcher public final void afterTextChanged(Editable editable) { this.b.d(editable.length()); if (this.b.f != null) { this.b.f.b(editable.toString()); } this.b.clearButton.setVisibility((!this.b.b || TextUtils.isEmpty(editable)) ? 4 : 0); } }; this.j = textWatcher; if (attributeSet != null) { TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C15715hv.jbe.InputText); this.h = obtainStyledAttributes.getString(5); this.e = obtainStyledAttributes.getInteger(4, 40); this.a = obtainStyledAttributes.getString(1); this.c = obtainStyledAttributes.getBoolean(3, false); this.b = obtainStyledAttributes.getBoolean(2, false); this.d = obtainStyledAttributes.getString(0); obtainStyledAttributes.recycle(); } LayoutInflater.from(getContext()).inflate(R.layout.2131558866, (ViewGroup) this, true); ButterKnife.c(this); URz.we_(this.errorText, R.style.f56002132017858); String str = this.h; if (str != null) { this.titleText.setText(str); } String str2 = this.a; if (str2 != null) { this.inputEditText.setHint(str2); } this.counterText.setVisibility(this.c ? 0 : 4); d(0); this.inputEditText.setInputType(this.e > 40 ? 131073 : 1); this.inputEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.e)}); this.inputEditText.removeTextChangedListener(textWatcher); this.inputEditText.addTextChangedListener(textWatcher); this.inputEditText.setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: o.eCq private InputText b; @Override // android.view.View.OnFocusChangeListener public final void onFocusChange(View view, boolean z) { InputText.a(this.b, z); } { this.b = this; } }); this.inputEditText.setOnEditorActionListener(new TextView.OnEditorActionListener(this) { // from class: o.eCw private InputText e; @Override // android.widget.TextView.OnEditorActionListener public final boolean onEditorAction(TextView textView, int i2, KeyEvent keyEvent) { return InputText.a(this.e, i2); } { this.e = this; } }); this.errorText.setText(this.d); this.errorText.setVisibility(8); } public void setText(String str) { this.inputEditText.setText(str); } public void setMaxLength(int i) { this.e = i; this.counterText.setText(getContext().getString(R.string.text_counter, 0, Integer.valueOf(i))); this.inputEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(i)}); } /* JADX INFO: Access modifiers changed from: private */ public void d(int i) { this.counterText.setText(getContext().getString(R.string.text_counter, Integer.valueOf(i), Integer.valueOf(this.e))); } public final void b(String str) { this.errorText.setVisibility(0); this.errorText.setText(str); this.inputEditText.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_red_reounded_reactangle_border)); } public void setImeOptions(int i) { this.inputEditText.setImeOptions(i); } @OnClick public void onClearButtonClick() { setText(""); } public static /* synthetic */ boolean a(InputText inputText, int i) { if (i != 6 || TextUtils.isEmpty(inputText.inputEditText.getText().toString().trim())) { return false; } inputText.setText(inputText.inputEditText.getText().toString().trim()); return false; } public static /* synthetic */ void a(InputText inputText, boolean z) { if (z) { return; } if (!TextUtils.isEmpty(inputText.inputEditText.getText().toString().trim())) { inputText.setText(inputText.inputEditText.getText().toString().trim()); } RVV rvv = inputText.g; if (rvv != null) { rvv.b(inputText.inputEditText.getText().toString()); } } public void setOnInputChangeListener(RVV rvv) { this.f = rvv; } public void setOnFocusChangeListener(RVV rvv) { this.g = rvv; } }