Rabbit-R1/android (non root)/java/sources/com/google/android/material/card/MaterialCardView.java

444 lines
16 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package com.google.android.material.card;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Checkable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.cardview.widget.CardView;
import com.google.android.material.shape.MaterialShapeUtils;
import com.google.android.material.shape.ShapeAppearanceModel;
import com.google.android.material.shape.Shapeable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes2.dex */
public class MaterialCardView extends CardView implements Checkable, Shapeable {
private static final String ACCESSIBILITY_CLASS_NAME = "androidx.cardview.widget.CardView";
public static final int CHECKED_ICON_GRAVITY_BOTTOM_END = 8388693;
public static final int CHECKED_ICON_GRAVITY_BOTTOM_START = 8388691;
public static final int CHECKED_ICON_GRAVITY_TOP_END = 8388661;
public static final int CHECKED_ICON_GRAVITY_TOP_START = 8388659;
private static final String LOG_TAG = "MaterialCardView";
private final MaterialCardViewHelper cardViewHelper;
private boolean checked;
private boolean dragged;
private boolean isParentCardViewDoneInitializing;
private OnCheckedChangeListener onCheckedChangeListener;
private static final int[] CHECKABLE_STATE_SET = {R.attr.state_checkable};
private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
private static final int[] DRAGGED_STATE_SET = {com.google.android.material.R.attr.state_dragged};
private static final int DEF_STYLE_RES = com.google.android.material.R.style.Widget_MaterialComponents_CardView;
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes2.dex */
public @interface CheckedIconGravity {
}
/* loaded from: classes2.dex */
public interface OnCheckedChangeListener {
void onCheckedChanged(MaterialCardView materialCardView, boolean z);
}
@Override // android.widget.Checkable
public boolean isChecked() {
return this.checked;
}
public boolean isDragged() {
return this.dragged;
}
public void setOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
this.onCheckedChangeListener = onCheckedChangeListener;
}
public MaterialCardView(Context context) {
this(context, null);
}
public MaterialCardView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, com.google.android.material.R.attr.materialCardViewStyle);
}
/* 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 MaterialCardView(android.content.Context r8, android.util.AttributeSet r9, int r10) {
/*
r7 = this;
int r6 = com.google.android.material.card.MaterialCardView.DEF_STYLE_RES
android.content.Context r8 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r8, r9, r10, r6)
r7.<init>(r8, r9, r10)
r8 = 0
r7.checked = r8
r7.dragged = r8
r0 = 1
r7.isParentCardViewDoneInitializing = r0
android.content.Context r0 = r7.getContext()
int[] r2 = com.google.android.material.R.styleable.MaterialCardView
int[] r5 = new int[r8]
r1 = r9
r3 = r10
r4 = r6
android.content.res.TypedArray r8 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5)
com.google.android.material.card.MaterialCardViewHelper r0 = new com.google.android.material.card.MaterialCardViewHelper
r0.<init>(r7, r9, r10, r6)
r7.cardViewHelper = r0
android.content.res.ColorStateList r9 = super.getCardBackgroundColor()
r0.setCardBackgroundColor(r9)
int r9 = super.getContentPaddingLeft()
int r10 = super.getContentPaddingTop()
int r1 = super.getContentPaddingRight()
int r7 = super.getContentPaddingBottom()
r0.setUserContentPadding(r9, r10, r1, r7)
r0.loadFromAttributes(r8)
r8.recycle()
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.card.MaterialCardView.<init>(android.content.Context, android.util.AttributeSet, int):void");
}
@Override // android.view.View
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
accessibilityNodeInfo.setClassName(ACCESSIBILITY_CLASS_NAME);
accessibilityNodeInfo.setCheckable(isCheckable());
accessibilityNodeInfo.setClickable(isClickable());
accessibilityNodeInfo.setChecked(isChecked());
}
@Override // android.view.View
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(accessibilityEvent);
accessibilityEvent.setClassName(ACCESSIBILITY_CLASS_NAME);
accessibilityEvent.setChecked(isChecked());
}
@Override // androidx.cardview.widget.CardView, android.widget.FrameLayout, android.view.View
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
this.cardViewHelper.recalculateCheckedIconPosition(getMeasuredWidth(), getMeasuredHeight());
}
public void setStrokeColor(int i) {
setStrokeColor(ColorStateList.valueOf(i));
}
public void setStrokeColor(ColorStateList colorStateList) {
this.cardViewHelper.setStrokeColor(colorStateList);
invalidate();
}
@Deprecated
public int getStrokeColor() {
return this.cardViewHelper.getStrokeColor();
}
public ColorStateList getStrokeColorStateList() {
return this.cardViewHelper.getStrokeColorStateList();
}
public void setStrokeWidth(int i) {
this.cardViewHelper.setStrokeWidth(i);
invalidate();
}
public int getStrokeWidth() {
return this.cardViewHelper.getStrokeWidth();
}
@Override // androidx.cardview.widget.CardView
public void setRadius(float f) {
super.setRadius(f);
this.cardViewHelper.setCornerRadius(f);
}
@Override // androidx.cardview.widget.CardView
public float getRadius() {
return this.cardViewHelper.getCornerRadius();
}
/* JADX INFO: Access modifiers changed from: package-private */
public float getCardViewRadius() {
return super.getRadius();
}
public void setProgress(float f) {
this.cardViewHelper.setProgress(f);
}
public float getProgress() {
return this.cardViewHelper.getProgress();
}
@Override // androidx.cardview.widget.CardView
public void setContentPadding(int i, int i2, int i3, int i4) {
this.cardViewHelper.setUserContentPadding(i, i2, i3, i4);
}
/* JADX INFO: Access modifiers changed from: package-private */
public void setAncestorContentPadding(int i, int i2, int i3, int i4) {
super.setContentPadding(i, i2, i3, i4);
}
@Override // androidx.cardview.widget.CardView
public int getContentPaddingLeft() {
return this.cardViewHelper.getUserContentPadding().left;
}
@Override // androidx.cardview.widget.CardView
public int getContentPaddingTop() {
return this.cardViewHelper.getUserContentPadding().top;
}
@Override // androidx.cardview.widget.CardView
public int getContentPaddingRight() {
return this.cardViewHelper.getUserContentPadding().right;
}
@Override // androidx.cardview.widget.CardView
public int getContentPaddingBottom() {
return this.cardViewHelper.getUserContentPadding().bottom;
}
@Override // androidx.cardview.widget.CardView
public void setCardBackgroundColor(int i) {
this.cardViewHelper.setCardBackgroundColor(ColorStateList.valueOf(i));
}
@Override // androidx.cardview.widget.CardView
public void setCardBackgroundColor(ColorStateList colorStateList) {
this.cardViewHelper.setCardBackgroundColor(colorStateList);
}
@Override // androidx.cardview.widget.CardView
public ColorStateList getCardBackgroundColor() {
return this.cardViewHelper.getCardBackgroundColor();
}
public void setCardForegroundColor(ColorStateList colorStateList) {
this.cardViewHelper.setCardForegroundColor(colorStateList);
}
public ColorStateList getCardForegroundColor() {
return this.cardViewHelper.getCardForegroundColor();
}
@Override // android.view.View
public void setClickable(boolean z) {
super.setClickable(z);
MaterialCardViewHelper materialCardViewHelper = this.cardViewHelper;
if (materialCardViewHelper != null) {
materialCardViewHelper.updateClickable();
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
this.cardViewHelper.updateClickable();
MaterialShapeUtils.setParentAbsoluteElevation(this, this.cardViewHelper.getBackground());
}
@Override // androidx.cardview.widget.CardView
public void setCardElevation(float f) {
super.setCardElevation(f);
this.cardViewHelper.updateElevation();
}
@Override // androidx.cardview.widget.CardView
public void setMaxCardElevation(float f) {
super.setMaxCardElevation(f);
this.cardViewHelper.updateInsets();
}
@Override // androidx.cardview.widget.CardView
public void setUseCompatPadding(boolean z) {
super.setUseCompatPadding(z);
this.cardViewHelper.updateInsets();
this.cardViewHelper.updateContentPadding();
}
@Override // androidx.cardview.widget.CardView
public void setPreventCornerOverlap(boolean z) {
super.setPreventCornerOverlap(z);
this.cardViewHelper.updateInsets();
this.cardViewHelper.updateContentPadding();
}
@Override // android.view.View
public void setBackground(Drawable drawable) {
setBackgroundDrawable(drawable);
}
@Override // android.view.View
public void setBackgroundDrawable(Drawable drawable) {
if (this.isParentCardViewDoneInitializing) {
if (!this.cardViewHelper.isBackgroundOverwritten()) {
Log.i(LOG_TAG, "Setting a custom background is not supported.");
this.cardViewHelper.setBackgroundOverwritten(true);
}
super.setBackgroundDrawable(drawable);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void setBackgroundInternal(Drawable drawable) {
super.setBackgroundDrawable(drawable);
}
@Override // android.widget.Checkable
public void setChecked(boolean z) {
if (this.checked != z) {
toggle();
}
}
public void setDragged(boolean z) {
if (this.dragged != z) {
this.dragged = z;
refreshDrawableState();
forceRippleRedrawIfNeeded();
invalidate();
}
}
public boolean isCheckable() {
MaterialCardViewHelper materialCardViewHelper = this.cardViewHelper;
return materialCardViewHelper != null && materialCardViewHelper.isCheckable();
}
public void setCheckable(boolean z) {
this.cardViewHelper.setCheckable(z);
}
@Override // android.widget.Checkable
public void toggle() {
if (isCheckable() && isEnabled()) {
this.checked = !this.checked;
refreshDrawableState();
forceRippleRedrawIfNeeded();
this.cardViewHelper.setChecked(this.checked, true);
OnCheckedChangeListener onCheckedChangeListener = this.onCheckedChangeListener;
if (onCheckedChangeListener != null) {
onCheckedChangeListener.onCheckedChanged(this, this.checked);
}
}
}
@Override // android.view.ViewGroup, android.view.View
protected int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 3);
if (isCheckable()) {
mergeDrawableStates(onCreateDrawableState, CHECKABLE_STATE_SET);
}
if (isChecked()) {
mergeDrawableStates(onCreateDrawableState, CHECKED_STATE_SET);
}
if (isDragged()) {
mergeDrawableStates(onCreateDrawableState, DRAGGED_STATE_SET);
}
return onCreateDrawableState;
}
public void setRippleColor(ColorStateList colorStateList) {
this.cardViewHelper.setRippleColor(colorStateList);
}
public void setRippleColorResource(int i) {
this.cardViewHelper.setRippleColor(AppCompatResources.getColorStateList(getContext(), i));
}
public ColorStateList getRippleColor() {
return this.cardViewHelper.getRippleColor();
}
public Drawable getCheckedIcon() {
return this.cardViewHelper.getCheckedIcon();
}
public void setCheckedIconResource(int i) {
this.cardViewHelper.setCheckedIcon(AppCompatResources.getDrawable(getContext(), i));
}
public void setCheckedIcon(Drawable drawable) {
this.cardViewHelper.setCheckedIcon(drawable);
}
public ColorStateList getCheckedIconTint() {
return this.cardViewHelper.getCheckedIconTint();
}
public void setCheckedIconTint(ColorStateList colorStateList) {
this.cardViewHelper.setCheckedIconTint(colorStateList);
}
public int getCheckedIconSize() {
return this.cardViewHelper.getCheckedIconSize();
}
public void setCheckedIconSize(int i) {
this.cardViewHelper.setCheckedIconSize(i);
}
public void setCheckedIconSizeResource(int i) {
if (i != 0) {
this.cardViewHelper.setCheckedIconSize(getResources().getDimensionPixelSize(i));
}
}
public int getCheckedIconMargin() {
return this.cardViewHelper.getCheckedIconMargin();
}
public void setCheckedIconMargin(int i) {
this.cardViewHelper.setCheckedIconMargin(i);
}
public void setCheckedIconMarginResource(int i) {
if (i != -1) {
this.cardViewHelper.setCheckedIconMargin(getResources().getDimensionPixelSize(i));
}
}
private RectF getBoundsAsRectF() {
RectF rectF = new RectF();
rectF.set(this.cardViewHelper.getBackground().getBounds());
return rectF;
}
@Override // com.google.android.material.shape.Shapeable
public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
setClipToOutline(shapeAppearanceModel.isRoundRect(getBoundsAsRectF()));
this.cardViewHelper.setShapeAppearanceModel(shapeAppearanceModel);
}
@Override // com.google.android.material.shape.Shapeable
public ShapeAppearanceModel getShapeAppearanceModel() {
return this.cardViewHelper.getShapeAppearanceModel();
}
private void forceRippleRedrawIfNeeded() {
this.cardViewHelper.forceRippleRedraw();
}
public int getCheckedIconGravity() {
return this.cardViewHelper.getCheckedIconGravity();
}
public void setCheckedIconGravity(int i) {
if (this.cardViewHelper.getCheckedIconGravity() != i) {
this.cardViewHelper.setCheckedIconGravity(i);
}
}
}