content: 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.core.graphics.ColorUtils;
  import com.google.android.material.shape.ShapeAppearanceModel;
  import com.google.android.material.shape.ShapeAppearancePathProvider;
  
  class BorderDrawable extends Drawable {
      private static final float DRAW_STROKE_WIDTH_MULTIPLE = 1.3333f;
      private ColorStateList borderTint;
      float borderWidth;
      private int bottomInnerStrokeColor;
      private int bottomOuterStrokeColor;
      private final RectF boundsRectF = new RectF();
      private int currentBorderTintColor;
      private boolean invalidateShader = true;
      private final Paint paint;
      private final ShapeAppearancePathProvider pathProvider = ShapeAppearancePathProvider.getInstance();
      private final Rect rect = new Rect();
      private final RectF rectF = new RectF();
      private ShapeAppearanceModel shapeAppearanceModel;
      private final Path shapePath = new Path();
      private final BorderState state = new BorderState();
      private int topInnerStrokeColor;
      private int topOuterStrokeColor;
  
      private class BorderState extends Drawable.ConstantState {
          private BorderState() {
          }
  
          public int getChangingConfigurations() {
              return 0;
          }
  
          public Drawable newDrawable() {
              return BorderDrawable.this;
          }
      }
  
      BorderDrawable(ShapeAppearanceModel shapeAppearanceModel2) {
          this.shapeAppearanceModel = shapeAppearanceModel2;
          Paint paint2 = new Paint(1);
          this.paint = paint2;
          paint2.setStyle(Paint.Style.STROKE);
      }
  
      private Shader createGradientShader() {
          Rect rect2 = this.rect;
          copyBounds(rect2);
          float height = this.borderWidth / ((float) rect2.height());
          return new LinearGradient(0.0f, (float) rect2.top, 0.0f, (float) rect2.bottom, new int[]{ColorUtils.compositeColors(this.topOuterStrokeColor, this.currentBorderTintColor), ColorUtils.compositeColors(this.topInnerStrokeColor, this.currentBorderTintColor), ColorUtils.compositeColors(ColorUtils.setAlphaComponent(this.topInnerStrokeColor, 0), this.currentBorderTintColor), ColorUtils.compositeColors(ColorUtils.setAlphaComponent(this.bottomInnerStrokeColor, 0), this.currentBorderTintColor), ColorUtils.compositeColors(this.bottomInnerStrokeColor, this.currentBorderTintColor), ColorUtils.compositeColors(this.bottomOuterStrokeColor, this.currentBorderTintColor)}, new float[]{0.0f, height, 0.5f, 0.5f, 1.0f - height, 1.0f}, Shader.TileMode.CLAMP);
      }
  
      public void draw(Canvas canvas) {
          if (this.invalidateShader) {
              this.paint.setShader(createGradientShader());
              this.invalidateShader = false;
          }
          float strokeWidth = this.paint.getStrokeWidth() / 2.0f;
          copyBounds(this.rect);
          this.rectF.set(this.rect);
          float min = Math.min(this.shapeAppearanceModel.getTopLeftCornerSize().getCornerSize(getBoundsAsRectF()), this.rectF.width() / 2.0f);
          if (this.shapeAppearanceModel.isRoundRect(getBoundsAsRectF())) {
              this.rectF.inset(strokeWidth, strokeWidth);
              canvas.drawRoundRect(this.rectF, min, min, this.paint);
          }
      }
  
      /* access modifiers changed from: protected */
      public RectF getBoundsAsRectF() {
          this.boundsRectF.set(getBounds());
          return this.boundsRectF;
      }
  
      public Drawable.ConstantState getConstantState() {
          return this.state;
      }
  
      public int getOpacity() {
          return this.borderWidth > 0.0f ? -3 : -2;
      }
  
      public void getOutline(Outline outline) {
          if (this.shapeAppearanceModel.isRoundRect(getBoundsAsRectF())) {
              outline.setRoundRect(getBounds(), this.shapeAppearanceModel.getTopLeftCornerSize().getCornerSize(getBoundsAsRectF()));
              return;
          }
          copyBounds(this.rect);
          this.rectF.set(this.rect);
          this.pathProvider.calculatePath(this.shapeAppearanceModel, 1.0f, this.rectF, this.shapePath);
          if (this.shapePath.isConvex()) {
              outline.setConvexPath(this.shapePath);
          }
      }
  
      public boolean getPadding(Rect padding) {
          if (!this.shapeAppearanceModel.isRoundRect(getBoundsAsRectF())) {
              return true;
          }
          int round = Math.round(this.borderWidth);
          padding.set(round, round, round, round);
          return true;
      }
  
      public ShapeAppearanceModel getShapeAppearanceModel() {
          return this.shapeAppearanceModel;
      }
  
      public boolean isStateful() {
          ColorStateList colorStateList = this.borderTint;
          return (colorStateList != null && colorStateList.isStateful()) || super.isStateful();
      }
  
      /* access modifiers changed from: protected */
      public void onBoundsChange(Rect bounds) {
          this.invalidateShader = true;
      }
  
      /* access modifiers changed from: protected */
      public boolean onStateChange(int[] state2) {
          int colorForState;
          ColorStateList colorStateList = this.borderTint;
          if (!(colorStateList == null || (colorForState = colorStateList.getColorForState(state2, this.currentBorderTintColor)) == this.currentBorderTintColor)) {
              this.invalidateShader = true;
              this.currentBorderTintColor = colorForState;
          }
          if (this.invalidateShader) {
              invalidateSelf();
          }
          return this.invalidateShader;
      }
  
      public void setAlpha(int alpha) {
          this.paint.setAlpha(alpha);
          invalidateSelf();
      }
  
      /* access modifiers changed from: package-private */
      public void setBorderTint(ColorStateList tint) {
          if (tint != null) {
              this.currentBorderTintColor = tint.getColorForState(getState(), this.currentBorderTintColor);
          }
          this.borderTint = tint;
          this.invalidateShader = true;
          invalidateSelf();
      }
  
      public void setBorderWidth(float width) {
          if (this.borderWidth != width) {
              this.borderWidth = width;
              this.paint.setStrokeWidth(DRAW_STROKE_WIDTH_MULTIPLE * width);
              this.invalidateShader = true;
              invalidateSelf();
          }
      }
  
      public void setColorFilter(ColorFilter colorFilter) {
          this.paint.setColorFilter(colorFilter);
          invalidateSelf();
      }
  
      /* access modifiers changed from: package-private */
      public void setGradientColors(int topOuterStrokeColor2, int topInnerStrokeColor2, int bottomOuterStrokeColor2, int bottomInnerStrokeColor2) {
          this.topOuterStrokeColor = topOuterStrokeColor2;
          this.topInnerStrokeColor = topInnerStrokeColor2;
          this.bottomOuterStrokeColor = bottomOuterStrokeColor2;
          this.bottomInnerStrokeColor = bottomInnerStrokeColor2;
      }
  
      public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel2) {
          this.shapeAppearanceModel = shapeAppearanceModel2;
          invalidateSelf();
      }
  }
  