package com.scb.phone.view.custom.common; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.text.InputFilter; import android.text.TextUtils; import android.util.AttributeSet; import android.view.KeyEvent; import android.widget.TextView; import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; import com.scb.phone.R; import com.scb.phone.view.custom.common.MwAmountEditText; import o.C10395eCv; import o.C15715hv; import o.C6583cXR; import o.EnumC0706MsT; import o.fLM; import o.fLN; import o.ofu; /* loaded from: classes5.dex */ public class MwAmountEditText extends TextInputEditText { private String a; private IeS b; public double c; private fLM d; private InputFilter[] e; private LWm f; private RVV g; private TextInputLayout h; private Sts i; private boolean j; private String l; /* loaded from: classes5.dex */ public interface IeS { void a(); } /* loaded from: classes5.dex */ public interface LWm { void c(); } /* loaded from: classes5.dex */ public interface RVV { boolean c(); } /* loaded from: classes5.dex */ public interface Sts { void c(); void c(double d); } public MwAmountEditText(Context context) { this(context, null); } public MwAmountEditText(Context context, AttributeSet attributeSet) { this(context, attributeSet, R.attr.editTextStyle); } public MwAmountEditText(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.j = true; this.d = new fLM(this, new C10395eCv(this)); this.l = getResources().getString(R.string.transfer_to_account_amount_hint); int i2 = -1; if (attributeSet != null) { TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C15715hv.jbe.AmountEditText); i2 = obtainStyledAttributes.getInteger(1, -1); if (obtainStyledAttributes.getString(0) != null) { this.l = obtainStyledAttributes.getString(0); } this.j = obtainStyledAttributes.getBoolean(2, true); obtainStyledAttributes.recycle(); } setHint(this.l); InputFilter[] inputFilterArr = {new fLN(i2 < 0 ? 10 : i2, this.j ? 2 : 0)}; this.e = inputFilterArr; setFilters(inputFilterArr); addTextChangedListener(this.d); setOnEditorActionListener(new TextView.OnEditorActionListener(this) { // from class: o.eCx private MwAmountEditText c; @Override // android.widget.TextView.OnEditorActionListener public final boolean onEditorAction(TextView textView, int i3, KeyEvent keyEvent) { return MwAmountEditText.c(this.c, i3); } { this.c = this; } }); setHandleDismissKeyboard(new IeS(this) { // from class: o.eCu private MwAmountEditText e; @Override // com.scb.phone.view.custom.common.MwAmountEditText.IeS public final void a() { MwAmountEditText.a(this.e); } { this.e = this; } }); } public void setCustomHint(String str, TextInputLayout textInputLayout) { this.h = textInputLayout; this.a = str; textInputLayout.setHint(str); } public void setCustomHint(String str) { this.a = str; setHint(str); } public void setCurrencyFormattingTextWatcher(fLM flm) { removeTextChangedListener(this.d); flm.b(new C10395eCv(this)); this.d = flm; addTextChangedListener(flm); } @Override // android.widget.TextView, android.view.View protected void onFocusChanged(boolean z, int i, Rect rect) { String b; String b2; super.onFocusChanged(z, i, rect); if (TextUtils.isEmpty(this.a) || (this.a.equalsIgnoreCase(this.l) && !z)) { if (C6583cXR.q(getText().toString())) { if (this.c != 0.0d) { this.c = 0.0d; Sts sts = this.i; if (sts != null) { sts.c(0.0d); } } if (!getText().toString().isEmpty()) { if (this.j) { b2 = (String) C6583cXR.c(new Object[]{Double.valueOf(0.0d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b2 = C6583cXR.b(0.0d); } setFormattedAmount(b2); } this.d.aAL_(getEditableText(), false); return; } if (TextUtils.isEmpty(getText().toString())) { return; } double d = this.c; if (this.j) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } setFormattedAmount(b); } } public void setFormattedAmount(String str) { if (str.isEmpty()) { setText(""); return; } setFilters(new InputFilter[0]); setText(str); setCurrencyFormattingTextWatcher(this.d); setFilters(this.e); } @Override // android.widget.TextView, android.view.View public boolean onKeyPreIme(int i, KeyEvent keyEvent) { String b; if (i == 4 && keyEvent.getAction() == 1) { if (TextUtils.isEmpty(getText())) { this.c = 0.0d; } else { double d = this.c; if (this.j) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } setFormattedAmount(b); } IeS ieS = this.b; if (ieS == null) { return false; } ieS.a(); this.d.d(); return false; } return super.onKeyPreIme(i, keyEvent); } @Override // android.view.View public boolean dispatchKeyEvent(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == 67 && keyEvent.getAction() == 1) { if (!TextUtils.isEmpty(getText())) { return false; } this.c = 0.0d; return false; } return super.dispatchKeyEvent(keyEvent); } public void setInvalidAmount(boolean z) { if (z) { getBackground().mutate().setColorFilter(ofu.oz_(R.color.f13582131100866, EnumC0706MsT.SRC_ATOP)); } else if (!hasFocus()) { getBackground().mutate().setColorFilter(ofu.oz_(R.color.f13772131100885, EnumC0706MsT.SRC_ATOP)); } else { getBackground().mutate().setColorFilter(ofu.oz_(R.color.f2112131099717, EnumC0706MsT.SRC_ATOP)); } } public void setMaximumDecimalDigit(int i) { InputFilter[] inputFilterArr = {new fLN(i)}; this.e = inputFilterArr; setFilters(inputFilterArr); } @Override // androidx.appcompat.widget.AppCompatEditText, android.widget.EditText, android.widget.TextView public boolean onTextContextMenuItem(int i) { ClipData primaryClip; RVV rvv; if (i == 16908322 && (primaryClip = ((ClipboardManager) getContext().getSystemService("clipboard")).getPrimaryClip()) != null && (rvv = this.g) != null) { primaryClip.getItemAt(0).coerceToText(getContext()); return rvv.c(); } return super.onTextContextMenuItem(i); } public static /* synthetic */ boolean c(MwAmountEditText mwAmountEditText, int i) { String b; if (i != 6) { return false; } mwAmountEditText.clearFocus(); Sts sts = mwAmountEditText.i; if (sts != null) { sts.c(); } if (TextUtils.isEmpty(mwAmountEditText.getText())) { return true; } double d = mwAmountEditText.c; if (mwAmountEditText.j) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } mwAmountEditText.setFormattedAmount(b); return true; } public static /* synthetic */ void e(MwAmountEditText mwAmountEditText, double d) { if (mwAmountEditText.c != d) { mwAmountEditText.c = d; Sts sts = mwAmountEditText.i; if (sts != null) { sts.c(d); } } } public static /* synthetic */ void a(MwAmountEditText mwAmountEditText) { LWm lWm = mwAmountEditText.f; if (lWm != null) { lWm.c(); } } public void setOnPasteListener(RVV rvv) { this.g = rvv; } public void setOnHandleDismissKeyboardListener(LWm lWm) { this.f = lWm; } public void setOnAmountChangeListener(Sts sts) { this.i = sts; } public void setHandleDismissKeyboard(IeS ieS) { this.b = ieS; } }