content: package androidx.constraintlayout.utils.widget;
  
  import android.content.Context;
  import android.content.res.TypedArray;
  import android.graphics.Canvas;
  import android.graphics.Outline;
  import android.graphics.Path;
  import android.graphics.RectF;
  import android.os.Build;
  import android.util.AttributeSet;
  import android.view.View;
  import android.view.ViewOutlineProvider;
  import androidx.appcompat.widget.AppCompatButton;
  import androidx.constraintlayout.widget.R;
  
  public class MotionButton extends AppCompatButton {
      private Path mPath;
      RectF mRect;
      /* access modifiers changed from: private */
      public float mRound = Float.NaN;
      /* access modifiers changed from: private */
      public float mRoundPercent = 0.0f;
      ViewOutlineProvider mViewOutlineProvider;
  
      public MotionButton(Context context) {
          super(context);
          init(context, (AttributeSet) null);
      }
  
      public MotionButton(Context context, AttributeSet attrs) {
          super(context, attrs);
          init(context, attrs);
      }
  
      public MotionButton(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          init(context, attrs);
      }
  
      private void init(Context context, AttributeSet attrs) {
          setPadding(0, 0, 0, 0);
          if (attrs != null) {
              TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.ImageFilterView);
              int indexCount = obtainStyledAttributes.getIndexCount();
              for (int i = 0; i < indexCount; i++) {
                  int index = obtainStyledAttributes.getIndex(i);
                  if (index == R.styleable.ImageFilterView_round) {
                      if (Build.VERSION.SDK_INT >= 21) {
                          setRound(obtainStyledAttributes.getDimension(index, 0.0f));
                      }
                  } else if (index == R.styleable.ImageFilterView_roundPercent && Build.VERSION.SDK_INT >= 21) {
                      setRoundPercent(obtainStyledAttributes.getFloat(index, 0.0f));
                  }
              }
              obtainStyledAttributes.recycle();
          }
      }
  
      public void draw(Canvas canvas) {
          boolean z = false;
          if (!(Build.VERSION.SDK_INT >= 21 || this.mRound == 0.0f || this.mPath == null)) {
              z = true;
              canvas.save();
              canvas.clipPath(this.mPath);
          }
          super.draw(canvas);
          if (z) {
              canvas.restore();
          }
      }
  
      public float getRound() {
          return this.mRound;
      }
  
      public float getRoundPercent() {
          return this.mRoundPercent;
      }
  
      public void setRound(float round) {
          if (Float.isNaN(round)) {
              this.mRound = round;
              float f = this.mRoundPercent;
              this.mRoundPercent = -1.0f;
              setRoundPercent(f);
              return;
          }
          boolean z = this.mRound != round;
          this.mRound = round;
          if (round != 0.0f) {
              if (this.mPath == null) {
                  this.mPath = new Path();
              }
              if (this.mRect == null) {
                  this.mRect = new RectF();
              }
              if (Build.VERSION.SDK_INT >= 21) {
                  if (this.mViewOutlineProvider == null) {
                      AnonymousClass2 r2 = new ViewOutlineProvider() {
                          public void getOutline(View view, Outline outline) {
                              outline.setRoundRect(0, 0, MotionButton.this.getWidth(), MotionButton.this.getHeight(), MotionButton.this.mRound);
                          }
                      };
                      this.mViewOutlineProvider = r2;
                      setOutlineProvider(r2);
                  }
                  setClipToOutline(true);
              }
              this.mRect.set(0.0f, 0.0f, (float) getWidth(), (float) getHeight());
              this.mPath.reset();
              Path path = this.mPath;
              RectF rectF = this.mRect;
              float f2 = this.mRound;
              path.addRoundRect(rectF, f2, f2, Path.Direction.CW);
          } else if (Build.VERSION.SDK_INT >= 21) {
              setClipToOutline(false);
          }
          if (z && Build.VERSION.SDK_INT >= 21) {
              invalidateOutline();
          }
      }
  
      public void setRoundPercent(float round) {
          boolean z = this.mRoundPercent != round;
          this.mRoundPercent = round;
          if (round != 0.0f) {
              if (this.mPath == null) {
                  this.mPath = new Path();
              }
              if (this.mRect == null) {
                  this.mRect = new RectF();
              }
              if (Build.VERSION.SDK_INT >= 21) {
                  if (this.mViewOutlineProvider == null) {
                      AnonymousClass1 r2 = new ViewOutlineProvider() {
                          public void getOutline(View view, Outline outline) {
                              int width = MotionButton.this.getWidth();
                              int height = MotionButton.this.getHeight();
                              outline.setRoundRect(0, 0, width, height, (((float) Math.min(width, height)) * MotionButton.this.mRoundPercent) / 2.0f);
                          }
                      };
                      this.mViewOutlineProvider = r2;
                      setOutlineProvider(r2);
                  }
                  setClipToOutline(true);
              }
              int width = getWidth();
              int height = getHeight();
              float min = (((float) Math.min(width, height)) * this.mRoundPercent) / 2.0f;
              this.mRect.set(0.0f, 0.0f, (float) width, (float) height);
              this.mPath.reset();
              this.mPath.addRoundRect(this.mRect, min, min, Path.Direction.CW);
          } else if (Build.VERSION.SDK_INT >= 21) {
              setClipToOutline(false);
          }
          if (z && Build.VERSION.SDK_INT >= 21) {
              invalidateOutline();
          }
      }
  }
  