package androidx.constraintlayout.utils.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import androidx.constraintlayout.widget.s;

/* JADX INFO: loaded from: classes.dex */
public class MockView extends View {

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

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final Rect f1205g;

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

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

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

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

    public MockView(Context context) {
        super(context);
        this.f1199a = new Paint();
        this.f1200b = new Paint();
        this.f1201c = new Paint();
        this.f1202d = true;
        this.f1203e = true;
        this.f1204f = null;
        this.f1205g = new Rect();
        this.f1206h = Color.argb(255, 0, 0, 0);
        this.f1207i = Color.argb(255, 200, 200, 200);
        this.f1208j = Color.argb(255, 50, 50, 50);
        this.f1209k = 4;
        a(context, null);
    }

    public final void a(Context context, AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, s.MockView);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i10 = 0; i10 < indexCount; i10++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i10);
                if (index == s.MockView_mock_label) {
                    this.f1204f = typedArrayObtainStyledAttributes.getString(index);
                } else if (index == s.MockView_mock_showDiagonals) {
                    this.f1202d = typedArrayObtainStyledAttributes.getBoolean(index, this.f1202d);
                } else if (index == s.MockView_mock_diagonalsColor) {
                    this.f1206h = typedArrayObtainStyledAttributes.getColor(index, this.f1206h);
                } else if (index == s.MockView_mock_labelBackgroundColor) {
                    this.f1208j = typedArrayObtainStyledAttributes.getColor(index, this.f1208j);
                } else if (index == s.MockView_mock_labelColor) {
                    this.f1207i = typedArrayObtainStyledAttributes.getColor(index, this.f1207i);
                } else if (index == s.MockView_mock_showLabel) {
                    this.f1203e = typedArrayObtainStyledAttributes.getBoolean(index, this.f1203e);
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }
        if (this.f1204f == null) {
            try {
                this.f1204f = context.getResources().getResourceEntryName(getId());
            } catch (Exception unused) {
            }
        }
        int i11 = this.f1206h;
        Paint paint = this.f1199a;
        paint.setColor(i11);
        paint.setAntiAlias(true);
        int i12 = this.f1207i;
        Paint paint2 = this.f1200b;
        paint2.setColor(i12);
        paint2.setAntiAlias(true);
        this.f1201c.setColor(this.f1208j);
        this.f1209k = Math.round((getResources().getDisplayMetrics().xdpi / 160.0f) * this.f1209k);
    }

    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int width = getWidth();
        int height = getHeight();
        if (this.f1202d) {
            width--;
            height--;
            float f10 = width;
            float f11 = height;
            canvas.drawLine(0.0f, 0.0f, f10, f11, this.f1199a);
            canvas.drawLine(0.0f, f11, f10, 0.0f, this.f1199a);
            canvas.drawLine(0.0f, 0.0f, f10, 0.0f, this.f1199a);
            canvas.drawLine(f10, 0.0f, f10, f11, this.f1199a);
            canvas.drawLine(f10, f11, 0.0f, f11, this.f1199a);
            canvas.drawLine(0.0f, f11, 0.0f, 0.0f, this.f1199a);
        }
        String str = this.f1204f;
        if (str == null || !this.f1203e) {
            return;
        }
        int length = str.length();
        Paint paint = this.f1200b;
        Rect rect = this.f1205g;
        paint.getTextBounds(str, 0, length, rect);
        float fWidth = (width - rect.width()) / 2.0f;
        float fHeight = ((height - rect.height()) / 2.0f) + rect.height();
        rect.offset((int) fWidth, (int) fHeight);
        int i10 = rect.left;
        int i11 = this.f1209k;
        rect.set(i10 - i11, rect.top - i11, rect.right + i11, rect.bottom + i11);
        canvas.drawRect(rect, this.f1201c);
        canvas.drawText(this.f1204f, fWidth, fHeight, paint);
    }

    public MockView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f1199a = new Paint();
        this.f1200b = new Paint();
        this.f1201c = new Paint();
        this.f1202d = true;
        this.f1203e = true;
        this.f1204f = null;
        this.f1205g = new Rect();
        this.f1206h = Color.argb(255, 0, 0, 0);
        this.f1207i = Color.argb(255, 200, 200, 200);
        this.f1208j = Color.argb(255, 50, 50, 50);
        this.f1209k = 4;
        a(context, attributeSet);
    }

    public MockView(Context context, AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f1199a = new Paint();
        this.f1200b = new Paint();
        this.f1201c = new Paint();
        this.f1202d = true;
        this.f1203e = true;
        this.f1204f = null;
        this.f1205g = new Rect();
        this.f1206h = Color.argb(255, 0, 0, 0);
        this.f1207i = Color.argb(255, 200, 200, 200);
        this.f1208j = Color.argb(255, 50, 50, 50);
        this.f1209k = 4;
        a(context, attributeSet);
    }
}
