package androidx.cardview.widget;

import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import com.google.android.gms.internal.atv_ads_framework.d1;
import r.b;
import r.c;
import s.a;
import s.d;

/* JADX INFO: loaded from: classes.dex */
public class CardView extends FrameLayout {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final int[] f917f = {R.attr.colorBackground};

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final a f918g = new a();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public boolean f919a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f920b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Rect f921c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Rect f922d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final d1 f923e;

    public CardView(@NonNull Context context) {
        this(context, null);
    }

    @NonNull
    public ColorStateList getCardBackgroundColor() {
        return a.a(this.f923e).f32630h;
    }

    public float getCardElevation() {
        return ((CardView) this.f923e.f19915c).getElevation();
    }

    @Px
    public int getContentPaddingBottom() {
        return this.f921c.bottom;
    }

    @Px
    public int getContentPaddingLeft() {
        return this.f921c.left;
    }

    @Px
    public int getContentPaddingRight() {
        return this.f921c.right;
    }

    @Px
    public int getContentPaddingTop() {
        return this.f921c.top;
    }

    public float getMaxCardElevation() {
        return a.a(this.f923e).f32627e;
    }

    public boolean getPreventCornerOverlap() {
        return this.f920b;
    }

    public float getRadius() {
        return a.a(this.f923e).f32623a;
    }

    public boolean getUseCompatPadding() {
        return this.f919a;
    }

    @Override // android.widget.FrameLayout, android.view.View
    public void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
    }

    public void setCardBackgroundColor(@ColorInt int i10) {
        f918g.setBackgroundColor(this.f923e, ColorStateList.valueOf(i10));
    }

    public void setCardElevation(float f10) {
        ((CardView) this.f923e.f19915c).setElevation(f10);
    }

    public void setContentPadding(@Px int i10, @Px int i11, @Px int i12, @Px int i13) {
        this.f921c.set(i10, i11, i12, i13);
        f918g.c(this.f923e);
    }

    public void setMaxCardElevation(float f10) {
        f918g.b(this.f923e, f10);
    }

    @Override // android.view.View
    public void setMinimumHeight(int i10) {
        super.setMinimumHeight(i10);
    }

    @Override // android.view.View
    public void setMinimumWidth(int i10) {
        super.setMinimumWidth(i10);
    }

    @Override // android.view.View
    public void setPadding(int i10, int i11, int i12, int i13) {
    }

    @Override // android.view.View
    public void setPaddingRelative(int i10, int i11, int i12, int i13) {
    }

    public void setPreventCornerOverlap(boolean z10) {
        if (z10 != this.f920b) {
            this.f920b = z10;
            a aVar = f918g;
            d1 d1Var = this.f923e;
            aVar.b(d1Var, a.a(d1Var).f32627e);
        }
    }

    public void setRadius(float f10) {
        d dVarA = a.a(this.f923e);
        if (f10 == dVarA.f32623a) {
            return;
        }
        dVarA.f32623a = f10;
        dVarA.b(null);
        dVarA.invalidateSelf();
    }

    public void setUseCompatPadding(boolean z10) {
        if (this.f919a != z10) {
            this.f919a = z10;
            a aVar = f918g;
            d1 d1Var = this.f923e;
            aVar.b(d1Var, a.a(d1Var).f32627e);
        }
    }

    public CardView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, r.a.cardViewStyle);
    }

    public void setCardBackgroundColor(@Nullable ColorStateList colorStateList) {
        f918g.setBackgroundColor(this.f923e, colorStateList);
    }

    public CardView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        int color;
        ColorStateList colorStateListValueOf;
        super(context, attributeSet, i10);
        Rect rect = new Rect();
        this.f921c = rect;
        this.f922d = new Rect();
        d1 d1Var = new d1(this);
        this.f923e = d1Var;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, r.d.CardView, i10, c.CardView);
        int i11 = r.d.CardView_cardBackgroundColor;
        if (typedArrayObtainStyledAttributes.hasValue(i11)) {
            colorStateListValueOf = typedArrayObtainStyledAttributes.getColorStateList(i11);
        } else {
            TypedArray typedArrayObtainStyledAttributes2 = getContext().obtainStyledAttributes(f917f);
            int color2 = typedArrayObtainStyledAttributes2.getColor(0, 0);
            typedArrayObtainStyledAttributes2.recycle();
            float[] fArr = new float[3];
            Color.colorToHSV(color2, fArr);
            if (fArr[2] > 0.5f) {
                color = getResources().getColor(b.cardview_light_background);
            } else {
                color = getResources().getColor(b.cardview_dark_background);
            }
            colorStateListValueOf = ColorStateList.valueOf(color);
        }
        float dimension = typedArrayObtainStyledAttributes.getDimension(r.d.CardView_cardCornerRadius, 0.0f);
        float dimension2 = typedArrayObtainStyledAttributes.getDimension(r.d.CardView_cardElevation, 0.0f);
        float dimension3 = typedArrayObtainStyledAttributes.getDimension(r.d.CardView_cardMaxElevation, 0.0f);
        this.f919a = typedArrayObtainStyledAttributes.getBoolean(r.d.CardView_cardUseCompatPadding, false);
        this.f920b = typedArrayObtainStyledAttributes.getBoolean(r.d.CardView_cardPreventCornerOverlap, true);
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_contentPadding, 0);
        rect.left = typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_contentPaddingLeft, dimensionPixelSize);
        rect.top = typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_contentPaddingTop, dimensionPixelSize);
        rect.right = typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_contentPaddingRight, dimensionPixelSize);
        rect.bottom = typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_contentPaddingBottom, dimensionPixelSize);
        dimension3 = dimension2 > dimension3 ? dimension2 : dimension3;
        typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_android_minWidth, 0);
        typedArrayObtainStyledAttributes.getDimensionPixelSize(r.d.CardView_android_minHeight, 0);
        typedArrayObtainStyledAttributes.recycle();
        a aVar = f918g;
        d dVar = new d(dimension, colorStateListValueOf);
        d1Var.f19914b = dVar;
        ((CardView) d1Var.f19915c).setBackgroundDrawable(dVar);
        CardView cardView = (CardView) d1Var.f19915c;
        cardView.setClipToOutline(true);
        cardView.setElevation(dimension2);
        aVar.b(d1Var, dimension3);
    }
}
