what-the-bank/sources/com/google/android/material/button/MaterialButton.java

745 lines
22 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.material.button;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.Layout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.Checkable;
import android.widget.CompoundButton;
import androidx.appcompat.widget.AppCompatButton;
import androidx.core.view.ViewCompat;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.util.Iterator;
import java.util.LinkedHashSet;
import o.AgY;
import o.C0459HUs;
import o.C17052tZT;
import o.C17525xWe;
import o.C4363bXv;
import o.DjZ;
import o.FLD;
import o.Jaq;
import o.Lot;
import o.Tlu;
import o.URz;
import o.Vdh;
import o.XgG;
/* loaded from: classes2.dex */
public class MaterialButton extends AppCompatButton implements Checkable, Jaq {
String a;
LWm b;
public int c;
final DjZ d;
public Drawable e;
private boolean f;
private boolean h;
private int k;
private int l;
private PorterDuff.Mode m;
private ColorStateList n;
/* renamed from: o, reason: collision with root package name */
private int f6469o;
private int p;
private final LinkedHashSet<Sts> q;
private static final int[] j = {R.attr.state_checkable};
private static final int[] i = {R.attr.state_checked};
private static final int g = C17052tZT.NHB.Widget_MaterialComponents_Button;
/* loaded from: classes2.dex */
interface LWm {
void a();
}
/* loaded from: classes2.dex */
public interface Sts {
}
public MaterialButton(Context context) {
this(context, null);
}
public MaterialButton(Context context, AttributeSet attributeSet) {
this(context, attributeSet, C17052tZT.IeS.materialButtonStyle);
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public MaterialButton(android.content.Context r10, android.util.AttributeSet r11, int r12) {
/*
Method dump skipped, instructions count: 387
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.button.MaterialButton.<init>(android.content.Context, android.util.AttributeSet, int):void");
}
private String b() {
if (!TextUtils.isEmpty(this.a)) {
return this.a;
}
DjZ djZ = this.d;
return ((djZ == null || !djZ.b) ? Button.class : CompoundButton.class).getName();
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setClassName(b());
DjZ djZ = this.d;
accessibilityNodeInfo.setCheckable(djZ != null && djZ.b);
accessibilityNodeInfo.setChecked(isChecked());
accessibilityNodeInfo.setClickable(isClickable());
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(accessibilityEvent);
accessibilityEvent.setClassName(b());
accessibilityEvent.setChecked(isChecked());
}
@Override // android.widget.TextView, android.view.View
public Parcelable onSaveInstanceState() {
HBt hBt = new HBt(super.onSaveInstanceState());
hBt.c = this.f;
return hBt;
}
@Override // android.widget.TextView, android.view.View
public void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof HBt)) {
super.onRestoreInstanceState(parcelable);
return;
}
HBt hBt = (HBt) parcelable;
super.onRestoreInstanceState(hBt.b);
setChecked(hBt.c);
}
@Override // androidx.appcompat.widget.AppCompatButton
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
DjZ djZ = this.d;
if (djZ != null && !djZ.d) {
DjZ djZ2 = this.d;
if (djZ2.c != colorStateList) {
djZ2.c = colorStateList;
if (djZ2.e(false) != null) {
Tlu.pF_(djZ2.e(false), djZ2.c);
return;
}
return;
}
return;
}
super.setSupportBackgroundTintList(colorStateList);
}
@Override // androidx.appcompat.widget.AppCompatButton
public ColorStateList getSupportBackgroundTintList() {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return super.getSupportBackgroundTintList();
}
return this.d.c;
}
@Override // androidx.appcompat.widget.AppCompatButton
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
DjZ djZ = this.d;
if (djZ != null && !djZ.d) {
DjZ djZ2 = this.d;
if (djZ2.a != mode) {
djZ2.a = mode;
if (djZ2.e(false) == null || djZ2.a == null) {
return;
}
Tlu.pG_(djZ2.e(false), djZ2.a);
return;
}
return;
}
super.setSupportBackgroundTintMode(mode);
}
@Override // androidx.appcompat.widget.AppCompatButton
public PorterDuff.Mode getSupportBackgroundTintMode() {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return super.getSupportBackgroundTintMode();
}
return this.d.a;
}
@Override // android.view.View
public void setBackgroundTintList(ColorStateList colorStateList) {
setSupportBackgroundTintList(colorStateList);
}
@Override // android.view.View
public ColorStateList getBackgroundTintList() {
return getSupportBackgroundTintList();
}
@Override // android.view.View
public void setBackgroundTintMode(PorterDuff.Mode mode) {
setSupportBackgroundTintMode(mode);
}
@Override // android.view.View
public PorterDuff.Mode getBackgroundTintMode() {
return getSupportBackgroundTintMode();
}
@Override // android.view.View
public void setBackgroundColor(int i2) {
DjZ djZ = this.d;
if (djZ != null && !djZ.d) {
DjZ djZ2 = this.d;
if (djZ2.e(false) != null) {
djZ2.e(false).setTint(i2);
return;
}
return;
}
super.setBackgroundColor(i2);
}
@Override // android.view.View
public void setBackground(Drawable drawable) {
setBackgroundDrawable(drawable);
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public void setBackgroundResource(int i2) {
setBackgroundDrawable(i2 != 0 ? AgY.dT_(getContext(), i2) : null);
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public void setBackgroundDrawable(Drawable drawable) {
DjZ djZ = this.d;
if (djZ != null && !djZ.d) {
if (drawable != getBackground()) {
this.d.e();
} else {
getBackground().setState(drawable.getState());
return;
}
}
super.setBackgroundDrawable(drawable);
}
@Override // androidx.appcompat.widget.AppCompatButton, android.widget.TextView, android.view.View
public void onLayout(boolean z, int i2, int i3, int i4, int i5) {
super.onLayout(z, i2, i3, i4, i5);
c(getMeasuredWidth(), getMeasuredHeight());
}
@Override // androidx.appcompat.widget.AppCompatButton, android.widget.TextView
public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
super.onTextChanged(charSequence, i2, i3, i4);
c(getMeasuredWidth(), getMeasuredHeight());
}
@Override // android.widget.TextView, android.view.View
public void onAttachedToWindow() {
super.onAttachedToWindow();
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
C4363bXv e = this.d.e(false);
if (e.B.c == null || !e.B.c.a) {
return;
}
e.k(Lot.e(this));
}
@Override // android.view.View
public void setElevation(float f) {
super.setElevation(f);
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
this.d.e(false).n(f);
}
@Override // android.view.View
public void refreshDrawableState() {
super.refreshDrawableState();
if (this.e != null) {
if (this.e.setState(getDrawableState())) {
invalidate();
}
}
}
@Override // android.view.View
public void setTextAlignment(int i2) {
super.setTextAlignment(i2);
c(getMeasuredWidth(), getMeasuredHeight());
}
private void c(int i2, int i3) {
Layout.Alignment alignment;
int min;
if (this.e == null || getLayout() == null) {
return;
}
int i4 = this.l;
if (i4 != 1 && i4 != 2 && i4 != 3 && i4 != 4) {
if (i4 == 16 || i4 == 32) {
this.k = 0;
if (i4 == 16) {
this.p = 0;
c(false);
return;
}
int i5 = this.c;
if (i5 == 0) {
i5 = this.e.getIntrinsicHeight();
}
if (getLineCount() > 1) {
min = getLayout().getHeight();
} else {
TextPaint paint = getPaint();
String obj = getText().toString();
if (getTransformationMethod() != null) {
obj = getTransformationMethod().getTransformation(obj, this).toString();
}
Rect rect = new Rect();
paint.getTextBounds(obj, 0, obj.length(), rect);
min = Math.min(rect.height(), getLayout().getHeight());
}
int max = Math.max(0, (((((i3 - min) - getPaddingTop()) - i5) - this.f6469o) - getPaddingBottom()) / 2);
if (this.p != max) {
this.p = max;
c(false);
return;
}
return;
}
return;
}
this.p = 0;
int textAlignment = getTextAlignment();
if (textAlignment == 1) {
int gravity = getGravity() & 8388615;
if (gravity == 1) {
alignment = Layout.Alignment.ALIGN_CENTER;
} else if (gravity == 5 || gravity == 8388613) {
alignment = Layout.Alignment.ALIGN_OPPOSITE;
} else {
alignment = Layout.Alignment.ALIGN_NORMAL;
}
} else if (textAlignment == 6 || textAlignment == 3) {
alignment = Layout.Alignment.ALIGN_OPPOSITE;
} else if (textAlignment == 4) {
alignment = Layout.Alignment.ALIGN_CENTER;
} else {
alignment = Layout.Alignment.ALIGN_NORMAL;
}
int i6 = this.l;
if (i6 == 1 || i6 == 3 || ((i6 == 2 && alignment == Layout.Alignment.ALIGN_NORMAL) || (this.l == 4 && alignment == Layout.Alignment.ALIGN_OPPOSITE))) {
this.k = 0;
c(false);
return;
}
int i7 = this.c;
if (i7 == 0) {
i7 = this.e.getIntrinsicWidth();
}
int lineCount = getLineCount();
float f = BitmapDescriptorFactory.HUE_RED;
for (int i8 = 0; i8 < lineCount; i8++) {
f = Math.max(f, getLayout().getLineWidth(i8));
}
int ceil = ((((i2 - ((int) Math.ceil(f))) - ViewCompat.r(this)) - i7) - this.f6469o) - ViewCompat.q(this);
if (alignment == Layout.Alignment.ALIGN_CENTER) {
ceil /= 2;
}
if ((ViewCompat.m(this) == 1) != (this.l == 4)) {
ceil = -ceil;
}
if (this.k != ceil) {
this.k = ceil;
c(false);
}
}
public final void Il_(Drawable drawable) {
super.setBackgroundDrawable(drawable);
}
public void setIconPadding(int i2) {
if (this.f6469o != i2) {
this.f6469o = i2;
setCompoundDrawablePadding(i2);
}
}
public void setIconSize(int i2) {
if (i2 < 0) {
throw new IllegalArgumentException("iconSize cannot be less than 0");
}
if (this.c != i2) {
this.c = i2;
c(true);
}
}
public void setIcon(Drawable drawable) {
if (this.e != drawable) {
this.e = drawable;
c(true);
c(getMeasuredWidth(), getMeasuredHeight());
}
}
public void setIconResource(int i2) {
setIcon(i2 != 0 ? AgY.dT_(getContext(), i2) : null);
}
public void setIconTint(ColorStateList colorStateList) {
if (this.n != colorStateList) {
this.n = colorStateList;
c(false);
}
}
public void setIconTintResource(int i2) {
setIconTint(AgY.dS_(getContext(), i2));
}
public void setIconTintMode(PorterDuff.Mode mode) {
if (this.m != mode) {
this.m = mode;
c(false);
}
}
private void c(boolean z) {
Drawable drawable = this.e;
if (drawable != null) {
Drawable mutate = Tlu.pI_(drawable).mutate();
this.e = mutate;
Tlu.pF_(mutate, this.n);
PorterDuff.Mode mode = this.m;
if (mode != null) {
Tlu.pG_(this.e, mode);
}
int i2 = this.c;
if (i2 == 0) {
i2 = this.e.getIntrinsicWidth();
}
int i3 = this.c;
if (i3 == 0) {
i3 = this.e.getIntrinsicHeight();
}
Drawable drawable2 = this.e;
int i4 = this.k;
int i5 = this.p;
drawable2.setBounds(i4, i5, i2 + i4, i3 + i5);
this.e.setVisible(true, z);
}
if (z) {
d();
return;
}
Drawable[] vO_ = URz.vO_(this);
Drawable drawable3 = vO_[0];
Drawable drawable4 = vO_[1];
Drawable drawable5 = vO_[2];
int i6 = this.l;
if (((i6 == 1 || i6 == 2) && drawable3 != this.e) || (((i6 == 3 || i6 == 4) && drawable5 != this.e) || ((i6 == 16 || i6 == 32) && drawable4 != this.e))) {
d();
}
}
public void setRippleColor(ColorStateList colorStateList) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
DjZ djZ2 = this.d;
if (djZ2.n != colorStateList) {
djZ2.n = colorStateList;
boolean z = DjZ.e;
if (z && (djZ2.m.getBackground() instanceof RippleDrawable)) {
((RippleDrawable) djZ2.m.getBackground()).setColor(C0459HUs.KI_(colorStateList));
} else {
if (z || !(djZ2.m.getBackground() instanceof Vdh)) {
return;
}
((Vdh) djZ2.m.getBackground()).setTintList(C0459HUs.KI_(colorStateList));
}
}
}
public void setRippleColorResource(int i2) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
setRippleColor(AgY.dS_(getContext(), i2));
}
public void setStrokeColor(ColorStateList colorStateList) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
DjZ djZ2 = this.d;
if (djZ2.q != colorStateList) {
djZ2.q = colorStateList;
djZ2.a();
}
}
public void setStrokeColorResource(int i2) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
setStrokeColor(AgY.dS_(getContext(), i2));
}
public void setStrokeWidth(int i2) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
DjZ djZ2 = this.d;
if (djZ2.p != i2) {
djZ2.p = i2;
djZ2.a();
}
}
public void setStrokeWidthResource(int i2) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
setStrokeWidth(getResources().getDimensionPixelSize(i2));
}
public final int e() {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return 0;
}
return this.d.p;
}
public void setCornerRadius(int i2) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
DjZ djZ2 = this.d;
if (djZ2.f && djZ2.j == i2) {
return;
}
djZ2.j = i2;
djZ2.f = true;
float f = i2;
FLD.RVV rvv = new FLD.RVV(djZ2.l);
rvv.f = new C17525xWe(f);
rvv.k = new C17525xWe(f);
rvv.d = new C17525xWe(f);
rvv.e = new C17525xWe(f);
FLD fld = new FLD(rvv, (byte) 0);
djZ2.l = fld;
djZ2.c(fld);
}
public void setCornerRadiusResource(int i2) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
setCornerRadius(getResources().getDimensionPixelSize(i2));
}
public void setIconGravity(int i2) {
if (this.l != i2) {
this.l = i2;
c(getMeasuredWidth(), getMeasuredHeight());
}
}
public void setInsetBottom(int i2) {
DjZ djZ = this.d;
djZ.a(djZ.k, i2);
}
public void setInsetTop(int i2) {
DjZ djZ = this.d;
djZ.a(i2, djZ.h);
}
@Override // android.widget.TextView, android.view.View
protected int[] onCreateDrawableState(int i2) {
int[] onCreateDrawableState = super.onCreateDrawableState(i2 + 2);
DjZ djZ = this.d;
if (djZ != null && djZ.b) {
mergeDrawableStates(onCreateDrawableState, j);
}
if (isChecked()) {
mergeDrawableStates(onCreateDrawableState, i);
}
return onCreateDrawableState;
}
@Override // android.widget.Checkable
public void setChecked(boolean z) {
DjZ djZ = this.d;
if (djZ == null || !djZ.b || !isEnabled() || this.f == z) {
return;
}
this.f = z;
refreshDrawableState();
if (getParent() instanceof MaterialButtonToggleGroup) {
MaterialButtonToggleGroup materialButtonToggleGroup = (MaterialButtonToggleGroup) getParent();
boolean z2 = this.f;
if (!materialButtonToggleGroup.d) {
materialButtonToggleGroup.b(getId(), z2);
}
}
if (this.h) {
return;
}
this.h = true;
Iterator<Sts> it = this.q.iterator();
while (it.hasNext()) {
it.next();
}
this.h = false;
}
@Override // android.widget.Checkable
public void toggle() {
setChecked(!this.f);
}
public void setCheckable(boolean z) {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
return;
}
this.d.b = z;
}
@Override // o.Jaq
public void setShapeAppearanceModel(FLD fld) {
DjZ djZ = this.d;
if (djZ != null && !djZ.d) {
DjZ djZ2 = this.d;
djZ2.l = fld;
djZ2.c(fld);
return;
}
throw new IllegalStateException("Attempted to set ShapeAppearanceModel on a MaterialButton which has an overwritten background.");
}
public final FLD c() {
DjZ djZ = this.d;
if (djZ == null || djZ.d) {
throw new IllegalStateException("Attempted to get ShapeAppearanceModel from a MaterialButton which has an overwritten background.");
}
return this.d.l;
}
@Override // android.view.View
public void setPressed(boolean z) {
LWm lWm = this.b;
if (lWm != null) {
lWm.a();
}
super.setPressed(z);
}
/* loaded from: classes2.dex */
static class HBt extends XgG {
public static final Parcelable.Creator<HBt> CREATOR = new Parcelable.ClassLoaderCreator<HBt>() { // from class: com.google.android.material.button.MaterialButton.HBt.2
@Override // android.os.Parcelable.Creator
public final /* synthetic */ Object createFromParcel(Parcel parcel) {
return new HBt(parcel, null);
}
@Override // android.os.Parcelable.ClassLoaderCreator
public final /* synthetic */ HBt createFromParcel(Parcel parcel, ClassLoader classLoader) {
return new HBt(parcel, classLoader);
}
@Override // android.os.Parcelable.Creator
public final /* bridge */ /* synthetic */ Object[] newArray(int i) {
return new HBt[i];
}
};
boolean c;
public HBt(Parcelable parcelable) {
super(parcelable);
}
public HBt(Parcel parcel, ClassLoader classLoader) {
super(parcel, classLoader);
this.c = parcel.readInt() == 1;
}
@Override // o.XgG, android.os.Parcelable
public final void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(this.c ? 1 : 0);
}
}
private void d() {
int i2 = this.l;
if (i2 == 1 || i2 == 2) {
URz.vZ_(this, this.e, null, null, null);
return;
}
if (i2 == 3 || i2 == 4) {
URz.vZ_(this, null, null, this.e, null);
} else if (i2 == 16 || i2 == 32) {
URz.vZ_(this, null, this.e, null, null);
}
}
@Override // android.view.View
public boolean performClick() {
if (this.d.t) {
toggle();
}
return super.performClick();
}
public void setToggleCheckedStateOnClick(boolean z) {
this.d.t = z;
}
@Override // android.widget.Checkable
public boolean isChecked() {
return this.f;
}
}