192 lines
6.7 KiB
Java
192 lines
6.7 KiB
Java
package com.scb.phone.view.custom.common;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Rect;
|
|
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.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 java.util.regex.Pattern;
|
|
import o.C15715hv;
|
|
import o.nMh;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public class NoteEditText extends RelativeLayout {
|
|
private int a;
|
|
private IeS b;
|
|
private float c;
|
|
private String d;
|
|
private String e;
|
|
private int f;
|
|
private final TextWatcher g;
|
|
private String h;
|
|
private int j;
|
|
|
|
@BindView
|
|
ImageButton mClearButton;
|
|
|
|
@BindView
|
|
public TextView mErrorText;
|
|
|
|
@BindView
|
|
public EditText mNoteEditText;
|
|
|
|
@BindView
|
|
TextView mTextCounter;
|
|
|
|
@BindView
|
|
TextView mTitleText;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public interface IeS {
|
|
void d(boolean z);
|
|
}
|
|
|
|
protected int a() {
|
|
return R.layout.2131558872;
|
|
}
|
|
|
|
public NoteEditText(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public NoteEditText(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public NoteEditText(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
TextWatcher textWatcher = new TextWatcher(this) { // from class: com.scb.phone.view.custom.common.NoteEditText.5
|
|
private NoteEditText 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.mTextCounter.setText(this.b.getContext().getString(R.string.text_counter, Integer.valueOf(editable.length()), Integer.valueOf(this.b.a)));
|
|
this.b.b();
|
|
this.b.mClearButton.setVisibility(TextUtils.isEmpty(editable) ? 4 : 0);
|
|
if (this.b.b != null) {
|
|
if (Pattern.compile(this.b.e).matcher(editable.toString()).matches() || editable.toString().isEmpty()) {
|
|
this.b.b();
|
|
} else {
|
|
this.b.d();
|
|
}
|
|
this.b.b.d(Pattern.compile(this.b.e).matcher(editable.toString()).matches());
|
|
}
|
|
}
|
|
};
|
|
this.g = textWatcher;
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C15715hv.jbe.NoteEditText);
|
|
this.a = obtainStyledAttributes.getInteger(2, 40);
|
|
this.c = obtainStyledAttributes.getFloat(1, 40.0f);
|
|
this.d = obtainStyledAttributes.getString(0);
|
|
this.h = obtainStyledAttributes.getString(4);
|
|
this.j = obtainStyledAttributes.getColor(3, nMh.getColor(context, R.color.f2982131099805));
|
|
this.f = (int) (obtainStyledAttributes.getDimensionPixelSize(5, context.getResources().getDimensionPixelSize(R.dimen.f16092131165375)) / getContext().getResources().getDisplayMetrics().scaledDensity);
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
LayoutInflater.from(getContext()).inflate(a(), (ViewGroup) this, true);
|
|
ButterKnife.c(this);
|
|
this.mNoteEditText.setInputType(524288);
|
|
this.mNoteEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.a)});
|
|
ViewGroup.LayoutParams layoutParams = this.mNoteEditText.getLayoutParams();
|
|
if (this.a > 40) {
|
|
float f = getContext().getResources().getDisplayMetrics().density;
|
|
int i2 = (int) ((8.0f * f) + 0.5f);
|
|
layoutParams.height = (int) ((this.c * f) + 0.5f);
|
|
this.mNoteEditText.setSingleLine(false);
|
|
this.mNoteEditText.setGravity(48);
|
|
EditText editText = this.mNoteEditText;
|
|
editText.setPadding(editText.getPaddingLeft(), i2, this.mNoteEditText.getPaddingRight(), i2);
|
|
this.mTitleText.setText(getContext().getString(R.string.gift_input_message_title));
|
|
}
|
|
String str = this.d;
|
|
if (str != null) {
|
|
this.mNoteEditText.setHint(str);
|
|
}
|
|
String str2 = this.h;
|
|
if (str2 != null) {
|
|
this.mTitleText.setText(str2);
|
|
}
|
|
int i3 = this.j;
|
|
if (i3 != 0) {
|
|
this.mTitleText.setTextColor(i3);
|
|
}
|
|
int i4 = this.f;
|
|
if (i4 != 0) {
|
|
this.mTitleText.setTextSize(i4);
|
|
}
|
|
this.mNoteEditText.setLayoutParams(layoutParams);
|
|
this.mTextCounter.setText(getContext().getString(R.string.text_counter, 0, Integer.valueOf(this.a)));
|
|
this.mNoteEditText.removeTextChangedListener(textWatcher);
|
|
this.mNoteEditText.addTextChangedListener(textWatcher);
|
|
}
|
|
|
|
public void setOnNoteInputListener(IeS ieS, String str, boolean z) {
|
|
this.e = str;
|
|
this.b = ieS;
|
|
if (z) {
|
|
this.mNoteEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.a), new InputFilter.AllCaps()});
|
|
} else {
|
|
this.mNoteEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.a)});
|
|
}
|
|
}
|
|
|
|
public void b() {
|
|
this.mErrorText.setVisibility(8);
|
|
this.mNoteEditText.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_gray_rounded_rectangle));
|
|
}
|
|
|
|
public void d() {
|
|
this.mErrorText.setVisibility(0);
|
|
this.mNoteEditText.setBackground(nMh.getDrawable(getContext(), R.drawable.shape_red_reounded_reactangle_border));
|
|
}
|
|
|
|
public void setErrorMessage(String str) {
|
|
this.mErrorText.setText(str);
|
|
}
|
|
|
|
@OnClick
|
|
public void onClickClear() {
|
|
this.mNoteEditText.setText("");
|
|
}
|
|
|
|
public void setText(String str) {
|
|
this.mNoteEditText.setText(str);
|
|
}
|
|
|
|
public void setNoteEnabled(boolean z) {
|
|
this.mNoteEditText.setEnabled(z);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public boolean requestFocus(int i, Rect rect) {
|
|
this.mNoteEditText.requestFocus();
|
|
return super.requestFocus(i, rect);
|
|
}
|
|
}
|