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.Editable; 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.AmountEditText; import o.C10341eBc; import o.C10342eBd; import o.C15715hv; import o.C6583cXR; import o.Tlu; import o.fLM; import o.fLN; import o.nMh; /* loaded from: classes5.dex */ public class AmountEditText extends TextInputEditText { public fLM a; public String b; public String c; private InputFilter[] d; public double e; private LWm f; private TextInputLayout g; private RVV h; private Sts i; private IeS j; /* renamed from: o */ private boolean f8016o; /* loaded from: classes5.dex */ public interface IeS { void e(); } /* loaded from: classes5.dex */ public interface LWm { void d(); } /* loaded from: classes5.dex */ public interface RVV { void a(); void b(double d); } /* loaded from: classes5.dex */ public interface Sts { boolean c(AmountEditText amountEditText, String str); } public AmountEditText(Context context) { this(context, null); } public AmountEditText(Context context, AttributeSet attributeSet) { this(context, attributeSet, R.attr.editTextStyle); } public AmountEditText(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.f8016o = true; this.a = new fLM(this, new C10342eBd(this)); this.b = 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.b = obtainStyledAttributes.getString(0); } this.f8016o = obtainStyledAttributes.getBoolean(2, true); obtainStyledAttributes.recycle(); } setHint(this.b); InputFilter[] inputFilterArr = {new fLN(i2 < 0 ? 10 : i2, this.f8016o ? 2 : 0)}; this.d = inputFilterArr; setFilters(inputFilterArr); addTextChangedListener(this.a); setOnEditorActionListener(new TextView.OnEditorActionListener(this) { // from class: o.eAV private AmountEditText c; @Override // android.widget.TextView.OnEditorActionListener public final boolean onEditorAction(TextView textView, int i3, KeyEvent keyEvent) { return AmountEditText.e(this.c, i3); } { this.c = this; } }); setHandleDismissKeyboard(new C10341eBc(this)); } public void setCustomHint(String str) { this.c = str; setHint(str); } public void setCustomHint(String str, TextInputLayout textInputLayout) { this.g = textInputLayout; this.c = str; textInputLayout.setHint(str); } public void setCurrencyFormattingTextWatcher(fLM flm) { removeTextChangedListener(this.a); flm.b(new C10342eBd(this)); this.a = flm; addTextChangedListener(flm); } @Override // android.widget.TextView, android.view.View protected void onFocusChanged(boolean z, int i, Rect rect) { String b; super.onFocusChanged(z, i, rect); Editable text = getText(); if (TextUtils.isEmpty(this.c) || this.c.equalsIgnoreCase(this.b)) { if (z) { TextInputLayout textInputLayout = this.g; if (textInputLayout != null) { textInputLayout.setHintEnabled(false); } setHint(""); return; } if (C6583cXR.Wd_(text)) { TextInputLayout textInputLayout2 = this.g; if (textInputLayout2 != null) { textInputLayout2.setHintEnabled(true); } setText(""); setHint(this.b); this.a.aAL_(getEditableText(), true); return; } if (TextUtils.isEmpty(text)) { return; } double d = this.e; if (this.f8016o) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } setFormattedAmount(b); } } @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.e = 0.0d; } else { double d = this.e; if (this.f8016o) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } setFormattedAmount(b); } LWm lWm = this.f; if (lWm == null) { return false; } lWm.d(); return false; } return super.onKeyPreIme(i, keyEvent); } @Override // android.view.View public boolean dispatchKeyEvent(KeyEvent keyEvent) { String b; if (keyEvent.getKeyCode() == 67 && keyEvent.getAction() == 1) { if (!TextUtils.isEmpty(getText())) { return false; } this.e = 0.0d; if (0.0d != 0.0d) { this.e = 0.0d; RVV rvv = this.h; if (rvv != null) { rvv.b(0.0d); } } double d = this.e; if (this.f8016o) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } setFormattedAmount(b); return false; } return super.dispatchKeyEvent(keyEvent); } public void setAvailableBalanceCurrencyFormattingTextWatcher(double d) { fLM flm = this.a; if (flm != null) { flm.a(d); } } public void setMinAmountCurrencyFormattingTextWatcher(double d, String str) { fLM flm = this.a; if (flm != null) { flm.a(d, str); } } public void setFormattedAmount(String str) { if (C6583cXR.q(str)) { setText(""); return; } setFilters(new InputFilter[0]); setText(str); setCurrencyFormattingTextWatcher(this.a); setFilters(this.d); } public void setInvalidAmount(boolean z) { if (z) { Tlu.pE_(getBackground().mutate(), nMh.getColor(getContext(), R.color.f13582131100866)); } else if (!hasFocus()) { Tlu.pE_(getBackground().mutate(), nMh.getColor(getContext(), R.color.f13772131100885)); } else { Tlu.pE_(getBackground().mutate(), nMh.getColor(getContext(), R.color.f2112131099717)); } } @Override // androidx.appcompat.widget.AppCompatEditText, android.widget.EditText, android.widget.TextView public boolean onTextContextMenuItem(int i) { ClipData primaryClip; Sts sts; if (i == 16908322 && (primaryClip = ((ClipboardManager) getContext().getSystemService("clipboard")).getPrimaryClip()) != null && (sts = this.i) != null) { return sts.c(this, primaryClip.getItemAt(0).coerceToText(getContext()).toString()); } return super.onTextContextMenuItem(i); } public void setMaximumDecimalDigit(int i) { InputFilter[] inputFilterArr = {new fLN(i)}; this.d = inputFilterArr; setFilters(inputFilterArr); } /* loaded from: classes5.dex */ public static class HBt implements Sts { @Override // com.scb.phone.view.custom.common.AmountEditText.Sts public final boolean c(AmountEditText amountEditText, String str) { amountEditText.setText(C6583cXR.n(str)); return true; } } public static /* synthetic */ boolean e(AmountEditText amountEditText, int i) { String b; if (i != 6) { return false; } RVV rvv = amountEditText.h; if (rvv != null) { rvv.a(); } amountEditText.clearFocus(); if (TextUtils.isEmpty(amountEditText.getText())) { return true; } double d = amountEditText.e; if (amountEditText.f8016o) { b = (String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()); } else { b = C6583cXR.b(d); } amountEditText.setFormattedAmount(b); return true; } public static /* synthetic */ void d(AmountEditText amountEditText, double d) { if (amountEditText.e != d) { amountEditText.e = d; RVV rvv = amountEditText.h; if (rvv != null) { rvv.b(d); } } } public static /* synthetic */ void b(AmountEditText amountEditText) { IeS ieS = amountEditText.j; if (ieS != null) { ieS.e(); } } public void setOnPasteListener(Sts sts) { this.i = sts; } public void setOnHandleDismissKeyboardListener(IeS ieS) { this.j = ieS; } public void setOnAmountChangeListener(RVV rvv) { this.h = rvv; } public void setHandleDismissKeyboard(LWm lWm) { this.f = lWm; } }