Primer paso de la investigacion. Se aportan el .apk, las carpetas con el apk extraido y el apk descompilado. El archivo API_DOCUMENTATION.md es un archivo donde se anotaran los descubrimientos del funcionamiento de la API, y los .py son scripts para probar la funcionalidad de la API con los métodos que vayamos encontrando. Finalmente, los archivos .js son scripts de Frida para extraer informacion de la APP durante la ejecucion.

This commit is contained in:
2025-12-04 13:59:54 +01:00
parent f2fd1c3bf5
commit e0133d2ca2
10432 changed files with 1019085 additions and 1 deletions

View File

@@ -0,0 +1,795 @@
package com.google.android.material.button;
import C.w;
import D.h;
import E2.j;
import E2.k;
import E2.u;
import K2.a;
import O.X;
import a.AbstractC0105a;
import a.AbstractC0106b;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Parcelable;
import android.text.Layout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
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 com.google.android.gms.maps.model.BitmapDescriptorFactory;
import h2.AbstractC0379a;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.WeakHashMap;
import m3.d;
import p2.InterfaceC0552a;
import p2.b;
import p2.c;
import x2.m;
/* loaded from: classes3.dex */
public class MaterialButton extends AppCompatButton implements Checkable, u {
/* renamed from: r, reason: collision with root package name */
public static final int[] f5589r = {R.attr.state_checkable};
/* renamed from: s, reason: collision with root package name */
public static final int[] f5590s = {R.attr.state_checked};
/* renamed from: d, reason: collision with root package name */
public final c f5591d;
/* renamed from: e, reason: collision with root package name */
public final LinkedHashSet f5592e;
/* renamed from: f, reason: collision with root package name */
public InterfaceC0552a f5593f;
/* renamed from: g, reason: collision with root package name */
public PorterDuff.Mode f5594g;
public ColorStateList h;
public Drawable i;
/* renamed from: j, reason: collision with root package name */
public String f5595j;
/* renamed from: k, reason: collision with root package name */
public int f5596k;
/* renamed from: l, reason: collision with root package name */
public int f5597l;
/* renamed from: m, reason: collision with root package name */
public int f5598m;
/* renamed from: n, reason: collision with root package name */
public int f5599n;
/* renamed from: o, reason: collision with root package name */
public boolean f5600o;
public boolean p;
/* renamed from: q, reason: collision with root package name */
public int f5601q;
public MaterialButton(Context context, AttributeSet attributeSet) {
super(a.a(context, attributeSet, com.adif.elcanomovil.R.attr.materialButtonStyle, 2132018286), attributeSet, com.adif.elcanomovil.R.attr.materialButtonStyle);
this.f5592e = new LinkedHashSet();
this.f5600o = false;
this.p = false;
Context context2 = getContext();
TypedArray h = m.h(context2, attributeSet, AbstractC0379a.f6764l, com.adif.elcanomovil.R.attr.materialButtonStyle, 2132018286, new int[0]);
this.f5599n = h.getDimensionPixelSize(12, 0);
int i = h.getInt(15, -1);
PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
this.f5594g = m.j(i, mode);
this.h = AbstractC0105a.w(getContext(), h, 14);
this.i = AbstractC0105a.z(getContext(), h, 10);
this.f5601q = h.getInteger(11, 1);
this.f5596k = h.getDimensionPixelSize(13, 0);
c cVar = new c(this, k.b(context2, attributeSet, com.adif.elcanomovil.R.attr.materialButtonStyle, 2132018286).a());
this.f5591d = cVar;
cVar.f8124c = h.getDimensionPixelOffset(1, 0);
cVar.f8125d = h.getDimensionPixelOffset(2, 0);
cVar.f8126e = h.getDimensionPixelOffset(3, 0);
cVar.f8127f = h.getDimensionPixelOffset(4, 0);
if (h.hasValue(8)) {
int dimensionPixelSize = h.getDimensionPixelSize(8, -1);
cVar.f8128g = dimensionPixelSize;
float f2 = dimensionPixelSize;
j e4 = cVar.f8123b.e();
e4.f422e = new E2.a(f2);
e4.f423f = new E2.a(f2);
e4.f424g = new E2.a(f2);
e4.h = new E2.a(f2);
cVar.c(e4.a());
cVar.p = true;
}
cVar.h = h.getDimensionPixelSize(20, 0);
cVar.i = m.j(h.getInt(7, -1), mode);
cVar.f8129j = AbstractC0105a.w(getContext(), h, 6);
cVar.f8130k = AbstractC0105a.w(getContext(), h, 19);
cVar.f8131l = AbstractC0105a.w(getContext(), h, 16);
cVar.f8135q = h.getBoolean(5, false);
cVar.f8138t = h.getDimensionPixelSize(9, 0);
cVar.f8136r = h.getBoolean(21, true);
WeakHashMap weakHashMap = X.f1226a;
int paddingStart = getPaddingStart();
int paddingTop = getPaddingTop();
int paddingEnd = getPaddingEnd();
int paddingBottom = getPaddingBottom();
if (h.hasValue(0)) {
cVar.f8134o = true;
setSupportBackgroundTintList(cVar.f8129j);
setSupportBackgroundTintMode(cVar.i);
} else {
cVar.e();
}
setPaddingRelative(paddingStart + cVar.f8124c, paddingTop + cVar.f8126e, paddingEnd + cVar.f8125d, paddingBottom + cVar.f8127f);
h.recycle();
setCompoundDrawablePadding(this.f5599n);
c(this.i != null);
}
private Layout.Alignment getActualTextAlignment() {
int textAlignment = getTextAlignment();
return textAlignment != 1 ? (textAlignment == 6 || textAlignment == 3) ? Layout.Alignment.ALIGN_OPPOSITE : textAlignment != 4 ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_CENTER : getGravityTextAlignment();
}
private Layout.Alignment getGravityTextAlignment() {
int gravity = getGravity() & 8388615;
return gravity != 1 ? (gravity == 5 || gravity == 8388613) ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_CENTER;
}
private int getTextHeight() {
if (getLineCount() > 1) {
return getLayout().getHeight();
}
TextPaint paint = getPaint();
String charSequence = getText().toString();
if (getTransformationMethod() != null) {
charSequence = getTransformationMethod().getTransformation(charSequence, this).toString();
}
Rect rect = new Rect();
paint.getTextBounds(charSequence, 0, charSequence.length(), rect);
return Math.min(rect.height(), getLayout().getHeight());
}
private int getTextLayoutWidth() {
int lineCount = getLineCount();
float f2 = BitmapDescriptorFactory.HUE_RED;
for (int i = 0; i < lineCount; i++) {
f2 = Math.max(f2, getLayout().getLineWidth(i));
}
return (int) Math.ceil(f2);
}
public final boolean a() {
c cVar = this.f5591d;
return (cVar == null || cVar.f8134o) ? false : true;
}
public final void b() {
int i = this.f5601q;
boolean z3 = true;
if (i != 1 && i != 2) {
z3 = false;
}
if (z3) {
setCompoundDrawablesRelative(this.i, null, null, null);
return;
}
if (i == 3 || i == 4) {
setCompoundDrawablesRelative(null, null, this.i, null);
} else if (i == 16 || i == 32) {
setCompoundDrawablesRelative(null, this.i, null, null);
}
}
public final void c(boolean z3) {
Drawable drawable = this.i;
if (drawable != null) {
Drawable mutate = drawable.mutate();
this.i = mutate;
H.a.h(mutate, this.h);
PorterDuff.Mode mode = this.f5594g;
if (mode != null) {
H.a.i(this.i, mode);
}
int i = this.f5596k;
if (i == 0) {
i = this.i.getIntrinsicWidth();
}
int i4 = this.f5596k;
if (i4 == 0) {
i4 = this.i.getIntrinsicHeight();
}
Drawable drawable2 = this.i;
int i5 = this.f5597l;
int i6 = this.f5598m;
drawable2.setBounds(i5, i6, i + i5, i4 + i6);
this.i.setVisible(true, z3);
}
if (z3) {
b();
return;
}
Drawable[] compoundDrawablesRelative = getCompoundDrawablesRelative();
Drawable drawable3 = compoundDrawablesRelative[0];
Drawable drawable4 = compoundDrawablesRelative[1];
Drawable drawable5 = compoundDrawablesRelative[2];
int i7 = this.f5601q;
if (((i7 == 1 || i7 == 2) && drawable3 != this.i) || (((i7 == 3 || i7 == 4) && drawable5 != this.i) || ((i7 == 16 || i7 == 32) && drawable4 != this.i))) {
b();
}
}
public final void d(int i, int i4) {
if (this.i == null || getLayout() == null) {
return;
}
int i5 = this.f5601q;
if (!(i5 == 1 || i5 == 2) && i5 != 3 && i5 != 4) {
if (i5 == 16 || i5 == 32) {
this.f5597l = 0;
if (i5 == 16) {
this.f5598m = 0;
c(false);
return;
}
int i6 = this.f5596k;
if (i6 == 0) {
i6 = this.i.getIntrinsicHeight();
}
int max = Math.max(0, (((((i4 - getTextHeight()) - getPaddingTop()) - i6) - this.f5599n) - getPaddingBottom()) / 2);
if (this.f5598m != max) {
this.f5598m = max;
c(false);
return;
}
return;
}
return;
}
this.f5598m = 0;
Layout.Alignment actualTextAlignment = getActualTextAlignment();
int i7 = this.f5601q;
if (i7 == 1 || i7 == 3 || ((i7 == 2 && actualTextAlignment == Layout.Alignment.ALIGN_NORMAL) || (i7 == 4 && actualTextAlignment == Layout.Alignment.ALIGN_OPPOSITE))) {
this.f5597l = 0;
c(false);
return;
}
int i8 = this.f5596k;
if (i8 == 0) {
i8 = this.i.getIntrinsicWidth();
}
int textLayoutWidth = i - getTextLayoutWidth();
WeakHashMap weakHashMap = X.f1226a;
int paddingEnd = (((textLayoutWidth - getPaddingEnd()) - i8) - this.f5599n) - getPaddingStart();
if (actualTextAlignment == Layout.Alignment.ALIGN_CENTER) {
paddingEnd /= 2;
}
if ((getLayoutDirection() == 1) != (this.f5601q == 4)) {
paddingEnd = -paddingEnd;
}
if (this.f5597l != paddingEnd) {
this.f5597l = paddingEnd;
c(false);
}
}
public String getA11yClassName() {
if (!TextUtils.isEmpty(this.f5595j)) {
return this.f5595j;
}
c cVar = this.f5591d;
return ((cVar == null || !cVar.f8135q) ? Button.class : CompoundButton.class).getName();
}
@Override // android.view.View
public ColorStateList getBackgroundTintList() {
return getSupportBackgroundTintList();
}
@Override // android.view.View
public PorterDuff.Mode getBackgroundTintMode() {
return getSupportBackgroundTintMode();
}
public int getCornerRadius() {
if (a()) {
return this.f5591d.f8128g;
}
return 0;
}
public Drawable getIcon() {
return this.i;
}
public int getIconGravity() {
return this.f5601q;
}
public int getIconPadding() {
return this.f5599n;
}
public int getIconSize() {
return this.f5596k;
}
public ColorStateList getIconTint() {
return this.h;
}
public PorterDuff.Mode getIconTintMode() {
return this.f5594g;
}
public int getInsetBottom() {
return this.f5591d.f8127f;
}
public int getInsetTop() {
return this.f5591d.f8126e;
}
public ColorStateList getRippleColor() {
if (a()) {
return this.f5591d.f8131l;
}
return null;
}
public k getShapeAppearanceModel() {
if (a()) {
return this.f5591d.f8123b;
}
throw new IllegalStateException("Attempted to get ShapeAppearanceModel from a MaterialButton which has an overwritten background.");
}
public ColorStateList getStrokeColor() {
if (a()) {
return this.f5591d.f8130k;
}
return null;
}
public int getStrokeWidth() {
if (a()) {
return this.f5591d.h;
}
return 0;
}
@Override // androidx.appcompat.widget.AppCompatButton
public ColorStateList getSupportBackgroundTintList() {
return a() ? this.f5591d.f8129j : super.getSupportBackgroundTintList();
}
@Override // androidx.appcompat.widget.AppCompatButton
public PorterDuff.Mode getSupportBackgroundTintMode() {
return a() ? this.f5591d.i : super.getSupportBackgroundTintMode();
}
@Override // android.widget.Checkable
public final boolean isChecked() {
return this.f5600o;
}
@Override // android.widget.TextView, android.view.View
public final void onAttachedToWindow() {
super.onAttachedToWindow();
if (a()) {
d.H(this, this.f5591d.b(false));
}
}
@Override // android.widget.TextView, android.view.View
public final int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 2);
c cVar = this.f5591d;
if (cVar != null && cVar.f8135q) {
View.mergeDrawableStates(onCreateDrawableState, f5589r);
}
if (this.f5600o) {
View.mergeDrawableStates(onCreateDrawableState, f5590s);
}
return onCreateDrawableState;
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public final void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(accessibilityEvent);
accessibilityEvent.setClassName(getA11yClassName());
accessibilityEvent.setChecked(this.f5600o);
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public final void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setClassName(getA11yClassName());
c cVar = this.f5591d;
accessibilityNodeInfo.setCheckable(cVar != null && cVar.f8135q);
accessibilityNodeInfo.setChecked(this.f5600o);
accessibilityNodeInfo.setClickable(isClickable());
}
@Override // androidx.appcompat.widget.AppCompatButton, android.widget.TextView, android.view.View
public final void onLayout(boolean z3, int i, int i4, int i5, int i6) {
super.onLayout(z3, i, i4, i5, i6);
d(getMeasuredWidth(), getMeasuredHeight());
}
@Override // android.widget.TextView, android.view.View
public final void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof b)) {
super.onRestoreInstanceState(parcelable);
return;
}
b bVar = (b) parcelable;
super.onRestoreInstanceState(bVar.f1880a);
setChecked(bVar.f8121c);
}
/* JADX WARN: Type inference failed for: r1v0, types: [android.os.Parcelable, p2.b, W.b] */
@Override // android.widget.TextView, android.view.View
public final Parcelable onSaveInstanceState() {
?? bVar = new W.b(super.onSaveInstanceState());
bVar.f8121c = this.f5600o;
return bVar;
}
@Override // androidx.appcompat.widget.AppCompatButton, android.widget.TextView
public final void onTextChanged(CharSequence charSequence, int i, int i4, int i5) {
super.onTextChanged(charSequence, i, i4, i5);
d(getMeasuredWidth(), getMeasuredHeight());
}
@Override // android.view.View
public final boolean performClick() {
if (this.f5591d.f8136r) {
toggle();
}
return super.performClick();
}
@Override // android.view.View
public final void refreshDrawableState() {
super.refreshDrawableState();
if (this.i != null) {
if (this.i.setState(getDrawableState())) {
invalidate();
}
}
}
public void setA11yClassName(String str) {
this.f5595j = str;
}
@Override // android.view.View
public void setBackground(Drawable drawable) {
setBackgroundDrawable(drawable);
}
@Override // android.view.View
public void setBackgroundColor(int i) {
if (!a()) {
super.setBackgroundColor(i);
return;
}
c cVar = this.f5591d;
if (cVar.b(false) != null) {
cVar.b(false).setTint(i);
}
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public void setBackgroundDrawable(Drawable drawable) {
if (!a()) {
super.setBackgroundDrawable(drawable);
return;
}
if (drawable == getBackground()) {
getBackground().setState(drawable.getState());
return;
}
Log.w("MaterialButton", "MaterialButton manages its own background to control elevation, shape, color and states. Consider using backgroundTint, shapeAppearance and other attributes where available. A custom background will ignore these attributes and you should consider handling interaction states such as pressed, focused and disabled");
c cVar = this.f5591d;
cVar.f8134o = true;
ColorStateList colorStateList = cVar.f8129j;
MaterialButton materialButton = cVar.f8122a;
materialButton.setSupportBackgroundTintList(colorStateList);
materialButton.setSupportBackgroundTintMode(cVar.i);
super.setBackgroundDrawable(drawable);
}
@Override // androidx.appcompat.widget.AppCompatButton, android.view.View
public void setBackgroundResource(int i) {
setBackgroundDrawable(i != 0 ? AbstractC0106b.m(getContext(), i) : null);
}
@Override // android.view.View
public void setBackgroundTintList(ColorStateList colorStateList) {
setSupportBackgroundTintList(colorStateList);
}
@Override // android.view.View
public void setBackgroundTintMode(PorterDuff.Mode mode) {
setSupportBackgroundTintMode(mode);
}
public void setCheckable(boolean z3) {
if (a()) {
this.f5591d.f8135q = z3;
}
}
@Override // android.widget.Checkable
public void setChecked(boolean z3) {
c cVar = this.f5591d;
if (cVar == null || !cVar.f8135q || !isEnabled() || this.f5600o == z3) {
return;
}
this.f5600o = z3;
refreshDrawableState();
if (getParent() instanceof MaterialButtonToggleGroup) {
MaterialButtonToggleGroup materialButtonToggleGroup = (MaterialButtonToggleGroup) getParent();
boolean z4 = this.f5600o;
if (!materialButtonToggleGroup.f5608f) {
materialButtonToggleGroup.b(getId(), z4);
}
}
if (this.p) {
return;
}
this.p = true;
Iterator it = this.f5592e.iterator();
if (it.hasNext()) {
throw w.g(it);
}
this.p = false;
}
public void setCornerRadius(int i) {
if (a()) {
c cVar = this.f5591d;
if (cVar.p && cVar.f8128g == i) {
return;
}
cVar.f8128g = i;
cVar.p = true;
float f2 = i;
j e4 = cVar.f8123b.e();
e4.f422e = new E2.a(f2);
e4.f423f = new E2.a(f2);
e4.f424g = new E2.a(f2);
e4.h = new E2.a(f2);
cVar.c(e4.a());
}
}
public void setCornerRadiusResource(int i) {
if (a()) {
setCornerRadius(getResources().getDimensionPixelSize(i));
}
}
@Override // android.view.View
public void setElevation(float f2) {
super.setElevation(f2);
if (a()) {
this.f5591d.b(false).i(f2);
}
}
public void setIcon(Drawable drawable) {
if (this.i != drawable) {
this.i = drawable;
c(true);
d(getMeasuredWidth(), getMeasuredHeight());
}
}
public void setIconGravity(int i) {
if (this.f5601q != i) {
this.f5601q = i;
d(getMeasuredWidth(), getMeasuredHeight());
}
}
public void setIconPadding(int i) {
if (this.f5599n != i) {
this.f5599n = i;
setCompoundDrawablePadding(i);
}
}
public void setIconResource(int i) {
setIcon(i != 0 ? AbstractC0106b.m(getContext(), i) : null);
}
public void setIconSize(int i) {
if (i < 0) {
throw new IllegalArgumentException("iconSize cannot be less than 0");
}
if (this.f5596k != i) {
this.f5596k = i;
c(true);
}
}
public void setIconTint(ColorStateList colorStateList) {
if (this.h != colorStateList) {
this.h = colorStateList;
c(false);
}
}
public void setIconTintMode(PorterDuff.Mode mode) {
if (this.f5594g != mode) {
this.f5594g = mode;
c(false);
}
}
public void setIconTintResource(int i) {
setIconTint(h.getColorStateList(getContext(), i));
}
public void setInsetBottom(int i) {
c cVar = this.f5591d;
cVar.d(cVar.f8126e, i);
}
public void setInsetTop(int i) {
c cVar = this.f5591d;
cVar.d(i, cVar.f8127f);
}
public void setInternalBackground(Drawable drawable) {
super.setBackgroundDrawable(drawable);
}
public void setOnPressedChangeListenerInternal(InterfaceC0552a interfaceC0552a) {
this.f5593f = interfaceC0552a;
}
@Override // android.view.View
public void setPressed(boolean z3) {
InterfaceC0552a interfaceC0552a = this.f5593f;
if (interfaceC0552a != null) {
((MaterialButtonToggleGroup) ((h3.d) interfaceC0552a).f6791b).invalidate();
}
super.setPressed(z3);
}
public void setRippleColor(ColorStateList colorStateList) {
if (a()) {
c cVar = this.f5591d;
if (cVar.f8131l != colorStateList) {
cVar.f8131l = colorStateList;
MaterialButton materialButton = cVar.f8122a;
if (materialButton.getBackground() instanceof RippleDrawable) {
((RippleDrawable) materialButton.getBackground()).setColor(C2.a.c(colorStateList));
}
}
}
}
public void setRippleColorResource(int i) {
if (a()) {
setRippleColor(h.getColorStateList(getContext(), i));
}
}
@Override // E2.u
public void setShapeAppearanceModel(k kVar) {
if (!a()) {
throw new IllegalStateException("Attempted to set ShapeAppearanceModel on a MaterialButton which has an overwritten background.");
}
this.f5591d.c(kVar);
}
public void setShouldDrawSurfaceColorStroke(boolean z3) {
if (a()) {
c cVar = this.f5591d;
cVar.f8133n = z3;
cVar.f();
}
}
public void setStrokeColor(ColorStateList colorStateList) {
if (a()) {
c cVar = this.f5591d;
if (cVar.f8130k != colorStateList) {
cVar.f8130k = colorStateList;
cVar.f();
}
}
}
public void setStrokeColorResource(int i) {
if (a()) {
setStrokeColor(h.getColorStateList(getContext(), i));
}
}
public void setStrokeWidth(int i) {
if (a()) {
c cVar = this.f5591d;
if (cVar.h != i) {
cVar.h = i;
cVar.f();
}
}
}
public void setStrokeWidthResource(int i) {
if (a()) {
setStrokeWidth(getResources().getDimensionPixelSize(i));
}
}
@Override // androidx.appcompat.widget.AppCompatButton
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
if (!a()) {
super.setSupportBackgroundTintList(colorStateList);
return;
}
c cVar = this.f5591d;
if (cVar.f8129j != colorStateList) {
cVar.f8129j = colorStateList;
if (cVar.b(false) != null) {
H.a.h(cVar.b(false), cVar.f8129j);
}
}
}
@Override // androidx.appcompat.widget.AppCompatButton
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
if (!a()) {
super.setSupportBackgroundTintMode(mode);
return;
}
c cVar = this.f5591d;
if (cVar.i != mode) {
cVar.i = mode;
if (cVar.b(false) == null || cVar.i == null) {
return;
}
H.a.i(cVar.b(false), cVar.i);
}
}
@Override // android.view.View
public void setTextAlignment(int i) {
super.setTextAlignment(i);
d(getMeasuredWidth(), getMeasuredHeight());
}
public void setToggleCheckedStateOnClick(boolean z3) {
this.f5591d.f8136r = z3;
}
@Override // android.widget.Checkable
public final void toggle() {
setChecked(!this.f5600o);
}
}

View File

@@ -0,0 +1,372 @@
package com.google.android.material.button;
import E2.j;
import E2.k;
import F0.g;
import K2.a;
import O.X;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.ToggleButton;
import com.adif.elcanomovil.R;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.material.timepicker.f;
import h2.AbstractC0379a;
import h3.d;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import java.util.WeakHashMap;
import p2.e;
import x2.m;
/* loaded from: classes3.dex */
public class MaterialButtonToggleGroup extends LinearLayout {
/* renamed from: k, reason: collision with root package name */
public static final /* synthetic */ int f5602k = 0;
/* renamed from: a, reason: collision with root package name */
public final ArrayList f5603a;
/* renamed from: b, reason: collision with root package name */
public final d f5604b;
/* renamed from: c, reason: collision with root package name */
public final LinkedHashSet f5605c;
/* renamed from: d, reason: collision with root package name */
public final p2.d f5606d;
/* renamed from: e, reason: collision with root package name */
public Integer[] f5607e;
/* renamed from: f, reason: collision with root package name */
public boolean f5608f;
/* renamed from: g, reason: collision with root package name */
public boolean f5609g;
public boolean h;
public final int i;
/* renamed from: j, reason: collision with root package name */
public HashSet f5610j;
public MaterialButtonToggleGroup(Context context, AttributeSet attributeSet) {
super(a.a(context, attributeSet, R.attr.materialButtonToggleGroupStyle, 2132018318), attributeSet, R.attr.materialButtonToggleGroupStyle);
this.f5603a = new ArrayList();
this.f5604b = new d(this, 8);
this.f5605c = new LinkedHashSet();
this.f5606d = new p2.d(this);
this.f5608f = false;
this.f5610j = new HashSet();
TypedArray h = m.h(getContext(), attributeSet, AbstractC0379a.f6765m, R.attr.materialButtonToggleGroupStyle, 2132018318, new int[0]);
setSingleSelection(h.getBoolean(3, false));
this.i = h.getResourceId(1, -1);
this.h = h.getBoolean(2, false);
setChildrenDrawingOrderEnabled(true);
setEnabled(h.getBoolean(0, true));
h.recycle();
WeakHashMap weakHashMap = X.f1226a;
setImportantForAccessibility(1);
}
private int getFirstVisibleChildIndex() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
if (c(i)) {
return i;
}
}
return -1;
}
private int getLastVisibleChildIndex() {
for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
if (c(childCount)) {
return childCount;
}
}
return -1;
}
private int getVisibleButtonCount() {
int i = 0;
for (int i4 = 0; i4 < getChildCount(); i4++) {
if ((getChildAt(i4) instanceof MaterialButton) && c(i4)) {
i++;
}
}
return i;
}
private void setGeneratedIdIfNeeded(MaterialButton materialButton) {
if (materialButton.getId() == -1) {
WeakHashMap weakHashMap = X.f1226a;
materialButton.setId(View.generateViewId());
}
}
private void setupButtonChild(MaterialButton materialButton) {
materialButton.setMaxLines(1);
materialButton.setEllipsize(TextUtils.TruncateAt.END);
materialButton.setCheckable(true);
materialButton.setOnPressedChangeListenerInternal(this.f5604b);
materialButton.setShouldDrawSurfaceColorStroke(true);
}
public final void a() {
int firstVisibleChildIndex = getFirstVisibleChildIndex();
if (firstVisibleChildIndex == -1) {
return;
}
for (int i = firstVisibleChildIndex + 1; i < getChildCount(); i++) {
MaterialButton materialButton = (MaterialButton) getChildAt(i);
int min = Math.min(materialButton.getStrokeWidth(), ((MaterialButton) getChildAt(i - 1)).getStrokeWidth());
ViewGroup.LayoutParams layoutParams = materialButton.getLayoutParams();
LinearLayout.LayoutParams layoutParams2 = layoutParams instanceof LinearLayout.LayoutParams ? (LinearLayout.LayoutParams) layoutParams : new LinearLayout.LayoutParams(layoutParams.width, layoutParams.height);
if (getOrientation() == 0) {
layoutParams2.setMarginEnd(0);
layoutParams2.setMarginStart(-min);
layoutParams2.topMargin = 0;
} else {
layoutParams2.bottomMargin = 0;
layoutParams2.topMargin = -min;
layoutParams2.setMarginStart(0);
}
materialButton.setLayoutParams(layoutParams2);
}
if (getChildCount() == 0 || firstVisibleChildIndex == -1) {
return;
}
LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) ((MaterialButton) getChildAt(firstVisibleChildIndex)).getLayoutParams();
if (getOrientation() == 1) {
layoutParams3.topMargin = 0;
layoutParams3.bottomMargin = 0;
} else {
layoutParams3.setMarginEnd(0);
layoutParams3.setMarginStart(0);
layoutParams3.leftMargin = 0;
layoutParams3.rightMargin = 0;
}
}
@Override // android.view.ViewGroup
public final void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
if (!(view instanceof MaterialButton)) {
Log.e("MButtonToggleGroup", "Child views must be of type MaterialButton.");
return;
}
super.addView(view, i, layoutParams);
MaterialButton materialButton = (MaterialButton) view;
setGeneratedIdIfNeeded(materialButton);
setupButtonChild(materialButton);
b(materialButton.getId(), materialButton.f5600o);
k shapeAppearanceModel = materialButton.getShapeAppearanceModel();
this.f5603a.add(new e(shapeAppearanceModel.f432e, shapeAppearanceModel.h, shapeAppearanceModel.f433f, shapeAppearanceModel.f434g));
materialButton.setEnabled(isEnabled());
X.j(materialButton, new g(this, 4));
}
public final void b(int i, boolean z3) {
if (i == -1) {
Log.e("MButtonToggleGroup", "Button ID is not valid: " + i);
return;
}
HashSet hashSet = new HashSet(this.f5610j);
if (z3 && !hashSet.contains(Integer.valueOf(i))) {
if (this.f5609g && !hashSet.isEmpty()) {
hashSet.clear();
}
hashSet.add(Integer.valueOf(i));
} else {
if (z3 || !hashSet.contains(Integer.valueOf(i))) {
return;
}
if (!this.h || hashSet.size() > 1) {
hashSet.remove(Integer.valueOf(i));
}
}
d(hashSet);
}
public final boolean c(int i) {
return getChildAt(i).getVisibility() != 8;
}
public final void d(Set set) {
HashSet hashSet = this.f5610j;
this.f5610j = new HashSet(set);
for (int i = 0; i < getChildCount(); i++) {
int id = ((MaterialButton) getChildAt(i)).getId();
boolean contains = set.contains(Integer.valueOf(id));
View findViewById = findViewById(id);
if (findViewById instanceof MaterialButton) {
this.f5608f = true;
((MaterialButton) findViewById).setChecked(contains);
this.f5608f = false;
}
if (hashSet.contains(Integer.valueOf(id)) != set.contains(Integer.valueOf(id))) {
set.contains(Integer.valueOf(id));
Iterator it = this.f5605c.iterator();
while (it.hasNext()) {
((f) it.next()).a();
}
}
}
invalidate();
}
@Override // android.view.ViewGroup, android.view.View
public final void dispatchDraw(Canvas canvas) {
TreeMap treeMap = new TreeMap(this.f5606d);
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
treeMap.put((MaterialButton) getChildAt(i), Integer.valueOf(i));
}
this.f5607e = (Integer[]) treeMap.values().toArray(new Integer[0]);
super.dispatchDraw(canvas);
}
public final void e() {
e eVar;
int childCount = getChildCount();
int firstVisibleChildIndex = getFirstVisibleChildIndex();
int lastVisibleChildIndex = getLastVisibleChildIndex();
for (int i = 0; i < childCount; i++) {
MaterialButton materialButton = (MaterialButton) getChildAt(i);
if (materialButton.getVisibility() != 8) {
j e4 = materialButton.getShapeAppearanceModel().e();
e eVar2 = (e) this.f5603a.get(i);
if (firstVisibleChildIndex != lastVisibleChildIndex) {
boolean z3 = getOrientation() == 0;
E2.a aVar = e.f8140e;
if (i == firstVisibleChildIndex) {
eVar = z3 ? m.g(this) ? new e(aVar, aVar, eVar2.f8142b, eVar2.f8143c) : new e(eVar2.f8141a, eVar2.f8144d, aVar, aVar) : new e(eVar2.f8141a, aVar, eVar2.f8142b, aVar);
} else if (i == lastVisibleChildIndex) {
eVar = z3 ? m.g(this) ? new e(eVar2.f8141a, eVar2.f8144d, aVar, aVar) : new e(aVar, aVar, eVar2.f8142b, eVar2.f8143c) : new e(aVar, eVar2.f8144d, aVar, eVar2.f8143c);
} else {
eVar2 = null;
}
eVar2 = eVar;
}
if (eVar2 == null) {
e4.f422e = new E2.a(BitmapDescriptorFactory.HUE_RED);
e4.f423f = new E2.a(BitmapDescriptorFactory.HUE_RED);
e4.f424g = new E2.a(BitmapDescriptorFactory.HUE_RED);
e4.h = new E2.a(BitmapDescriptorFactory.HUE_RED);
} else {
e4.f422e = eVar2.f8141a;
e4.h = eVar2.f8144d;
e4.f423f = eVar2.f8142b;
e4.f424g = eVar2.f8143c;
}
materialButton.setShapeAppearanceModel(e4.a());
}
}
}
public int getCheckedButtonId() {
if (!this.f5609g || this.f5610j.isEmpty()) {
return -1;
}
return ((Integer) this.f5610j.iterator().next()).intValue();
}
public List<Integer> getCheckedButtonIds() {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < getChildCount(); i++) {
int id = ((MaterialButton) getChildAt(i)).getId();
if (this.f5610j.contains(Integer.valueOf(id))) {
arrayList.add(Integer.valueOf(id));
}
}
return arrayList;
}
@Override // android.view.ViewGroup
public final int getChildDrawingOrder(int i, int i4) {
Integer[] numArr = this.f5607e;
if (numArr != null && i4 < numArr.length) {
return numArr[i4].intValue();
}
Log.w("MButtonToggleGroup", "Child order wasn't updated");
return i4;
}
@Override // android.view.View
public final void onFinishInflate() {
super.onFinishInflate();
int i = this.i;
if (i != -1) {
d(Collections.singleton(Integer.valueOf(i)));
}
}
@Override // android.view.View
public final void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setCollectionInfo((AccessibilityNodeInfo.CollectionInfo) A.a.s(1, getVisibleButtonCount(), this.f5609g ? 1 : 2).f7b);
}
@Override // android.widget.LinearLayout, android.view.View
public final void onMeasure(int i, int i4) {
e();
a();
super.onMeasure(i, i4);
}
@Override // android.view.ViewGroup
public final void onViewRemoved(View view) {
super.onViewRemoved(view);
if (view instanceof MaterialButton) {
((MaterialButton) view).setOnPressedChangeListenerInternal(null);
}
int indexOfChild = indexOfChild(view);
if (indexOfChild >= 0) {
this.f5603a.remove(indexOfChild);
}
e();
a();
}
@Override // android.view.View
public void setEnabled(boolean z3) {
super.setEnabled(z3);
for (int i = 0; i < getChildCount(); i++) {
((MaterialButton) getChildAt(i)).setEnabled(z3);
}
}
public void setSelectionRequired(boolean z3) {
this.h = z3;
}
public void setSingleSelection(boolean z3) {
if (this.f5609g != z3) {
this.f5609g = z3;
d(new HashSet());
}
for (int i = 0; i < getChildCount(); i++) {
((MaterialButton) getChildAt(i)).setA11yClassName((this.f5609g ? RadioButton.class : ToggleButton.class).getName());
}
}
public void setSingleSelection(int i) {
setSingleSelection(getResources().getBoolean(i));
}
}