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

293 lines
8.9 KiB
Java
Raw 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.text.Editable;
import android.text.InputFilter;
import android.text.Spanned;
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.LinearLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.scb.phone.R;
import com.scb.phone.view.custom.common.CustomAddressInput;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import o.C12919fLP;
import o.C15715hv;
import o.nMh;
/* loaded from: classes5.dex */
public class CustomAddressInput extends LinearLayout implements TextWatcher, View.OnFocusChangeListener {
private List<InputFilter> a;
public RVV b;
private String c;
public IeS d;
private String e;
@BindView
public TextView errorInline;
private int f;
private String g;
private boolean h;
private String i;
@BindView
public EditText inputTextField;
private Sts j;
@BindView
TextView mandatorySymbol;
@BindView
TextView titleLabel;
/* loaded from: classes5.dex */
public interface IeS {
void e(boolean z);
}
/* loaded from: classes5.dex */
public interface RVV {
void e(boolean z);
}
/* loaded from: classes5.dex */
public interface Sts {
void d(boolean z);
}
@Override // android.text.TextWatcher
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override // android.text.TextWatcher
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
public CustomAddressInput(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
byte b = 0;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C15715hv.jbe.CustomAddressInput, 0, 0);
this.i = obtainStyledAttributes.getString(4);
this.e = obtainStyledAttributes.getString(1);
this.h = obtainStyledAttributes.getBoolean(2, false);
this.f = obtainStyledAttributes.getInt(3, 30);
this.c = obtainStyledAttributes.getString(0);
obtainStyledAttributes.recycle();
((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R.layout.2131558915, (ViewGroup) this, true);
ButterKnife.c(this);
setTitleLabel(this.i);
setHint(this.e);
this.mandatorySymbol.setVisibility(this.h ? 0 : 8);
setMaxCharacter(this.f);
if (this.a == null) {
this.a = new ArrayList();
}
this.a.add(new LWm(this, b));
b();
b();
this.inputTextField.setOnEditorActionListener(new TextView.OnEditorActionListener(this) { // from class: o.eBl
private CustomAddressInput b;
@Override // android.widget.TextView.OnEditorActionListener
public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
return CustomAddressInput.a(this.b, i);
}
{
this.b = this;
}
});
}
public void setOnValueChangeListener(RVV rvv) {
this.inputTextField.addTextChangedListener(this);
this.b = rvv;
}
public void setOnInputValidateListener(Sts sts) {
this.inputTextField.addTextChangedListener(this);
this.j = sts;
}
public void setMaxCharacter(int i) {
List<InputFilter> list = this.a;
if (list == null) {
this.a = new ArrayList();
} else {
this.a = (List) list.stream().filter(new Predicate() { // from class: o.eBg
@Override // java.util.function.Predicate
public final boolean test(Object obj) {
return CustomAddressInput.aow_((InputFilter) obj);
}
}).collect(Collectors.toList());
}
this.a.add(new InputFilter.LengthFilter(i));
b();
}
public static /* synthetic */ boolean aow_(InputFilter inputFilter) {
return inputFilter.getClass() != InputFilter.LengthFilter.class;
}
public final void d() {
if (this.a == null) {
this.a = new ArrayList();
}
this.a.add(new C12919fLP("[^\\u0E01-\\u0E39\\u0E40-\\u0E4C]"));
b();
}
public final void a() {
if (this.a == null) {
this.a = new ArrayList();
}
this.a.add(new C12919fLP("^(?=\\S)[\\u0E00-\\u0E3E\\u0E40-\\u0E4E0-9 _*'\".,#&*()@\\/-]+$"));
b();
}
public final void e() {
if (this.a == null) {
this.a = new ArrayList();
}
this.a.add(new C12919fLP("^(?=\\S)[0-9a-zA-Z _*'\".,#&*()@\\/-]+$"));
b();
}
public final void c() {
if (this.a == null) {
this.a = new ArrayList();
}
this.a.add(new C12919fLP("^(?=\\S)[0-9a-zA-Z\\u0E00-\\u0E3E\\u0E40-\\u0E4E _*'\".,#&*()@\\/-]+$"));
b();
}
private void b() {
List<InputFilter> list = this.a;
if (list != null) {
this.inputTextField.setFilters((InputFilter[]) list.toArray(new InputFilter[list.size()]));
}
}
public final void a(boolean z) {
if (z) {
this.errorInline.setVisibility(8);
this.inputTextField.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_gray_rounded_rectangle));
} else {
this.errorInline.setVisibility(0);
this.errorInline.setText(this.c);
this.inputTextField.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_red_reounded_reactangle_border));
}
}
public CustomAddressInput(Context context) {
super(context);
}
public CustomAddressInput(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
}
public void setTitleLabel(String str) {
this.titleLabel.setText(str);
}
public void setHint(String str) {
this.inputTextField.setHint(str);
}
@Override // android.text.TextWatcher
public void afterTextChanged(Editable editable) {
RVV rvv = this.b;
if (rvv != null) {
rvv.e(!TextUtils.isEmpty(editable.toString().trim()));
}
if (this.j != null) {
if (!Pattern.compile(this.g).matcher(editable.toString()).matches() && !TextUtils.isEmpty(editable.toString().trim())) {
this.errorInline.setVisibility(0);
this.errorInline.setText(this.c);
} else {
this.errorInline.setVisibility(8);
}
this.j.d(Pattern.compile(this.g).matcher(editable.toString()).matches() && !TextUtils.isEmpty(editable.toString().trim()));
}
}
public void setTextValue(String str) {
if (str != null) {
this.inputTextField.setText(str.trim());
}
}
public void setOnFocusChanged(IeS ieS) {
this.inputTextField.setOnFocusChangeListener(this);
this.d = ieS;
}
@Override // android.view.View.OnFocusChangeListener
public void onFocusChange(View view, boolean z) {
IeS ieS = this.d;
if (ieS != null) {
ieS.e(z);
}
}
/* loaded from: classes5.dex */
class LWm implements InputFilter {
private CustomAddressInput d;
private LWm(CustomAddressInput customAddressInput) {
this.d = customAddressInput;
}
@Override // android.text.InputFilter
public final CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
while (i < i2) {
int type = Character.getType(charSequence.charAt(i));
if (type == 19 || type == 28) {
return "";
}
i++;
}
return null;
}
/* synthetic */ LWm(CustomAddressInput customAddressInput, byte b) {
this(customAddressInput);
}
}
public void setReadOnly(Boolean bool) {
this.inputTextField.setEnabled(!bool.booleanValue());
this.inputTextField.setBackground(nMh.getDrawable(getContext(), R.drawable.bg_rounded_rectangle_border_enable_state));
}
public static /* synthetic */ boolean a(CustomAddressInput customAddressInput, int i) {
if (i != 6 && i != 5) {
return false;
}
customAddressInput.setTextValue(customAddressInput.inputTextField.getText().toString().trim());
return false;
}
public void setRegexPattern(String str) {
this.g = str;
}
public void setErrorMessage(String str) {
this.c = str;
}
}