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.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.util.AttributeSet; import android.view.View; import android.view.ViewOutlineProvider; import androidx.annotation.RequiresApi; import androidx.appcompat.widget.AppCompatImageButton; import androidx.constraintlayout.utils.widget.ImageFilterView; import androidx.constraintlayout.widget.R; public class ImageFilterButton extends AppCompatImageButton { private float mCrossfade = 0.0f; private ImageFilterView.ImageMatrix mImageMatrix = new ImageFilterView.ImageMatrix(); public LayerDrawable mLayer; public Drawable[] mLayers; private boolean mOverlay = true; private Path mPath; public RectF mRect; private float mRound = Float.NaN; private float mRoundPercent = 0.0f; public ViewOutlineProvider mViewOutlineProvider; /* renamed from: androidx.constraintlayout.utils.widget.ImageFilterButton$1 reason: invalid class name */ public class AnonymousClass1 extends ViewOutlineProvider { public AnonymousClass1() { } @Override // android.view.ViewOutlineProvider public void getOutline(View view, Outline outline) { int width = ImageFilterButton.this.getWidth(); int height = ImageFilterButton.this.getHeight(); outline.setRoundRect(0, 0, width, height, (ImageFilterButton.access$000(ImageFilterButton.this) * ((float) Math.min(width, height))) / 2.0f); } } /* renamed from: androidx.constraintlayout.utils.widget.ImageFilterButton$2 reason: invalid class name */ public class AnonymousClass2 extends ViewOutlineProvider { public AnonymousClass2() { } @Override // android.view.ViewOutlineProvider public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, ImageFilterButton.this.getWidth(), ImageFilterButton.this.getHeight(), ImageFilterButton.access$100(ImageFilterButton.this)); } } public ImageFilterButton(Context context) { super(context); init(context, null); } public ImageFilterButton(Context context, AttributeSet attributeSet) { super(context, attributeSet); init(context, attributeSet); } public ImageFilterButton(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); init(context, attributeSet); } public static /* synthetic */ float access$000(ImageFilterButton imageFilterButton) { return imageFilterButton.mRoundPercent; } public static /* synthetic */ float access$100(ImageFilterButton imageFilterButton) { return imageFilterButton.mRound; } private void init(Context context, AttributeSet attributeSet) { setPadding(0, 0, 0, 0); if (attributeSet != null) { TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.styleable.ImageFilterView); int indexCount = obtainStyledAttributes.getIndexCount(); Drawable drawable = obtainStyledAttributes.getDrawable(R.styleable.ImageFilterView_altSrc); for (int i = 0; i < indexCount; i++) { int index = obtainStyledAttributes.getIndex(i); if (index == R.styleable.ImageFilterView_crossfade) { this.mCrossfade = obtainStyledAttributes.getFloat(index, 0.0f); } else if (index == R.styleable.ImageFilterView_warmth) { setWarmth(obtainStyledAttributes.getFloat(index, 0.0f)); } else if (index == R.styleable.ImageFilterView_saturation) { setSaturation(obtainStyledAttributes.getFloat(index, 0.0f)); } else if (index == R.styleable.ImageFilterView_contrast) { setContrast(obtainStyledAttributes.getFloat(index, 0.0f)); } else if (index == R.styleable.ImageFilterView_round) { setRound(obtainStyledAttributes.getDimension(index, 0.0f)); } else if (index == R.styleable.ImageFilterView_roundPercent) { setRoundPercent(obtainStyledAttributes.getFloat(index, 0.0f)); } else if (index == R.styleable.ImageFilterView_overlay) { setOverlay(obtainStyledAttributes.getBoolean(index, this.mOverlay)); } } obtainStyledAttributes.recycle(); if (drawable != null) { Drawable[] drawableArr = new Drawable[2]; this.mLayers = drawableArr; drawableArr[0] = getDrawable(); this.mLayers[1] = drawable; LayerDrawable layerDrawable = new LayerDrawable(this.mLayers); this.mLayer = layerDrawable; layerDrawable.getDrawable(1).setAlpha((int) (this.mCrossfade * 255.0f)); super.setImageDrawable(this.mLayer); } } } private void setOverlay(boolean z2) { this.mOverlay = z2; } @Override // android.view.View public void draw(Canvas canvas) { super.draw(canvas); if (0 != 0) { canvas.restore(); } } public float getContrast() { return this.mImageMatrix.mContrast; } public float getCrossfade() { return this.mCrossfade; } public float getRound() { return this.mRound; } public float getRoundPercent() { return this.mRoundPercent; } public float getSaturation() { return this.mImageMatrix.mSaturation; } public float getWarmth() { return this.mImageMatrix.mWarmth; } public void setBrightness(float f) { ImageFilterView.ImageMatrix imageMatrix = this.mImageMatrix; imageMatrix.mBrightness = f; imageMatrix.updateMatrix(this); } public void setContrast(float f) { ImageFilterView.ImageMatrix imageMatrix = this.mImageMatrix; imageMatrix.mContrast = f; imageMatrix.updateMatrix(this); } public void setCrossfade(float f) { this.mCrossfade = f; if (this.mLayers != null) { if (!this.mOverlay) { this.mLayer.getDrawable(0).setAlpha((int) ((1.0f - this.mCrossfade) * 255.0f)); } this.mLayer.getDrawable(1).setAlpha((int) (this.mCrossfade * 255.0f)); super.setImageDrawable(this.mLayer); } } @RequiresApi(21) public void setRound(float f) { if (Float.isNaN(f)) { this.mRound = f; float f2 = this.mRoundPercent; this.mRoundPercent = -1.0f; setRoundPercent(f2); return; } boolean z2 = this.mRound != f; this.mRound = f; if (f != 0.0f) { if (this.mPath == null) { this.mPath = new Path(); } if (this.mRect == null) { this.mRect = new RectF(); } if (this.mViewOutlineProvider == null) { AnonymousClass2 r5 = new AnonymousClass2(); this.mViewOutlineProvider = r5; setOutlineProvider(r5); } 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 f3 = this.mRound; path.addRoundRect(rectF, f3, f3, Path.Direction.CW); } else { setClipToOutline(false); } if (z2) { invalidateOutline(); } } @RequiresApi(21) public void setRoundPercent(float f) { boolean z2 = this.mRoundPercent != f; this.mRoundPercent = f; if (f != 0.0f) { if (this.mPath == null) { this.mPath = new Path(); } if (this.mRect == null) { this.mRect = new RectF(); } if (this.mViewOutlineProvider == null) { AnonymousClass1 r6 = new AnonymousClass1(); this.mViewOutlineProvider = r6; setOutlineProvider(r6); } 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 { setClipToOutline(false); } if (z2) { invalidateOutline(); } } public void setSaturation(float f) { ImageFilterView.ImageMatrix imageMatrix = this.mImageMatrix; imageMatrix.mSaturation = f; imageMatrix.updateMatrix(this); } public void setWarmth(float f) { ImageFilterView.ImageMatrix imageMatrix = this.mImageMatrix; imageMatrix.mWarmth = f; imageMatrix.updateMatrix(this); } }