package o0;

import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import androidx.appcompat.widget.g;
import androidx.core.widget.d;
import com.google.android.material.internal.m;
import com.google.android.material.internal.o;
import l0.b;
import l0.j;
import l0.k;
import z0.c;

/* JADX INFO: compiled from: MaterialCheckBox.java */
/* JADX INFO: loaded from: classes.dex */
public class a extends g {

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private static final int f5747l = j.f5454i;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private static final int[][] f5748m = {new int[]{R.attr.state_enabled, R.attr.state_checked}, new int[]{R.attr.state_enabled, -16842912}, new int[]{-16842910, R.attr.state_checked}, new int[]{-16842910, -16842912}};

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private ColorStateList f5749i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private boolean f5750j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private boolean f5751k;

    public a(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, b.f5320c);
    }

    private ColorStateList getMaterialThemeColorsTintList() {
        if (this.f5749i == null) {
            int[][] iArr = f5748m;
            int[] iArr2 = new int[iArr.length];
            int iD = r0.a.d(this, b.f5323f);
            int iD2 = r0.a.d(this, b.f5328k);
            int iD3 = r0.a.d(this, b.f5325h);
            iArr2[0] = r0.a.h(iD2, iD, 1.0f);
            iArr2[1] = r0.a.h(iD2, iD3, 0.54f);
            iArr2[2] = r0.a.h(iD2, iD3, 0.38f);
            iArr2[3] = r0.a.h(iD2, iD3, 0.38f);
            this.f5749i = new ColorStateList(iArr, iArr2);
        }
        return this.f5749i;
    }

    @Override // android.widget.TextView, android.view.View
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (this.f5750j && d.b(this) == null) {
            setUseMaterialThemeColors(true);
        }
    }

    @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View
    protected void onDraw(Canvas canvas) {
        Drawable drawableA;
        if (!this.f5751k || !TextUtils.isEmpty(getText()) || (drawableA = d.a(this)) == null) {
            super.onDraw(canvas);
            return;
        }
        int width = ((getWidth() - drawableA.getIntrinsicWidth()) / 2) * (o.e(this) ? -1 : 1);
        int iSave = canvas.save();
        canvas.translate(width, 0.0f);
        super.onDraw(canvas);
        canvas.restoreToCount(iSave);
        if (getBackground() != null) {
            Rect bounds = drawableA.getBounds();
            androidx.core.graphics.drawable.a.l(getBackground(), bounds.left + width, bounds.top, bounds.right + width, bounds.bottom);
        }
    }

    public void setCenterIfNoTextEnabled(boolean z2) {
        this.f5751k = z2;
    }

    public void setUseMaterialThemeColors(boolean z2) {
        this.f5750j = z2;
        if (z2) {
            d.c(this, getMaterialThemeColorsTintList());
        } else {
            d.c(this, null);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public a(Context context, AttributeSet attributeSet, int i3) {
        int i4 = f5747l;
        super(e1.a.c(context, attributeSet, i3, i4), attributeSet, i3);
        Context context2 = getContext();
        TypedArray typedArrayH = m.h(context2, attributeSet, k.N1, i3, i4, new int[0]);
        int i5 = k.O1;
        if (typedArrayH.hasValue(i5)) {
            d.c(this, c.a(context2, typedArrayH, i5));
        }
        this.f5750j = typedArrayH.getBoolean(k.Q1, false);
        this.f5751k = typedArrayH.getBoolean(k.P1, true);
        typedArrayH.recycle();
    }
}
