package androidx.constraintlayout.utils.widget;

import a0.b;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.constraintlayout.widget.s;
import b0.e;
import d.a;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class MotionLabel extends View implements b {
    public float Q;
    public String R;
    public boolean S;
    public final Rect T;
    public int U;
    public int V;
    public int W;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final TextPaint f1215a;

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Path f1217b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public String f1218b0;

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f1223e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public boolean f1224e0;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public Drawable f1232i0;

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

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public Matrix f1234j0;

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

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public Bitmap f1236k0;

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

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public BitmapShader f1238l0;

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

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public Matrix f1240m0;

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

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

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

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

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

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

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public Rect f1247t0;

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    public Paint f1248u0;

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

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

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

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public float f1252y0;
    public float z0;

    public MotionLabel(Context context) {
        super(context);
        this.f1215a = new TextPaint();
        this.f1217b = new Path();
        this.f1219c = 65535;
        this.f1221d = 65535;
        this.f1223e = false;
        this.f1225f = 0.0f;
        this.f1227g = Float.NaN;
        this.f1233j = 48.0f;
        this.f1235k = Float.NaN;
        this.Q = 0.0f;
        this.R = "Hello World";
        this.S = true;
        this.T = new Rect();
        this.U = 1;
        this.V = 1;
        this.W = 1;
        this.f1216a0 = 1;
        this.f1220c0 = 8388659;
        this.f1222d0 = 0;
        this.f1224e0 = false;
        this.f1241n0 = Float.NaN;
        this.f1242o0 = Float.NaN;
        this.f1243p0 = 0.0f;
        this.f1244q0 = 0.0f;
        this.f1245r0 = new Paint();
        this.f1246s0 = 0;
        this.f1250w0 = Float.NaN;
        this.f1251x0 = Float.NaN;
        this.f1252y0 = Float.NaN;
        this.z0 = Float.NaN;
        b(context, null);
    }

    private float getHorizontalOffset() {
        float f10 = Float.isNaN(this.f1235k) ? 1.0f : this.f1233j / this.f1235k;
        String str = this.R;
        return ((this.f1243p0 + 1.0f) * ((((Float.isNaN(this.f1228g0) ? getMeasuredWidth() : this.f1228g0) - getPaddingLeft()) - getPaddingRight()) - (this.f1215a.measureText(str, 0, str.length()) * f10))) / 2.0f;
    }

    private float getVerticalOffset() {
        float f10 = Float.isNaN(this.f1235k) ? 1.0f : this.f1233j / this.f1235k;
        Paint.FontMetrics fontMetrics = this.f1215a.getFontMetrics();
        float measuredHeight = ((Float.isNaN(this.f1230h0) ? getMeasuredHeight() : this.f1230h0) - getPaddingTop()) - getPaddingBottom();
        float f11 = fontMetrics.descent;
        float f12 = fontMetrics.ascent;
        return (((1.0f - this.f1244q0) * (measuredHeight - ((f11 - f12) * f10))) / 2.0f) - (f10 * f12);
    }

    private void setUpTheme(Context context) {
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(a.colorPrimary, typedValue, true);
        int i10 = typedValue.data;
        this.f1219c = i10;
        this.f1215a.setColor(i10);
    }

    public final void a(float f10) {
        if (this.f1223e || f10 != 1.0f) {
            this.f1217b.reset();
            String str = this.R;
            int length = str.length();
            TextPaint textPaint = this.f1215a;
            Rect rect = this.T;
            textPaint.getTextBounds(str, 0, length, rect);
            this.f1215a.getTextPath(str, 0, length, 0.0f, 0.0f, this.f1217b);
            if (f10 != 1.0f) {
                o6.b.n();
                Matrix matrix = new Matrix();
                matrix.postScale(f10, f10);
                this.f1217b.transform(matrix);
            }
            rect.right--;
            rect.left++;
            rect.bottom++;
            rect.top--;
            RectF rectF = new RectF();
            rectF.bottom = getHeight();
            rectF.right = getWidth();
            this.S = false;
        }
    }

    public final void b(Context context, AttributeSet attributeSet) {
        Typeface typefaceCreate;
        setUpTheme(context);
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, s.MotionLabel);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i10 = 0; i10 < indexCount; i10++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i10);
                if (index == s.MotionLabel_android_text) {
                    setText(typedArrayObtainStyledAttributes.getText(index));
                } else if (index == s.MotionLabel_android_fontFamily) {
                    this.f1218b0 = typedArrayObtainStyledAttributes.getString(index);
                } else if (index == s.MotionLabel_scaleFromTextSize) {
                    this.f1235k = typedArrayObtainStyledAttributes.getDimensionPixelSize(index, (int) this.f1235k);
                } else if (index == s.MotionLabel_android_textSize) {
                    this.f1233j = typedArrayObtainStyledAttributes.getDimensionPixelSize(index, (int) this.f1233j);
                } else if (index == s.MotionLabel_android_textStyle) {
                    this.f1237l = typedArrayObtainStyledAttributes.getInt(index, this.f1237l);
                } else if (index == s.MotionLabel_android_typeface) {
                    this.f1239m = typedArrayObtainStyledAttributes.getInt(index, this.f1239m);
                } else if (index == s.MotionLabel_android_textColor) {
                    this.f1219c = typedArrayObtainStyledAttributes.getColor(index, this.f1219c);
                } else if (index == s.MotionLabel_borderRound) {
                    float dimension = typedArrayObtainStyledAttributes.getDimension(index, this.f1227g);
                    this.f1227g = dimension;
                    setRound(dimension);
                } else if (index == s.MotionLabel_borderRoundPercent) {
                    float f10 = typedArrayObtainStyledAttributes.getFloat(index, this.f1225f);
                    this.f1225f = f10;
                    setRoundPercent(f10);
                } else if (index == s.MotionLabel_android_gravity) {
                    setGravity(typedArrayObtainStyledAttributes.getInt(index, -1));
                } else if (index == s.MotionLabel_android_autoSizeTextType) {
                    this.f1222d0 = typedArrayObtainStyledAttributes.getInt(index, 0);
                } else if (index == s.MotionLabel_textOutlineColor) {
                    this.f1221d = typedArrayObtainStyledAttributes.getInt(index, this.f1221d);
                    this.f1223e = true;
                } else if (index == s.MotionLabel_textOutlineThickness) {
                    this.Q = typedArrayObtainStyledAttributes.getDimension(index, this.Q);
                    this.f1223e = true;
                } else if (index == s.MotionLabel_textBackground) {
                    this.f1232i0 = typedArrayObtainStyledAttributes.getDrawable(index);
                    this.f1223e = true;
                } else if (index == s.MotionLabel_textBackgroundPanX) {
                    this.f1250w0 = typedArrayObtainStyledAttributes.getFloat(index, this.f1250w0);
                } else if (index == s.MotionLabel_textBackgroundPanY) {
                    this.f1251x0 = typedArrayObtainStyledAttributes.getFloat(index, this.f1251x0);
                } else if (index == s.MotionLabel_textPanX) {
                    this.f1243p0 = typedArrayObtainStyledAttributes.getFloat(index, this.f1243p0);
                } else if (index == s.MotionLabel_textPanY) {
                    this.f1244q0 = typedArrayObtainStyledAttributes.getFloat(index, this.f1244q0);
                } else if (index == s.MotionLabel_textBackgroundRotate) {
                    this.z0 = typedArrayObtainStyledAttributes.getFloat(index, this.z0);
                } else if (index == s.MotionLabel_textBackgroundZoom) {
                    this.f1252y0 = typedArrayObtainStyledAttributes.getFloat(index, this.f1252y0);
                } else if (index == s.MotionLabel_textureHeight) {
                    this.f1241n0 = typedArrayObtainStyledAttributes.getDimension(index, this.f1241n0);
                } else if (index == s.MotionLabel_textureWidth) {
                    this.f1242o0 = typedArrayObtainStyledAttributes.getDimension(index, this.f1242o0);
                } else if (index == s.MotionLabel_textureEffect) {
                    this.f1246s0 = typedArrayObtainStyledAttributes.getInt(index, this.f1246s0);
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }
        if (this.f1232i0 != null) {
            this.f1240m0 = new Matrix();
            int intrinsicWidth = this.f1232i0.getIntrinsicWidth();
            int intrinsicHeight = this.f1232i0.getIntrinsicHeight();
            if (intrinsicWidth <= 0 && (intrinsicWidth = getWidth()) == 0) {
                intrinsicWidth = Float.isNaN(this.f1242o0) ? 128 : (int) this.f1242o0;
            }
            if (intrinsicHeight <= 0 && (intrinsicHeight = getHeight()) == 0) {
                intrinsicHeight = Float.isNaN(this.f1241n0) ? 128 : (int) this.f1241n0;
            }
            if (this.f1246s0 != 0) {
                intrinsicWidth /= 2;
                intrinsicHeight /= 2;
            }
            this.f1236k0 = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(this.f1236k0);
            this.f1232i0.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            this.f1232i0.setFilterBitmap(true);
            this.f1232i0.draw(canvas);
            if (this.f1246s0 != 0) {
                Bitmap bitmap = this.f1236k0;
                int width = bitmap.getWidth() / 2;
                int height = bitmap.getHeight() / 2;
                Bitmap bitmapCreateScaledBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
                for (int i11 = 0; i11 < 4 && width >= 32 && height >= 32; i11++) {
                    width /= 2;
                    height /= 2;
                    bitmapCreateScaledBitmap = Bitmap.createScaledBitmap(bitmapCreateScaledBitmap, width, height, true);
                }
                this.f1236k0 = bitmapCreateScaledBitmap;
            }
            Bitmap bitmap2 = this.f1236k0;
            Shader.TileMode tileMode = Shader.TileMode.REPEAT;
            this.f1238l0 = new BitmapShader(bitmap2, tileMode, tileMode);
        }
        this.U = getPaddingLeft();
        this.V = getPaddingRight();
        this.W = getPaddingTop();
        this.f1216a0 = getPaddingBottom();
        String str = this.f1218b0;
        int i12 = this.f1239m;
        int i13 = this.f1237l;
        TextPaint textPaint = this.f1215a;
        if (str != null) {
            typefaceCreate = Typeface.create(str, i13);
            if (typefaceCreate != null) {
                setTypeface(typefaceCreate);
            }
            textPaint.setColor(this.f1219c);
            textPaint.setStrokeWidth(this.Q);
            textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            textPaint.setFlags(128);
            setTextSize(this.f1233j);
            textPaint.setAntiAlias(true);
        }
        typefaceCreate = null;
        if (i12 == 1) {
            typefaceCreate = Typeface.SANS_SERIF;
        } else if (i12 == 2) {
            typefaceCreate = Typeface.SERIF;
        } else if (i12 == 3) {
            typefaceCreate = Typeface.MONOSPACE;
        }
        if (i13 > 0) {
            Typeface typefaceDefaultFromStyle = typefaceCreate == null ? Typeface.defaultFromStyle(i13) : Typeface.create(typefaceCreate, i13);
            setTypeface(typefaceDefaultFromStyle);
            int i14 = (~(typefaceDefaultFromStyle != null ? typefaceDefaultFromStyle.getStyle() : 0)) & i13;
            textPaint.setFakeBoldText((i14 & 1) != 0);
            textPaint.setTextSkewX((i14 & 2) != 0 ? -0.25f : 0.0f);
        } else {
            textPaint.setFakeBoldText(false);
            textPaint.setTextSkewX(0.0f);
            setTypeface(typefaceCreate);
        }
        textPaint.setColor(this.f1219c);
        textPaint.setStrokeWidth(this.Q);
        textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        textPaint.setFlags(128);
        setTextSize(this.f1233j);
        textPaint.setAntiAlias(true);
    }

    public final void c(float f10, float f11, float f12, float f13) {
        int i10 = (int) (f10 + 0.5f);
        this.f1226f0 = f10 - i10;
        int i11 = (int) (f12 + 0.5f);
        int i12 = i11 - i10;
        int i13 = (int) (f13 + 0.5f);
        int i14 = (int) (0.5f + f11);
        int i15 = i13 - i14;
        float f14 = f12 - f10;
        this.f1228g0 = f14;
        float f15 = f13 - f11;
        this.f1230h0 = f15;
        if (this.f1240m0 != null) {
            this.f1228g0 = f14;
            this.f1230h0 = f15;
            d();
        }
        if (getMeasuredHeight() == i15 && getMeasuredWidth() == i12) {
            super.layout(i10, i14, i11, i13);
        } else {
            measure(View.MeasureSpec.makeMeasureSpec(i12, 1073741824), View.MeasureSpec.makeMeasureSpec(i15, 1073741824));
            super.layout(i10, i14, i11, i13);
        }
        if (this.f1224e0) {
            Rect rect = this.f1247t0;
            TextPaint textPaint = this.f1215a;
            if (rect == null) {
                this.f1248u0 = new Paint();
                this.f1247t0 = new Rect();
                this.f1248u0.set(textPaint);
                this.f1249v0 = this.f1248u0.getTextSize();
            }
            this.f1228g0 = f14;
            this.f1230h0 = f15;
            Paint paint = this.f1248u0;
            String str = this.R;
            paint.getTextBounds(str, 0, str.length(), this.f1247t0);
            float fHeight = this.f1247t0.height() * 1.3f;
            float f16 = (f14 - this.V) - this.U;
            float f17 = (f15 - this.f1216a0) - this.W;
            float fWidth = this.f1247t0.width();
            if (fWidth * f17 > fHeight * f16) {
                textPaint.setTextSize((this.f1249v0 * f16) / fWidth);
            } else {
                textPaint.setTextSize((this.f1249v0 * f17) / fHeight);
            }
            if (this.f1223e || !Float.isNaN(this.f1235k)) {
                a(Float.isNaN(this.f1235k) ? 1.0f : this.f1233j / this.f1235k);
            }
        }
    }

    public final void d() {
        float f10 = Float.isNaN(this.f1250w0) ? 0.0f : this.f1250w0;
        float f11 = Float.isNaN(this.f1251x0) ? 0.0f : this.f1251x0;
        float f12 = Float.isNaN(this.f1252y0) ? 1.0f : this.f1252y0;
        float f13 = Float.isNaN(this.z0) ? 0.0f : this.z0;
        this.f1240m0.reset();
        float width = this.f1236k0.getWidth();
        float height = this.f1236k0.getHeight();
        float f14 = Float.isNaN(this.f1242o0) ? this.f1228g0 : this.f1242o0;
        float f15 = Float.isNaN(this.f1241n0) ? this.f1230h0 : this.f1241n0;
        float f16 = f12 * (width * f15 < height * f14 ? f14 / width : f15 / height);
        this.f1240m0.postScale(f16, f16);
        float f17 = width * f16;
        float f18 = f14 - f17;
        float f19 = f16 * height;
        float f20 = f15 - f19;
        if (!Float.isNaN(this.f1241n0)) {
            f20 = this.f1241n0 / 2.0f;
        }
        if (!Float.isNaN(this.f1242o0)) {
            f18 = this.f1242o0 / 2.0f;
        }
        this.f1240m0.postTranslate((((f10 * f18) + f14) - f17) * 0.5f, (((f11 * f20) + f15) - f19) * 0.5f);
        this.f1240m0.postRotate(f13, f14 / 2.0f, f15 / 2.0f);
        this.f1238l0.setLocalMatrix(this.f1240m0);
    }

    public float getRound() {
        return this.f1227g;
    }

    public float getRoundPercent() {
        return this.f1225f;
    }

    public float getScaleFromTextSize() {
        return this.f1235k;
    }

    public float getTextBackgroundPanX() {
        return this.f1250w0;
    }

    public float getTextBackgroundPanY() {
        return this.f1251x0;
    }

    public float getTextBackgroundRotate() {
        return this.z0;
    }

    public float getTextBackgroundZoom() {
        return this.f1252y0;
    }

    public int getTextOutlineColor() {
        return this.f1221d;
    }

    public float getTextPanX() {
        return this.f1243p0;
    }

    public float getTextPanY() {
        return this.f1244q0;
    }

    public float getTextureHeight() {
        return this.f1241n0;
    }

    public float getTextureWidth() {
        return this.f1242o0;
    }

    public Typeface getTypeface() {
        return this.f1215a.getTypeface();
    }

    @Override // android.view.View
    public final void layout(int i10, int i11, int i12, int i13) {
        super.layout(i10, i11, i12, i13);
        boolean zIsNaN = Float.isNaN(this.f1235k);
        float f10 = zIsNaN ? 1.0f : this.f1233j / this.f1235k;
        this.f1228g0 = i12 - i10;
        this.f1230h0 = i13 - i11;
        if (this.f1224e0) {
            Rect rect = this.f1247t0;
            TextPaint textPaint = this.f1215a;
            if (rect == null) {
                this.f1248u0 = new Paint();
                this.f1247t0 = new Rect();
                this.f1248u0.set(textPaint);
                this.f1249v0 = this.f1248u0.getTextSize();
            }
            Paint paint = this.f1248u0;
            String str = this.R;
            paint.getTextBounds(str, 0, str.length(), this.f1247t0);
            int iWidth = this.f1247t0.width();
            int iHeight = (int) (this.f1247t0.height() * 1.3f);
            float f11 = (this.f1228g0 - this.V) - this.U;
            float f12 = (this.f1230h0 - this.f1216a0) - this.W;
            if (zIsNaN) {
                float f13 = iWidth;
                float f14 = iHeight;
                if (f13 * f12 > f14 * f11) {
                    textPaint.setTextSize((this.f1249v0 * f11) / f13);
                } else {
                    textPaint.setTextSize((this.f1249v0 * f12) / f14);
                }
            } else {
                float f15 = iWidth;
                float f16 = iHeight;
                f10 = f15 * f12 > f16 * f11 ? f11 / f15 : f12 / f16;
            }
        }
        if (this.f1223e || !zIsNaN) {
            float f17 = i10;
            float f18 = i11;
            float f19 = i12;
            float f20 = i13;
            if (this.f1240m0 != null) {
                this.f1228g0 = f19 - f17;
                this.f1230h0 = f20 - f18;
                d();
            }
            a(f10);
        }
    }

    @Override // android.view.View
    public final void onDraw(Canvas canvas) {
        float f10 = Float.isNaN(this.f1235k) ? 1.0f : this.f1233j / this.f1235k;
        super.onDraw(canvas);
        boolean z10 = this.f1223e;
        TextPaint textPaint = this.f1215a;
        if (!z10 && f10 == 1.0f) {
            canvas.drawText(this.R, this.f1226f0 + this.U + getHorizontalOffset(), this.W + getVerticalOffset(), textPaint);
            return;
        }
        if (this.S) {
            a(f10);
        }
        if (this.f1234j0 == null) {
            this.f1234j0 = new Matrix();
        }
        if (!this.f1223e) {
            float horizontalOffset = this.U + getHorizontalOffset();
            float verticalOffset = this.W + getVerticalOffset();
            this.f1234j0.reset();
            this.f1234j0.preTranslate(horizontalOffset, verticalOffset);
            this.f1217b.transform(this.f1234j0);
            textPaint.setColor(this.f1219c);
            textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            textPaint.setStrokeWidth(this.Q);
            canvas.drawPath(this.f1217b, textPaint);
            this.f1234j0.reset();
            this.f1234j0.preTranslate(-horizontalOffset, -verticalOffset);
            this.f1217b.transform(this.f1234j0);
            return;
        }
        Paint paint = this.f1245r0;
        paint.set(textPaint);
        this.f1234j0.reset();
        float horizontalOffset2 = this.U + getHorizontalOffset();
        float verticalOffset2 = this.W + getVerticalOffset();
        this.f1234j0.postTranslate(horizontalOffset2, verticalOffset2);
        this.f1234j0.preScale(f10, f10);
        this.f1217b.transform(this.f1234j0);
        if (this.f1238l0 != null) {
            textPaint.setFilterBitmap(true);
            textPaint.setShader(this.f1238l0);
        } else {
            textPaint.setColor(this.f1219c);
        }
        textPaint.setStyle(Paint.Style.FILL);
        textPaint.setStrokeWidth(this.Q);
        canvas.drawPath(this.f1217b, textPaint);
        if (this.f1238l0 != null) {
            textPaint.setShader(null);
        }
        textPaint.setColor(this.f1221d);
        textPaint.setStyle(Paint.Style.STROKE);
        textPaint.setStrokeWidth(this.Q);
        canvas.drawPath(this.f1217b, textPaint);
        this.f1234j0.reset();
        this.f1234j0.postTranslate(-horizontalOffset2, -verticalOffset2);
        this.f1217b.transform(this.f1234j0);
        textPaint.set(paint);
    }

    @Override // android.view.View
    public final void onMeasure(int i10, int i11) {
        int mode = View.MeasureSpec.getMode(i10);
        int mode2 = View.MeasureSpec.getMode(i11);
        int size = View.MeasureSpec.getSize(i10);
        int size2 = View.MeasureSpec.getSize(i11);
        this.f1224e0 = false;
        this.U = getPaddingLeft();
        this.V = getPaddingRight();
        this.W = getPaddingTop();
        this.f1216a0 = getPaddingBottom();
        if (mode != 1073741824 || mode2 != 1073741824) {
            String str = this.R;
            int length = str.length();
            this.f1215a.getTextBounds(str, 0, length, this.T);
            if (mode != 1073741824) {
                size = (int) (r7.width() + 0.99999f);
            }
            size += this.U + this.V;
            if (mode2 != 1073741824) {
                int fontMetricsInt = (int) (r6.getFontMetricsInt(null) + 0.99999f);
                if (mode2 == Integer.MIN_VALUE) {
                    fontMetricsInt = Math.min(size2, fontMetricsInt);
                }
                size2 = this.W + this.f1216a0 + fontMetricsInt;
            }
        } else if (this.f1222d0 != 0) {
            this.f1224e0 = true;
        }
        setMeasuredDimension(size, size2);
    }

    @SuppressLint({"RtlHardcoded"})
    public void setGravity(int i10) {
        if ((i10 & 8388615) == 0) {
            i10 |= 8388611;
        }
        if ((i10 & 112) == 0) {
            i10 |= 48;
        }
        if (i10 != this.f1220c0) {
            invalidate();
        }
        this.f1220c0 = i10;
        int i11 = i10 & 112;
        if (i11 == 48) {
            this.f1244q0 = -1.0f;
        } else if (i11 != 80) {
            this.f1244q0 = 0.0f;
        } else {
            this.f1244q0 = 1.0f;
        }
        int i12 = i10 & 8388615;
        if (i12 != 3) {
            if (i12 != 5) {
                if (i12 != 8388611) {
                    if (i12 != 8388613) {
                        this.f1243p0 = 0.0f;
                        return;
                    }
                }
            }
            this.f1243p0 = 1.0f;
            return;
        }
        this.f1243p0 = -1.0f;
    }

    @RequiresApi(21)
    public void setRound(float f10) {
        if (Float.isNaN(f10)) {
            this.f1227g = f10;
            float f11 = this.f1225f;
            this.f1225f = -1.0f;
            setRoundPercent(f11);
            return;
        }
        boolean z10 = this.f1227g != f10;
        this.f1227g = f10;
        if (f10 != 0.0f) {
            if (this.f1217b == null) {
                this.f1217b = new Path();
            }
            if (this.f1231i == null) {
                this.f1231i = new RectF();
            }
            if (this.f1229h == null) {
                e eVar = new e(this, 1);
                this.f1229h = eVar;
                setOutlineProvider(eVar);
            }
            setClipToOutline(true);
            this.f1231i.set(0.0f, 0.0f, getWidth(), getHeight());
            this.f1217b.reset();
            Path path = this.f1217b;
            RectF rectF = this.f1231i;
            float f12 = this.f1227g;
            path.addRoundRect(rectF, f12, f12, Path.Direction.CW);
        } else {
            setClipToOutline(false);
        }
        if (z10) {
            invalidateOutline();
        }
    }

    @RequiresApi(21)
    public void setRoundPercent(float f10) {
        boolean z10 = this.f1225f != f10;
        this.f1225f = f10;
        if (f10 != 0.0f) {
            if (this.f1217b == null) {
                this.f1217b = new Path();
            }
            if (this.f1231i == null) {
                this.f1231i = new RectF();
            }
            if (this.f1229h == null) {
                e eVar = new e(this, 0);
                this.f1229h = eVar;
                setOutlineProvider(eVar);
            }
            setClipToOutline(true);
            int width = getWidth();
            int height = getHeight();
            float fMin = (Math.min(width, height) * this.f1225f) / 2.0f;
            this.f1231i.set(0.0f, 0.0f, width, height);
            this.f1217b.reset();
            this.f1217b.addRoundRect(this.f1231i, fMin, fMin, Path.Direction.CW);
        } else {
            setClipToOutline(false);
        }
        if (z10) {
            invalidateOutline();
        }
    }

    public void setScaleFromTextSize(float f10) {
        this.f1235k = f10;
    }

    public void setText(CharSequence charSequence) {
        this.R = charSequence.toString();
        invalidate();
    }

    public void setTextBackgroundPanX(float f10) {
        this.f1250w0 = f10;
        d();
        invalidate();
    }

    public void setTextBackgroundPanY(float f10) {
        this.f1251x0 = f10;
        d();
        invalidate();
    }

    public void setTextBackgroundRotate(float f10) {
        this.z0 = f10;
        d();
        invalidate();
    }

    public void setTextBackgroundZoom(float f10) {
        this.f1252y0 = f10;
        d();
        invalidate();
    }

    public void setTextFillColor(int i10) {
        this.f1219c = i10;
        invalidate();
    }

    public void setTextOutlineColor(int i10) {
        this.f1221d = i10;
        this.f1223e = true;
        invalidate();
    }

    public void setTextOutlineThickness(float f10) {
        this.Q = f10;
        this.f1223e = true;
        if (Float.isNaN(f10)) {
            this.Q = 1.0f;
            this.f1223e = false;
        }
        invalidate();
    }

    public void setTextPanX(float f10) {
        this.f1243p0 = f10;
        invalidate();
    }

    public void setTextPanY(float f10) {
        this.f1244q0 = f10;
        invalidate();
    }

    public void setTextSize(float f10) {
        this.f1233j = f10;
        if (!Float.isNaN(this.f1235k)) {
            f10 = this.f1235k;
        }
        this.f1215a.setTextSize(f10);
        a(Float.isNaN(this.f1235k) ? 1.0f : this.f1233j / this.f1235k);
        requestLayout();
        invalidate();
    }

    public void setTextureHeight(float f10) {
        this.f1241n0 = f10;
        d();
        invalidate();
    }

    public void setTextureWidth(float f10) {
        this.f1242o0 = f10;
        d();
        invalidate();
    }

    public void setTypeface(Typeface typeface) {
        TextPaint textPaint = this.f1215a;
        if (Objects.equals(textPaint.getTypeface(), typeface)) {
            return;
        }
        textPaint.setTypeface(typeface);
    }

    public MotionLabel(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f1215a = new TextPaint();
        this.f1217b = new Path();
        this.f1219c = 65535;
        this.f1221d = 65535;
        this.f1223e = false;
        this.f1225f = 0.0f;
        this.f1227g = Float.NaN;
        this.f1233j = 48.0f;
        this.f1235k = Float.NaN;
        this.Q = 0.0f;
        this.R = "Hello World";
        this.S = true;
        this.T = new Rect();
        this.U = 1;
        this.V = 1;
        this.W = 1;
        this.f1216a0 = 1;
        this.f1220c0 = 8388659;
        this.f1222d0 = 0;
        this.f1224e0 = false;
        this.f1241n0 = Float.NaN;
        this.f1242o0 = Float.NaN;
        this.f1243p0 = 0.0f;
        this.f1244q0 = 0.0f;
        this.f1245r0 = new Paint();
        this.f1246s0 = 0;
        this.f1250w0 = Float.NaN;
        this.f1251x0 = Float.NaN;
        this.f1252y0 = Float.NaN;
        this.z0 = Float.NaN;
        b(context, attributeSet);
    }

    public MotionLabel(Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f1215a = new TextPaint();
        this.f1217b = new Path();
        this.f1219c = 65535;
        this.f1221d = 65535;
        this.f1223e = false;
        this.f1225f = 0.0f;
        this.f1227g = Float.NaN;
        this.f1233j = 48.0f;
        this.f1235k = Float.NaN;
        this.Q = 0.0f;
        this.R = "Hello World";
        this.S = true;
        this.T = new Rect();
        this.U = 1;
        this.V = 1;
        this.W = 1;
        this.f1216a0 = 1;
        this.f1220c0 = 8388659;
        this.f1222d0 = 0;
        this.f1224e0 = false;
        this.f1241n0 = Float.NaN;
        this.f1242o0 = Float.NaN;
        this.f1243p0 = 0.0f;
        this.f1244q0 = 0.0f;
        this.f1245r0 = new Paint();
        this.f1246s0 = 0;
        this.f1250w0 = Float.NaN;
        this.f1251x0 = Float.NaN;
        this.f1252y0 = Float.NaN;
        this.z0 = Float.NaN;
        b(context, attributeSet);
    }
}
