package zi;

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.f;
import androidx.core.widget.d;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.material.internal.o;
import com.google.android.material.internal.q;
import ij.c;
import vi.b;
import vi.k;
import vi.l;

/* loaded from: classes3.dex */
public class a extends f {

    /* renamed from: w, reason: collision with root package name */
    private static final int f53469w = k.f39906u;

    /* renamed from: x, reason: collision with root package name */
    private static final int[][] f53470x = {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}};

    /* renamed from: t, reason: collision with root package name */
    private ColorStateList f53471t;

    /* renamed from: u, reason: collision with root package name */
    private boolean f53472u;

    /* renamed from: v, reason: collision with root package name */
    private boolean f53473v;

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

    private ColorStateList getMaterialThemeColorsTintList() {
        if (this.f53471t == null) {
            int[][] iArr = f53470x;
            int[] iArr2 = new int[iArr.length];
            int d10 = aj.a.d(this, b.f39730l);
            int d11 = aj.a.d(this, b.f39735q);
            int d12 = aj.a.d(this, b.f39732n);
            iArr2[0] = aj.a.h(d11, d10, 1.0f);
            iArr2[1] = aj.a.h(d11, d12, 0.54f);
            iArr2[2] = aj.a.h(d11, d12, 0.38f);
            iArr2[3] = aj.a.h(d11, d12, 0.38f);
            this.f53471t = new ColorStateList(iArr, iArr2);
        }
        return this.f53471t;
    }

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

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

    public void setCenterIfNoTextEnabled(boolean z10) {
        this.f53473v = z10;
    }

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

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public a(Context context, AttributeSet attributeSet, int i10) {
        super(nj.a.c(context, attributeSet, i10, r4), attributeSet, i10);
        int i11 = f53469w;
        Context context2 = getContext();
        TypedArray h10 = o.h(context2, attributeSet, l.f39997i4, i10, i11, new int[0]);
        int i12 = l.f40007j4;
        if (h10.hasValue(i12)) {
            d.c(this, c.a(context2, h10, i12));
        }
        this.f53472u = h10.getBoolean(l.f40027l4, false);
        this.f53473v = h10.getBoolean(l.f40017k4, true);
        h10.recycle();
    }
}
