186 lines
6.0 KiB
Java
186 lines
6.0 KiB
Java
package c.i.a.g.e;
|
|
|
|
import android.annotation.TargetApi;
|
|
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.ColorInt;
|
|
import androidx.annotation.Dimension;
|
|
import androidx.annotation.IntRange;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.graphics.ColorUtils;
|
|
import com.google.android.material.shape.ShapeAppearanceModel;
|
|
import com.google.android.material.shape.ShapeAppearancePathProvider;
|
|
/* compiled from: BorderDrawable */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
public class c extends Drawable {
|
|
public final ShapeAppearancePathProvider a = ShapeAppearancePathProvider.getInstance();
|
|
@NonNull
|
|
public final Paint b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final Path f1239c = new Path();
|
|
public final Rect d = new Rect();
|
|
public final RectF e = new RectF();
|
|
public final RectF f = new RectF();
|
|
public final b g = new b(null);
|
|
@Dimension
|
|
public float h;
|
|
@ColorInt
|
|
public int i;
|
|
@ColorInt
|
|
public int j;
|
|
@ColorInt
|
|
public int k;
|
|
@ColorInt
|
|
public int l;
|
|
@ColorInt
|
|
public int m;
|
|
public boolean n = true;
|
|
public ShapeAppearanceModel o;
|
|
@Nullable
|
|
public ColorStateList p;
|
|
|
|
/* compiled from: BorderDrawable */
|
|
public class b extends Drawable.ConstantState {
|
|
public b(a aVar) {
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
public int getChangingConfigurations() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
@NonNull
|
|
public Drawable newDrawable() {
|
|
return c.this;
|
|
}
|
|
}
|
|
|
|
public c(ShapeAppearanceModel shapeAppearanceModel) {
|
|
this.o = shapeAppearanceModel;
|
|
Paint paint = new Paint(1);
|
|
this.b = paint;
|
|
paint.setStyle(Paint.Style.STROKE);
|
|
}
|
|
|
|
@NonNull
|
|
public RectF a() {
|
|
this.f.set(getBounds());
|
|
return this.f;
|
|
}
|
|
|
|
public void b(@Nullable ColorStateList colorStateList) {
|
|
if (colorStateList != null) {
|
|
this.m = colorStateList.getColorForState(getState(), this.m);
|
|
}
|
|
this.p = colorStateList;
|
|
this.n = true;
|
|
invalidateSelf();
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void draw(@NonNull Canvas canvas) {
|
|
if (this.n) {
|
|
Paint paint = this.b;
|
|
Rect rect = this.d;
|
|
copyBounds(rect);
|
|
float height = this.h / ((float) rect.height());
|
|
paint.setShader(new LinearGradient(0.0f, (float) rect.top, 0.0f, (float) rect.bottom, new int[]{ColorUtils.compositeColors(this.i, this.m), ColorUtils.compositeColors(this.j, this.m), ColorUtils.compositeColors(ColorUtils.setAlphaComponent(this.j, 0), this.m), ColorUtils.compositeColors(ColorUtils.setAlphaComponent(this.l, 0), this.m), ColorUtils.compositeColors(this.l, this.m), ColorUtils.compositeColors(this.k, this.m)}, new float[]{0.0f, height, 0.5f, 0.5f, 1.0f - height, 1.0f}, Shader.TileMode.CLAMP));
|
|
this.n = false;
|
|
}
|
|
float strokeWidth = this.b.getStrokeWidth() / 2.0f;
|
|
copyBounds(this.d);
|
|
this.e.set(this.d);
|
|
float min = Math.min(this.o.getTopLeftCornerSize().getCornerSize(a()), this.e.width() / 2.0f);
|
|
if (this.o.isRoundRect(a())) {
|
|
this.e.inset(strokeWidth, strokeWidth);
|
|
canvas.drawRoundRect(this.e, min, min, this.b);
|
|
}
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
@Nullable
|
|
public Drawable.ConstantState getConstantState() {
|
|
return this.g;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public int getOpacity() {
|
|
return this.h > 0.0f ? -3 : -2;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
@TargetApi(21)
|
|
public void getOutline(@NonNull Outline outline) {
|
|
if (this.o.isRoundRect(a())) {
|
|
outline.setRoundRect(getBounds(), this.o.getTopLeftCornerSize().getCornerSize(a()));
|
|
return;
|
|
}
|
|
copyBounds(this.d);
|
|
this.e.set(this.d);
|
|
this.a.calculatePath(this.o, 1.0f, this.e, this.f1239c);
|
|
if (this.f1239c.isConvex()) {
|
|
outline.setConvexPath(this.f1239c);
|
|
}
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public boolean getPadding(@NonNull Rect rect) {
|
|
if (!this.o.isRoundRect(a())) {
|
|
return true;
|
|
}
|
|
int round = Math.round(this.h);
|
|
rect.set(round, round, round, round);
|
|
return true;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public boolean isStateful() {
|
|
ColorStateList colorStateList = this.p;
|
|
return (colorStateList != null && colorStateList.isStateful()) || super.isStateful();
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void onBoundsChange(Rect rect) {
|
|
this.n = true;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public boolean onStateChange(int[] iArr) {
|
|
int colorForState;
|
|
ColorStateList colorStateList = this.p;
|
|
if (!(colorStateList == null || (colorForState = colorStateList.getColorForState(iArr, this.m)) == this.m)) {
|
|
this.n = true;
|
|
this.m = colorForState;
|
|
}
|
|
if (this.n) {
|
|
invalidateSelf();
|
|
}
|
|
return this.n;
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void setAlpha(@IntRange(from = 0, to = 255) int i) {
|
|
this.b.setAlpha(i);
|
|
invalidateSelf();
|
|
}
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
|
this.b.setColorFilter(colorFilter);
|
|
invalidateSelf();
|
|
}
|
|
}
|