what-the-bank/sources/com/scb/phone/view/custom/common/CommonInputViewGroup.java

337 lines
11 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.custom.common;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
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 butterknife.OnClick;
import com.scb.phone.R;
import com.scb.phone.view.custom.common.CommonInputViewGroup;
import com.scb.phone.view.custom.common.CustomEditText;
import java.util.ArrayList;
import java.util.Iterator;
import o.C12919fLP;
import o.C15715hv;
import o.nMh;
/* loaded from: classes5.dex */
public class CommonInputViewGroup extends RelativeLayout {
public int a;
private Sts b;
private DefaultButton c;
public ArrayList<TextWatcher> d;
public boolean e;
@BindView
ImageView extraIcon;
private boolean f;
private int g;
private final TextWatcher h;
private HBt i;
private int j;
@BindView
TextView mCounterTextView;
@BindView
public ImageButton mEditClearImageButton;
@BindView
public ImageButton mEditPencilImageButton;
@BindView
public CustomEditText mEditText;
@BindView
public TextView mErrorTextView;
@BindView
TextView mTitleTextView;
/* loaded from: classes5.dex */
public interface HBt {
void a();
}
/* loaded from: classes5.dex */
public interface Sts {
void c();
}
protected int a() {
return R.layout.2131558867;
}
public CommonInputViewGroup(Context context) {
this(context, null);
}
public CommonInputViewGroup(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public CommonInputViewGroup(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.a = 20;
this.f = false;
this.e = false;
this.i = null;
this.d = new ArrayList<>();
this.g = 50;
this.j = 1;
this.b = null;
TextWatcher textWatcher = new TextWatcher(this) { // from class: com.scb.phone.view.custom.common.CommonInputViewGroup.5
private CommonInputViewGroup d;
@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.d = this;
}
@Override // android.text.TextWatcher
public final void afterTextChanged(Editable editable) {
this.d.mCounterTextView.setText(this.d.getContext().getString(R.string.text_counter, Integer.valueOf(editable.length()), Integer.valueOf(this.d.a)));
if (this.d.c != null) {
this.d.c.setButtonEnabled(editable.length() > 0 && editable.length() <= this.d.a);
}
}
};
this.h = textWatcher;
LayoutInflater.from(getContext()).inflate(a(), (ViewGroup) this, true);
ButterKnife.c(this);
if (attributeSet != null) {
TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(attributeSet, C15715hv.jbe.CommonInputViewGroup, 0, 0);
try {
this.f = obtainStyledAttributes.getBoolean(2, false);
this.e = obtainStyledAttributes.getBoolean(0, false);
this.a = obtainStyledAttributes.getInteger(3, 20);
this.mTitleTextView.setText(obtainStyledAttributes.getString(9));
this.mEditText.setHint(obtainStyledAttributes.getString(5));
this.mErrorTextView.setText(obtainStyledAttributes.getString(4));
int integer = obtainStyledAttributes.getInteger(8, 1);
if (integer == 131072) {
this.mEditText.setSingleLine(false);
this.mEditText.setInputType(integer | 1);
} else {
this.mEditText.setInputType(integer);
}
this.mEditText.setImeOptions(obtainStyledAttributes.getInteger(7, 6));
int resourceId = obtainStyledAttributes.getResourceId(6, 0);
if (resourceId != 0) {
this.extraIcon.setImageResource(resourceId);
this.extraIcon.setVisibility(0);
this.extraIcon.setOnClickListener(new View.OnClickListener(this) { // from class: o.eBk
private CommonInputViewGroup e;
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
CommonInputViewGroup.d(this.e);
}
{
this.e = this;
}
});
} else {
this.extraIcon.setVisibility(8);
}
if (this.a > 0) {
this.mEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.a)});
}
int resourceId2 = obtainStyledAttributes.getResourceId(1, 0);
if (resourceId2 != 0) {
this.mEditClearImageButton.setImageResource(resourceId2);
} else {
this.mEditClearImageButton.setImageResource(R.drawable.ic_cross_circle);
}
} finally {
obtainStyledAttributes.recycle();
}
}
this.mCounterTextView.setText(getContext().getString(R.string.text_counter, 0, Integer.valueOf(this.a)));
if (this.f) {
this.mEditText.addTextChangedListener(textWatcher);
}
this.mCounterTextView.setVisibility(this.f ? 0 : 8);
this.mEditClearImageButton.setVisibility(this.e ? 0 : 8);
}
public void setNameThaiType() {
b("^[\\u0E01-\\u0E39\\u0E40-\\u0E4C ]+$");
}
public void setNameEnglishType() {
b("^[a-zA-Z .'-]+$");
}
@Override // android.view.ViewGroup, android.view.View
public void clearFocus() {
super.clearFocus();
this.mErrorTextView.setFocusable(true);
this.mErrorTextView.setFocusableInTouchMode(true);
this.mErrorTextView.requestFocus();
}
public final void b() {
ArrayList<TextWatcher> arrayList = this.d;
if (arrayList != null) {
Iterator<TextWatcher> it = arrayList.iterator();
while (it.hasNext()) {
this.mEditText.removeTextChangedListener(it.next());
}
this.d.clear();
}
}
public void setFocusListener(View.OnFocusChangeListener onFocusChangeListener) {
this.mEditText.setOnFocusChangeListener(onFocusChangeListener);
}
public void setErrorText(String str) {
this.mErrorTextView.setText(str);
}
public void e() {
this.mErrorTextView.setVisibility(8);
this.mEditText.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_gray_rounded_rectangle));
}
public void c() {
this.mErrorTextView.setVisibility(0);
this.mEditText.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_red_reounded_reactangle_border));
}
public void setText(String str) {
this.mEditText.setText(str);
}
@OnClick
public void onClickClear() {
Sts sts = this.b;
if (sts != null) {
sts.c();
} else if (this.e) {
this.mEditText.setText("");
}
}
public void setOnBackListener(CustomEditText.LWm lWm) {
this.mEditText.setOnBackListener(lWm);
}
public void setOnPasteListener(CustomEditText.IeS ieS) {
this.mEditText.setOnPasteListener(ieS);
}
public void setOnEditorActionListener(TextView.OnEditorActionListener onEditorActionListener) {
this.mEditText.setOnEditorActionListener(onEditorActionListener);
}
public void setFilter(String str) {
if (str != null) {
this.mEditText.setFilters(new InputFilter[]{new C12919fLP(str), new InputFilter.LengthFilter(this.a)});
}
}
public void setFilterList(InputFilter[] inputFilterArr) {
if (inputFilterArr != null) {
this.mEditText.setFilters(inputFilterArr);
}
}
public void setTitle(String str) {
this.mTitleTextView.setText(str);
}
public void setHint(String str) {
this.mEditText.setHint(str);
}
public void setHintEllipsize() {
this.mEditText.setMaxLines(this.j);
this.mEditText.setEllipsize(TextUtils.TruncateAt.END);
}
@Override // android.view.View
public void setEnabled(boolean z) {
this.mEditText.setEnabled(z);
if (z) {
this.mEditText.setTextColor(nMh.getColor(getContext(), R.color.f2982131099805));
} else {
this.mEditText.setTextColor(nMh.getColor(getContext(), R.color.f3412131099849));
}
super.setEnabled(z);
}
public void setPencilEditListener(View.OnClickListener onClickListener) {
ImageButton imageButton = this.mEditPencilImageButton;
if (imageButton != null) {
imageButton.setOnClickListener(onClickListener);
}
}
public void setForegroundFontEnabled(boolean z) {
this.mEditText.setEnabled(z);
if (z) {
this.mTitleTextView.setTextColor(nMh.getColor(getContext(), R.color.f2982131099805));
this.mEditText.setHintTextColor(nMh.getColor(getContext(), R.color.f3092131099816));
} else {
this.mTitleTextView.setTextColor(nMh.getColor(getContext(), R.color.f3092131099816));
this.mEditText.setHintTextColor(nMh.getColor(getContext(), R.color.f3412131099849));
}
super.setEnabled(z);
}
public void setClearTextIconColorFilter(int i) {
this.mEditClearImageButton.setColorFilter(nMh.getColor(getContext(), i), PorterDuff.Mode.SRC_ATOP);
}
private void b(String str) {
this.mEditText.setFilters(new InputFilter[]{new C12919fLP(str), new InputFilter.LengthFilter(this.g)});
this.mEditText.setInputType(524432);
}
public static /* synthetic */ void d(CommonInputViewGroup commonInputViewGroup) {
HBt hBt = commonInputViewGroup.i;
if (hBt != null) {
hBt.a();
}
}
public void setMaxCounter(int i) {
this.a = i;
}
public void setIconListener(HBt hBt) {
this.i = hBt;
}
public void setDefaultButton(DefaultButton defaultButton) {
this.c = defaultButton;
}
public void setClearTextIconListener(Sts sts) {
this.b = sts;
}
}