160 lines
5.0 KiB
Java
160 lines
5.0 KiB
Java
|
package com.google.android.material.internal;
|
||
|
|
||
|
import android.R;
|
||
|
import android.content.Context;
|
||
|
import android.os.Parcel;
|
||
|
import android.os.Parcelable;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.View;
|
||
|
import android.view.accessibility.AccessibilityEvent;
|
||
|
import android.widget.Checkable;
|
||
|
import androidx.appcompat.widget.AppCompatImageButton;
|
||
|
import androidx.core.view.ViewCompat;
|
||
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||
|
import o.SYO;
|
||
|
import o.XgG;
|
||
|
import o.yZt;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class CheckableImageButton extends AppCompatImageButton implements Checkable {
|
||
|
private static final int[] b = {R.attr.state_checked};
|
||
|
private boolean c;
|
||
|
boolean d;
|
||
|
private boolean e;
|
||
|
|
||
|
public CheckableImageButton(Context context) {
|
||
|
this(context, null);
|
||
|
}
|
||
|
|
||
|
public CheckableImageButton(Context context, AttributeSet attributeSet) {
|
||
|
this(context, attributeSet, SYO.IeS.imageButtonStyle);
|
||
|
}
|
||
|
|
||
|
public CheckableImageButton(Context context, AttributeSet attributeSet, int i) {
|
||
|
super(context, attributeSet, i);
|
||
|
this.d = true;
|
||
|
this.e = true;
|
||
|
ViewCompat.e(this, new yZt(this) { // from class: com.google.android.material.internal.CheckableImageButton.2
|
||
|
private CheckableImageButton e;
|
||
|
|
||
|
{
|
||
|
this.e = this;
|
||
|
}
|
||
|
|
||
|
@Override // o.yZt
|
||
|
public final void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
|
||
|
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
|
||
|
accessibilityEvent.setChecked(this.e.isChecked());
|
||
|
}
|
||
|
|
||
|
@Override // o.yZt
|
||
|
public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
||
|
accessibilityNodeInfoCompat.c(this.e.d);
|
||
|
accessibilityNodeInfoCompat.a(this.e.isChecked());
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.Checkable
|
||
|
public void setChecked(boolean z) {
|
||
|
if (!this.d || this.c == z) {
|
||
|
return;
|
||
|
}
|
||
|
this.c = z;
|
||
|
refreshDrawableState();
|
||
|
sendAccessibilityEvent(2048);
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.Checkable
|
||
|
public void toggle() {
|
||
|
setChecked(!this.c);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void setPressed(boolean z) {
|
||
|
if (this.e) {
|
||
|
super.setPressed(z);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.ImageView, android.view.View
|
||
|
public int[] onCreateDrawableState(int i) {
|
||
|
if (this.c) {
|
||
|
int[] iArr = b;
|
||
|
return mergeDrawableStates(super.onCreateDrawableState(i + iArr.length), iArr);
|
||
|
}
|
||
|
return super.onCreateDrawableState(i);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected Parcelable onSaveInstanceState() {
|
||
|
Sts sts = new Sts(super.onSaveInstanceState());
|
||
|
sts.d = this.c;
|
||
|
return sts;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected void onRestoreInstanceState(Parcelable parcelable) {
|
||
|
if (!(parcelable instanceof Sts)) {
|
||
|
super.onRestoreInstanceState(parcelable);
|
||
|
return;
|
||
|
}
|
||
|
Sts sts = (Sts) parcelable;
|
||
|
super.onRestoreInstanceState(sts.b);
|
||
|
setChecked(sts.d);
|
||
|
}
|
||
|
|
||
|
public void setCheckable(boolean z) {
|
||
|
if (this.d != z) {
|
||
|
this.d = z;
|
||
|
sendAccessibilityEvent(0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class Sts extends XgG {
|
||
|
public static final Parcelable.Creator<Sts> CREATOR = new Parcelable.ClassLoaderCreator<Sts>() { // from class: com.google.android.material.internal.CheckableImageButton.Sts.3
|
||
|
@Override // android.os.Parcelable.Creator
|
||
|
public final /* synthetic */ Object createFromParcel(Parcel parcel) {
|
||
|
return new Sts(parcel, null);
|
||
|
}
|
||
|
|
||
|
@Override // android.os.Parcelable.ClassLoaderCreator
|
||
|
public final /* synthetic */ Sts createFromParcel(Parcel parcel, ClassLoader classLoader) {
|
||
|
return new Sts(parcel, classLoader);
|
||
|
}
|
||
|
|
||
|
@Override // android.os.Parcelable.Creator
|
||
|
public final /* bridge */ /* synthetic */ Object[] newArray(int i) {
|
||
|
return new Sts[i];
|
||
|
}
|
||
|
};
|
||
|
boolean d;
|
||
|
|
||
|
public Sts(Parcelable parcelable) {
|
||
|
super(parcelable);
|
||
|
}
|
||
|
|
||
|
public Sts(Parcel parcel, ClassLoader classLoader) {
|
||
|
super(parcel, classLoader);
|
||
|
this.d = parcel.readInt() == 1;
|
||
|
}
|
||
|
|
||
|
@Override // o.XgG, android.os.Parcelable
|
||
|
public final void writeToParcel(Parcel parcel, int i) {
|
||
|
super.writeToParcel(parcel, i);
|
||
|
parcel.writeInt(this.d ? 1 : 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setPressable(boolean z) {
|
||
|
this.e = z;
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.Checkable
|
||
|
public boolean isChecked() {
|
||
|
return this.c;
|
||
|
}
|
||
|
}
|