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 androidx.annotation.Nullable;
import com.google.android.material.shape.w;

/* JADX INFO: loaded from: classes2.dex */
public final class c extends Drawable {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Paint f22566b;

    @Nullable
    private ColorStateList borderTint;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public float f22572h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f22573i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f22574j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f22575k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f22576l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f22577m;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public com.google.android.material.shape.s f22579o;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final w f22565a = com.google.android.material.shape.t.f23163a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Path f22567c = new Path();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Rect f22568d = new Rect();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final RectF f22569e = new RectF();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final RectF f22570f = new RectF();

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final t3.e f22571g = new t3.e(this, 0);

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f22578n = true;

    public c(com.google.android.material.shape.s sVar) {
        this.f22579o = sVar;
        Paint paint = new Paint(1);
        this.f22566b = paint;
        paint.setStyle(Paint.Style.STROKE);
    }

    @Override // android.graphics.drawable.Drawable
    public final void draw(Canvas canvas) {
        boolean z10 = this.f22578n;
        Paint paint = this.f22566b;
        Rect rect = this.f22568d;
        if (z10) {
            copyBounds(rect);
            float fHeight = this.f22572h / rect.height();
            paint.setShader(new LinearGradient(0.0f, rect.top, 0.0f, rect.bottom, new int[]{j0.c.c(this.f22573i, this.f22577m), j0.c.c(this.f22574j, this.f22577m), j0.c.c(j0.c.e(this.f22574j, 0), this.f22577m), j0.c.c(j0.c.e(this.f22576l, 0), this.f22577m), j0.c.c(this.f22576l, this.f22577m), j0.c.c(this.f22575k, this.f22577m)}, new float[]{0.0f, fHeight, 0.5f, 0.5f, 1.0f - fHeight, 1.0f}, Shader.TileMode.CLAMP));
            this.f22578n = false;
        }
        float strokeWidth = paint.getStrokeWidth() / 2.0f;
        copyBounds(rect);
        RectF rectF = this.f22569e;
        rectF.set(rect);
        com.google.android.material.shape.d dVar = this.f22579o.f23155e;
        RectF rectF2 = this.f22570f;
        rectF2.set(getBounds());
        float fMin = Math.min(dVar.a(rectF2), rectF.width() / 2.0f);
        com.google.android.material.shape.s sVar = this.f22579o;
        rectF2.set(getBounds());
        if (sVar.g(rectF2)) {
            rectF.inset(strokeWidth, strokeWidth);
            canvas.drawRoundRect(rectF, fMin, fMin, paint);
        }
    }

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

    @Override // android.graphics.drawable.Drawable
    public final int getOpacity() {
        return this.f22572h > 0.0f ? -3 : -2;
    }

    @Override // android.graphics.drawable.Drawable
    public final void getOutline(Outline outline) {
        com.google.android.material.shape.s sVar = this.f22579o;
        RectF rectF = this.f22570f;
        rectF.set(getBounds());
        if (sVar.g(rectF)) {
            com.google.android.material.shape.d dVar = this.f22579o.f23155e;
            rectF.set(getBounds());
            outline.setRoundRect(getBounds(), dVar.a(rectF));
            return;
        }
        Rect rect = this.f22568d;
        copyBounds(rect);
        RectF rectF2 = this.f22569e;
        rectF2.set(rect);
        com.google.android.material.shape.s sVar2 = this.f22579o;
        Path path = this.f22567c;
        this.f22565a.calculatePath(sVar2, null, 1.0f, rectF2, null, path);
        j9.c.b(outline, path);
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean getPadding(Rect rect) {
        com.google.android.material.shape.s sVar = this.f22579o;
        RectF rectF = this.f22570f;
        rectF.set(getBounds());
        if (!sVar.g(rectF)) {
            return true;
        }
        int iRound = Math.round(this.f22572h);
        rect.set(iRound, iRound, iRound, iRound);
        return true;
    }

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

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

    @Override // android.graphics.drawable.Drawable
    public final boolean onStateChange(int[] iArr) {
        int colorForState;
        ColorStateList colorStateList = this.borderTint;
        if (colorStateList != null && (colorForState = colorStateList.getColorForState(iArr, this.f22577m)) != this.f22577m) {
            this.f22578n = true;
            this.f22577m = colorForState;
        }
        if (this.f22578n) {
            invalidateSelf();
        }
        return this.f22578n;
    }

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

    public void setBorderTint(@Nullable ColorStateList colorStateList) {
        if (colorStateList != null) {
            this.f22577m = colorStateList.getColorForState(getState(), this.f22577m);
        }
        this.borderTint = colorStateList;
        this.f22578n = true;
        invalidateSelf();
    }

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