what-the-bank/sources/com/google/android/material/textfield/EndCompoundLayout.java

606 lines
23 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.material.textfield;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Base64;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.view.ViewCompat;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.textfield.TextInputLayout;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.LinkedHashSet;
import o.AgY;
import o.C0683McA;
import o.C14739fyr;
import o.C15896jTh;
import o.C15977kAW;
import o.C17052tZT;
import o.CYM;
import o.GES;
import o.Lot;
import o.QAo;
import o.SQv;
import o.THi;
import o.Tlu;
import o.URz;
import o.cLR;
import o.mRi;
import o.pAW;
/* loaded from: classes2.dex */
public class EndCompoundLayout extends LinearLayout {
private static int A = 1;
private static byte u = 6;
private static int y;
final HBt a;
EditText b;
public final FrameLayout c;
final AccessibilityManager d;
final TextWatcher e;
public View.OnLongClickListener f;
ColorStateList g;
PorterDuff.Mode h;
ImageView.ScaleType i;
int j;
final CheckableImageButton k;
ColorStateList l;
PorterDuff.Mode m;
View.OnLongClickListener n;
/* renamed from: o, reason: collision with root package name */
public final CheckableImageButton f6484o;
QAo.LWm p;
final TextView q;
boolean r;
public final TextInputLayout s;
public CharSequence t;
private final TextInputLayout.HBt v;
private final LinkedHashSet<TextInputLayout.LWm> w;
private int x;
private void z(String str, Object[] objArr) {
byte[] decode = Base64.decode(str, 0);
byte[] bArr = new byte[decode.length];
for (int i = 0; i < decode.length; i++) {
bArr[i] = (byte) (decode[(decode.length - i) - 1] ^ u);
}
objArr[0] = new String(bArr, StandardCharsets.UTF_8);
}
/* JADX INFO: Access modifiers changed from: package-private */
public EndCompoundLayout(TextInputLayout textInputLayout, C0683McA c0683McA) {
super(textInputLayout.getContext());
this.j = 0;
this.w = new LinkedHashSet<>();
this.e = new GES(this) { // from class: com.google.android.material.textfield.EndCompoundLayout.3
private EndCompoundLayout c;
{
this.c = this;
}
@Override // o.GES, android.text.TextWatcher
public final void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
EndCompoundLayout endCompoundLayout = this.c;
endCompoundLayout.a.d(endCompoundLayout.j).q();
}
@Override // o.GES, android.text.TextWatcher
public final void afterTextChanged(Editable editable) {
EndCompoundLayout endCompoundLayout = this.c;
endCompoundLayout.a.d(endCompoundLayout.j).e();
}
};
TextInputLayout.HBt hBt = new TextInputLayout.HBt(this) { // from class: com.google.android.material.textfield.EndCompoundLayout.1
private EndCompoundLayout e;
{
this.e = this;
}
@Override // com.google.android.material.textfield.TextInputLayout.HBt
public final void c(TextInputLayout textInputLayout2) {
if (this.e.b == textInputLayout2.f) {
return;
}
if (this.e.b != null) {
this.e.b.removeTextChangedListener(this.e.e);
View.OnFocusChangeListener onFocusChangeListener = this.e.b.getOnFocusChangeListener();
EndCompoundLayout endCompoundLayout = this.e;
if (onFocusChangeListener == endCompoundLayout.a.d(endCompoundLayout.j).Mj_()) {
this.e.b.setOnFocusChangeListener(null);
}
}
this.e.b = textInputLayout2.f;
if (this.e.b != null) {
this.e.b.addTextChangedListener(this.e.e);
}
EndCompoundLayout endCompoundLayout2 = this.e;
endCompoundLayout2.a.d(endCompoundLayout2.j).Mz_(this.e.b);
EndCompoundLayout endCompoundLayout3 = this.e;
endCompoundLayout3.a(endCompoundLayout3.a.d(endCompoundLayout3.j));
}
};
this.v = hBt;
this.d = (AccessibilityManager) getContext().getSystemService("accessibility");
this.s = textInputLayout;
setVisibility(8);
setOrientation(0);
setLayoutParams(new FrameLayout.LayoutParams(-2, -1, 8388613));
FrameLayout frameLayout = new FrameLayout(getContext());
this.c = frameLayout;
frameLayout.setVisibility(8);
frameLayout.setLayoutParams(new LinearLayout.LayoutParams(-2, -1));
LayoutInflater from = LayoutInflater.from(getContext());
CheckableImageButton Mg_ = Mg_(this, from, C17052tZT.ZqN.text_input_error_icon);
this.k = Mg_;
CheckableImageButton Mg_2 = Mg_(frameLayout, from, C17052tZT.ZqN.text_input_end_icon);
this.f6484o = Mg_2;
this.a = new HBt(this, c0683McA);
AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
this.q = appCompatTextView;
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_errorIconTint)) {
this.l = C14739fyr.Kv_(getContext(), c0683McA, C17052tZT.jNh.TextInputLayout_errorIconTint);
}
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_errorIconTintMode)) {
this.m = Lot.Kf_(c0683McA.d.getInt(C17052tZT.jNh.TextInputLayout_errorIconTintMode, -1), null);
}
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_errorIconDrawable)) {
Mi_(c0683McA.jL_(C17052tZT.jNh.TextInputLayout_errorIconDrawable));
}
Mg_.setContentDescription(getResources().getText(C17052tZT.ojQ.error_icon_content_description));
ViewCompat.g(Mg_, 2);
Mg_.setClickable(false);
Mg_.setPressable(false);
Mg_.setFocusable(false);
if (!c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_passwordToggleEnabled)) {
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_endIconTint)) {
this.g = C14739fyr.Kv_(getContext(), c0683McA, C17052tZT.jNh.TextInputLayout_endIconTint);
}
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_endIconTintMode)) {
this.h = Lot.Kf_(c0683McA.d.getInt(C17052tZT.jNh.TextInputLayout_endIconTintMode, -1), null);
}
}
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_endIconMode)) {
a(c0683McA.d.getInt(C17052tZT.jNh.TextInputLayout_endIconMode, 0));
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_endIconContentDescription)) {
CharSequence text = c0683McA.d.getText(C17052tZT.jNh.TextInputLayout_endIconContentDescription);
if (Mg_2.getContentDescription() != text) {
Mg_2.setContentDescription(text);
}
}
Mg_2.setCheckable(c0683McA.d.getBoolean(C17052tZT.jNh.TextInputLayout_endIconCheckable, true));
} else {
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_passwordToggleEnabled)) {
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_passwordToggleTint)) {
this.g = C14739fyr.Kv_(getContext(), c0683McA, C17052tZT.jNh.TextInputLayout_passwordToggleTint);
}
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_passwordToggleTintMode)) {
this.h = Lot.Kf_(c0683McA.d.getInt(C17052tZT.jNh.TextInputLayout_passwordToggleTintMode, -1), null);
}
a(c0683McA.d.getBoolean(C17052tZT.jNh.TextInputLayout_passwordToggleEnabled, false) ? 1 : 0);
CharSequence text2 = c0683McA.d.getText(C17052tZT.jNh.TextInputLayout_passwordToggleContentDescription);
if (Mg_2.getContentDescription() != text2) {
Mg_2.setContentDescription(text2);
}
}
}
b(c0683McA.d.getDimensionPixelSize(C17052tZT.jNh.TextInputLayout_endIconMinSize, getResources().getDimensionPixelSize(C17052tZT.HBt.mtrl_min_touch_target_size)));
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_endIconScaleType)) {
ImageView.ScaleType Mp_ = C15977kAW.Mp_(c0683McA.d.getInt(C17052tZT.jNh.TextInputLayout_endIconScaleType, -1));
this.i = Mp_;
Mg_2.setScaleType(Mp_);
Mg_.setScaleType(Mp_);
}
appCompatTextView.setVisibility(8);
appCompatTextView.setId(C17052tZT.ZqN.textinput_suffix_text);
appCompatTextView.setLayoutParams(new LinearLayout.LayoutParams(-2, -2, 80.0f));
ViewCompat.c(appCompatTextView, 1);
URz.we_(appCompatTextView, c0683McA.d.getResourceId(C17052tZT.jNh.TextInputLayout_suffixTextAppearance, 0));
if (c0683McA.d.hasValue(C17052tZT.jNh.TextInputLayout_suffixTextColor)) {
appCompatTextView.setTextColor(c0683McA.jK_(C17052tZT.jNh.TextInputLayout_suffixTextColor));
}
CharSequence text3 = c0683McA.d.getText(C17052tZT.jNh.TextInputLayout_suffixText);
this.t = TextUtils.isEmpty(text3) ? null : text3;
appCompatTextView.setText(text3);
d();
frameLayout.addView(Mg_2);
addView(appCompatTextView);
addView(frameLayout);
addView(Mg_);
textInputLayout.g.add(hBt);
if (textInputLayout.f != null) {
hBt.c(textInputLayout);
}
addOnAttachStateChangeListener(new View.OnAttachStateChangeListener(this) { // from class: com.google.android.material.textfield.EndCompoundLayout.5
private EndCompoundLayout a;
{
this.a = this;
}
@Override // android.view.View.OnAttachStateChangeListener
public final void onViewAttachedToWindow(View view) {
this.a.b();
}
@Override // android.view.View.OnAttachStateChangeListener
public final void onViewDetachedFromWindow(View view) {
AccessibilityManager accessibilityManager;
EndCompoundLayout endCompoundLayout = this.a;
QAo.LWm lWm = endCompoundLayout.p;
if (lWm == null || (accessibilityManager = endCompoundLayout.d) == null) {
return;
}
QAo.tQ_(accessibilityManager, lWm);
}
});
}
private CheckableImageButton Mg_(ViewGroup viewGroup, LayoutInflater layoutInflater, int i) {
CheckableImageButton checkableImageButton = (CheckableImageButton) layoutInflater.inflate(C17052tZT.tOB.design_text_input_end_icon, viewGroup, false);
checkableImageButton.setId(i);
if (getContext().getResources().getConfiguration().fontScale >= 1.3f) {
CYM.rA_((ViewGroup.MarginLayoutParams) checkableImageButton.getLayoutParams(), 0);
}
return checkableImageButton;
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void Mi_(Drawable drawable) {
this.k.setImageDrawable(drawable);
f();
C15977kAW.Mo_(this.s, this.k, this.l, this.m);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void a(int i) {
int i2 = this.j;
if (i2 == i) {
return;
}
b(this.a.d(i2));
this.j = i;
i();
e(i != 0);
SQv d = this.a.d(this.j);
int i3 = this.a.e;
if (i3 == 0) {
i3 = d.c();
}
Mh_(i3 != 0 ? AgY.dT_(getContext(), i3) : null);
c(d.a());
this.f6484o.setCheckable(d.k());
if (!d.b(this.s.d)) {
StringBuilder sb = new StringBuilder("The current box background mode ");
sb.append(this.s.d);
sb.append(" is not supported by the end icon mode ");
sb.append(i);
throw new IllegalStateException(sb.toString());
}
d.g();
this.p = d.h();
b();
View.OnClickListener My_ = d.My_();
CheckableImageButton checkableImageButton = this.f6484o;
View.OnLongClickListener onLongClickListener = this.f;
checkableImageButton.setOnClickListener(My_);
C15977kAW.Mr_(checkableImageButton, onLongClickListener);
EditText editText = this.b;
if (editText != null) {
d.Mz_(editText);
a(d);
}
C15977kAW.Mo_(this.s, this.f6484o, this.g, this.h);
a(true);
}
public final void a(boolean z) {
boolean z2;
boolean isActivated;
boolean isChecked;
SQv d = this.a.d(this.j);
boolean z3 = true;
if (!d.k() || (isChecked = this.f6484o.isChecked()) == d.m()) {
z2 = false;
} else {
this.f6484o.setChecked(!isChecked);
z2 = true;
}
if (!d.n() || (isActivated = this.f6484o.isActivated()) == d.l()) {
z3 = z2;
} else {
this.f6484o.setActivated(!isActivated);
}
if (z || z3) {
C15977kAW.Mq_(this.s, this.f6484o, this.g);
}
}
private void b(SQv sQv) {
AccessibilityManager accessibilityManager;
QAo.LWm lWm = this.p;
if (lWm != null && (accessibilityManager = this.d) != null) {
QAo.tQ_(accessibilityManager, lWm);
}
this.p = null;
sQv.f();
}
final void b() {
if (this.p == null || this.d == null || !ViewCompat.H(this)) {
return;
}
QAo.tP_(this.d, this.p);
}
final void a(SQv sQv) {
if (this.b == null) {
return;
}
if (sQv.Mj_() != null) {
this.b.setOnFocusChangeListener(sQv.Mj_());
}
if (sQv.Ml_() != null) {
this.f6484o.setOnFocusChangeListener(sQv.Ml_());
}
}
public final void e(boolean z) {
if ((this.c.getVisibility() == 0 && this.f6484o.getVisibility() == 0) != z) {
this.f6484o.setVisibility(z ? 0 : 8);
g();
a();
this.s.d();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void Mh_(Drawable drawable) {
this.f6484o.setImageDrawable(drawable);
if (drawable != null) {
C15977kAW.Mo_(this.s, this.f6484o, this.g, this.h);
C15977kAW.Mq_(this.s, this.f6484o, this.g);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r2v5, types: [android.text.SpannableString, android.text.Spannable] */
public final void c(int i) {
String str;
int i2 = 2 % 2;
Object obj = null;
if (i != 0) {
Resources resources = getResources();
str = resources.getString(i);
if (str.startsWith(",*,)")) {
Object[] objArr = new Object[1];
z(str.substring(4), objArr);
str = ((String) objArr[0]).intern();
CharSequence text = resources.getText(i);
if (text instanceof Spanned) {
?? spannableString = new SpannableString(str);
TextUtils.copySpansFrom((SpannedString) text, 0, str.length(), Object.class, spannableString, 0);
str = spannableString;
}
}
int i3 = y + 121;
A = i3 % 128;
int i4 = i3 % 2;
} else {
int i5 = y + 125;
A = i5 % 128;
int i6 = i5 % 2;
str = null;
}
if (this.f6484o.getContentDescription() != str) {
this.f6484o.setContentDescription(str);
}
int i7 = y + 59;
A = i7 % 128;
if (i7 % 2 != 0) {
return;
}
obj.hashCode();
throw null;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r1v7, types: [android.text.SpannableString, android.text.Spannable] */
public final void e(int i) {
int i2 = 2 % 2;
int i3 = A + 17;
y = i3 % 128;
String str = null;
if (i3 % 2 != 0) {
str.hashCode();
throw null;
}
if (i != 0) {
Resources resources = getResources();
String string = resources.getString(i);
if (string.startsWith(",*,)")) {
int i4 = A + 35;
y = i4 % 128;
if (i4 % 2 != 0) {
String substring = string.substring(4);
Object[] objArr = new Object[1];
z(substring, objArr);
((String) objArr[0]).intern();
boolean z = resources.getText(i) instanceof Spanned;
str.hashCode();
throw null;
}
String substring2 = string.substring(4);
Object[] objArr2 = new Object[1];
z(substring2, objArr2);
str = ((String) objArr2[0]).intern();
CharSequence text = resources.getText(i);
if (text instanceof Spanned) {
?? spannableString = new SpannableString(str);
TextUtils.copySpansFrom((SpannedString) text, 0, str.length(), Object.class, spannableString, 0);
str = spannableString;
}
} else {
str = string;
}
int i5 = y + 69;
A = i5 % 128;
int i6 = i5 % 2;
}
this.f6484o.setContentDescription(str);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void c() {
f();
C15977kAW.Mq_(this.s, this.k, this.l);
C15977kAW.Mq_(this.s, this.f6484o, this.g);
if (this.a.d(this.j).o()) {
if (this.s.f6485o.c() && this.f6484o.getDrawable() != null) {
Drawable mutate = Tlu.pI_(this.f6484o.getDrawable()).mutate();
TextView textView = this.s.f6485o.h;
Tlu.pE_(mutate, textView != null ? textView.getCurrentTextColor() : -1);
this.f6484o.setImageDrawable(mutate);
return;
}
C15977kAW.Mo_(this.s, this.f6484o, this.g, this.h);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void d() {
int visibility = this.q.getVisibility();
int i = (this.t == null || this.r) ? 8 : 0;
if (visibility != i) {
this.a.d(this.j).e(i == 0);
}
g();
this.q.setVisibility(i);
this.s.d();
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void a() {
if (this.s.f == null) {
return;
}
ViewCompat.a(this.q, getContext().getResources().getDimensionPixelSize(C17052tZT.HBt.material_input_text_to_prefix_suffix_padding), this.s.f.getPaddingTop(), ((this.c.getVisibility() == 0 && this.f6484o.getVisibility() == 0) || this.k.getVisibility() == 0) ? 0 : ViewCompat.r(this.s.f), this.s.f.getPaddingBottom());
}
/* JADX INFO: Access modifiers changed from: package-private */
public final CheckableImageButton e() {
if (this.k.getVisibility() == 0) {
return this.k;
}
if (this.j != 0 && this.c.getVisibility() == 0 && this.f6484o.getVisibility() == 0) {
return this.f6484o;
}
return null;
}
private void f() {
this.k.setVisibility(this.k.getDrawable() != null && this.s.f6485o.c && this.s.f6485o.c() ? 0 : 8);
g();
a();
if (this.j != 0) {
return;
}
this.s.d();
}
private void g() {
this.c.setVisibility((this.f6484o.getVisibility() != 0 || this.k.getVisibility() == 0) ? 8 : 0);
setVisibility(((this.c.getVisibility() == 0 && this.f6484o.getVisibility() == 0) || this.k.getVisibility() == 0 || !((this.t == null || this.r) ? 8 : false)) ? 0 : 8);
}
private void i() {
Iterator<TextInputLayout.LWm> it = this.w.iterator();
while (it.hasNext()) {
it.next();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class HBt {
private final EndCompoundLayout a;
private final SparseArray<SQv> b = new SparseArray<>();
private final int c;
final int e;
HBt(EndCompoundLayout endCompoundLayout, C0683McA c0683McA) {
this.a = endCompoundLayout;
this.e = c0683McA.d.getResourceId(C17052tZT.jNh.TextInputLayout_endIconDrawable, 0);
this.c = c0683McA.d.getResourceId(C17052tZT.jNh.TextInputLayout_passwordToggleDrawable, 0);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final SQv d(int i) {
SQv sQv = this.b.get(i);
if (sQv != null) {
return sQv;
}
SQv a = a(i);
this.b.append(i, a);
return a;
}
private SQv a(int i) {
if (i == -1) {
return new C15896jTh(this.a);
}
if (i == 0) {
return new mRi(this.a);
}
if (i == 1) {
return new cLR(this.a, this.c);
}
if (i == 2) {
return new THi(this.a);
}
if (i == 3) {
return new pAW(this.a);
}
throw new IllegalArgumentException("Invalid end icon mode: ".concat(String.valueOf(i)));
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void b(int i) {
if (i < 0) {
throw new IllegalArgumentException("endIconSize cannot be less than 0");
}
if (i != this.x) {
this.x = i;
CheckableImageButton checkableImageButton = this.f6484o;
checkableImageButton.setMinimumWidth(i);
checkableImageButton.setMinimumHeight(i);
CheckableImageButton checkableImageButton2 = this.k;
checkableImageButton2.setMinimumWidth(i);
checkableImageButton2.setMinimumHeight(i);
}
}
}