package com.google.android.material.floatingactionbutton;

import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import lj.k;
import lj.l;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class a extends Drawable {

    /* renamed from: b, reason: collision with root package name */
    private final Paint f13218b;

    /* renamed from: h, reason: collision with root package name */
    float f13224h;

    /* renamed from: i, reason: collision with root package name */
    private int f13225i;

    /* renamed from: j, reason: collision with root package name */
    private int f13226j;

    /* renamed from: k, reason: collision with root package name */
    private int f13227k;

    /* renamed from: l, reason: collision with root package name */
    private int f13228l;

    /* renamed from: m, reason: collision with root package name */
    private int f13229m;

    /* renamed from: o, reason: collision with root package name */
    private k f13231o;

    /* renamed from: p, reason: collision with root package name */
    private ColorStateList f13232p;

    /* renamed from: a, reason: collision with root package name */
    private final l f13217a = l.k();

    /* renamed from: c, reason: collision with root package name */
    private final Path f13219c = new Path();

    /* renamed from: d, reason: collision with root package name */
    private final Rect f13220d = new Rect();

    /* renamed from: e, reason: collision with root package name */
    private final RectF f13221e = new RectF();

    /* renamed from: f, reason: collision with root package name */
    private final RectF f13222f = new RectF();

    /* renamed from: g, reason: collision with root package name */
    private final b f13223g = new b();

    /* renamed from: n, reason: collision with root package name */
    private boolean f13230n = true;

    /* loaded from: classes3.dex */
    private class b extends Drawable.ConstantState {
        private b() {
        }

        @Override // android.graphics.drawable.Drawable.ConstantState
        public int getChangingConfigurations() {
            return 0;
        }

        @Override // android.graphics.drawable.Drawable.ConstantState
        public Drawable newDrawable() {
            return a.this;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public a(k kVar) {
        this.f13231o = kVar;
        Paint paint = new Paint(1);
        this.f13218b = paint;
        paint.setStyle(Paint.Style.STROKE);
    }

    private Shader a() {
        copyBounds(this.f13220d);
        float height = this.f13224h / r0.height();
        return new LinearGradient(BitmapDescriptorFactory.HUE_RED, r0.top, BitmapDescriptorFactory.HUE_RED, r0.bottom, new int[]{androidx.core.graphics.a.f(this.f13225i, this.f13229m), androidx.core.graphics.a.f(this.f13226j, this.f13229m), androidx.core.graphics.a.f(androidx.core.graphics.a.j(this.f13226j, 0), this.f13229m), androidx.core.graphics.a.f(androidx.core.graphics.a.j(this.f13228l, 0), this.f13229m), androidx.core.graphics.a.f(this.f13228l, this.f13229m), androidx.core.graphics.a.f(this.f13227k, this.f13229m)}, new float[]{BitmapDescriptorFactory.HUE_RED, height, 0.5f, 0.5f, 1.0f - height, 1.0f}, Shader.TileMode.CLAMP);
    }

    protected RectF b() {
        this.f13222f.set(getBounds());
        return this.f13222f;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void c(ColorStateList colorStateList) {
        if (colorStateList != null) {
            this.f13229m = colorStateList.getColorForState(getState(), this.f13229m);
        }
        this.f13232p = colorStateList;
        this.f13230n = true;
        invalidateSelf();
    }

    public void d(float f10) {
        if (this.f13224h != f10) {
            this.f13224h = f10;
            this.f13218b.setStrokeWidth(f10 * 1.3333f);
            this.f13230n = true;
            invalidateSelf();
        }
    }

    @Override // android.graphics.drawable.Drawable
    public void draw(Canvas canvas) {
        if (this.f13230n) {
            this.f13218b.setShader(a());
            this.f13230n = false;
        }
        float strokeWidth = this.f13218b.getStrokeWidth() / 2.0f;
        copyBounds(this.f13220d);
        this.f13221e.set(this.f13220d);
        float min = Math.min(this.f13231o.r().a(b()), this.f13221e.width() / 2.0f);
        if (this.f13231o.u(b())) {
            this.f13221e.inset(strokeWidth, strokeWidth);
            canvas.drawRoundRect(this.f13221e, min, min, this.f13218b);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void e(int i10, int i11, int i12, int i13) {
        this.f13225i = i10;
        this.f13226j = i11;
        this.f13227k = i12;
        this.f13228l = i13;
    }

    public void f(k kVar) {
        this.f13231o = kVar;
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public Drawable.ConstantState getConstantState() {
        return this.f13223g;
    }

    @Override // android.graphics.drawable.Drawable
    public int getOpacity() {
        return this.f13224h > BitmapDescriptorFactory.HUE_RED ? -3 : -2;
    }

    @Override // android.graphics.drawable.Drawable
    public void getOutline(Outline outline) {
        if (this.f13231o.u(b())) {
            outline.setRoundRect(getBounds(), this.f13231o.r().a(b()));
            return;
        }
        copyBounds(this.f13220d);
        this.f13221e.set(this.f13220d);
        this.f13217a.d(this.f13231o, 1.0f, this.f13221e, this.f13219c);
        if (this.f13219c.isConvex()) {
            outline.setConvexPath(this.f13219c);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public boolean getPadding(Rect rect) {
        if (!this.f13231o.u(b())) {
            return true;
        }
        int round = Math.round(this.f13224h);
        rect.set(round, round, round, round);
        return true;
    }

    @Override // android.graphics.drawable.Drawable
    public boolean isStateful() {
        ColorStateList colorStateList = this.f13232p;
        return (colorStateList != null && colorStateList.isStateful()) || super.isStateful();
    }

    @Override // android.graphics.drawable.Drawable
    protected void onBoundsChange(Rect rect) {
        this.f13230n = true;
    }

    @Override // android.graphics.drawable.Drawable
    protected boolean onStateChange(int[] iArr) {
        int colorForState;
        ColorStateList colorStateList = this.f13232p;
        if (colorStateList != null && (colorForState = colorStateList.getColorForState(iArr, this.f13229m)) != this.f13229m) {
            this.f13230n = true;
            this.f13229m = colorForState;
        }
        if (this.f13230n) {
            invalidateSelf();
        }
        return this.f13230n;
    }

    @Override // android.graphics.drawable.Drawable
    public void setAlpha(int i10) {
        this.f13218b.setAlpha(i10);
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public void setColorFilter(ColorFilter colorFilter) {
        this.f13218b.setColorFilter(colorFilter);
        invalidateSelf();
    }
}
