alexandroid/decompiled/jadx/sources/androidx/constraintlayout/utils/widget/MockView.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

149 lines
6.3 KiB
Java

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.annotation.NonNull;
import androidx.constraintlayout.widget.R;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes13.dex */
public class MockView extends View {
private int mDiagonalsColor;
private boolean mDrawDiagonals;
private boolean mDrawLabel;
private int mMargin;
private Paint mPaintDiagonals;
private Paint mPaintText;
private Paint mPaintTextBackground;
protected String mText;
private int mTextBackgroundColor;
private Rect mTextBounds;
private int mTextColor;
public MockView(Context context) {
super(context);
this.mPaintDiagonals = new Paint();
this.mPaintText = new Paint();
this.mPaintTextBackground = new Paint();
this.mDrawDiagonals = true;
this.mDrawLabel = true;
this.mText = null;
this.mTextBounds = new Rect();
this.mDiagonalsColor = Color.argb(255, 0, 0, 0);
this.mTextColor = Color.argb(255, 200, 200, 200);
this.mTextBackgroundColor = Color.argb(255, 50, 50, 50);
this.mMargin = 4;
init(context, null);
}
private void init(Context context, AttributeSet attributeSet) {
if (attributeSet != null) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.MockView);
int indexCount = obtainStyledAttributes.getIndexCount();
for (int i = 0; i < indexCount; i++) {
int index = obtainStyledAttributes.getIndex(i);
if (index == R.styleable.MockView_mock_label) {
this.mText = obtainStyledAttributes.getString(index);
} else if (index == R.styleable.MockView_mock_showDiagonals) {
this.mDrawDiagonals = obtainStyledAttributes.getBoolean(index, this.mDrawDiagonals);
} else if (index == R.styleable.MockView_mock_diagonalsColor) {
this.mDiagonalsColor = obtainStyledAttributes.getColor(index, this.mDiagonalsColor);
} else if (index == R.styleable.MockView_mock_labelBackgroundColor) {
this.mTextBackgroundColor = obtainStyledAttributes.getColor(index, this.mTextBackgroundColor);
} else if (index == R.styleable.MockView_mock_labelColor) {
this.mTextColor = obtainStyledAttributes.getColor(index, this.mTextColor);
} else if (index == R.styleable.MockView_mock_showLabel) {
this.mDrawLabel = obtainStyledAttributes.getBoolean(index, this.mDrawLabel);
}
}
obtainStyledAttributes.recycle();
}
if (this.mText == null) {
try {
this.mText = context.getResources().getResourceEntryName(getId());
} catch (Exception unused) {
}
}
this.mPaintDiagonals.setColor(this.mDiagonalsColor);
this.mPaintDiagonals.setAntiAlias(true);
this.mPaintText.setColor(this.mTextColor);
this.mPaintText.setAntiAlias(true);
this.mPaintTextBackground.setColor(this.mTextBackgroundColor);
this.mMargin = Math.round((getResources().getDisplayMetrics().xdpi / 160.0f) * this.mMargin);
}
@Override // android.view.View
public void onDraw(@NonNull Canvas canvas) {
Canvas canvas2;
super.onDraw(canvas);
int width = getWidth();
int height = getHeight();
if (this.mDrawDiagonals) {
width--;
height--;
float f = width;
float f2 = height;
canvas2 = canvas;
canvas2.drawLine(0.0f, 0.0f, f, f2, this.mPaintDiagonals);
canvas2.drawLine(0.0f, f2, f, 0.0f, this.mPaintDiagonals);
canvas2.drawLine(0.0f, 0.0f, f, 0.0f, this.mPaintDiagonals);
canvas2.drawLine(f, 0.0f, f, f2, this.mPaintDiagonals);
canvas2.drawLine(f, f2, 0.0f, f2, this.mPaintDiagonals);
canvas2.drawLine(0.0f, f2, 0.0f, 0.0f, this.mPaintDiagonals);
} else {
canvas2 = canvas;
}
String str = this.mText;
if (str == null || !this.mDrawLabel) {
return;
}
this.mPaintText.getTextBounds(str, 0, str.length(), this.mTextBounds);
float width2 = (width - this.mTextBounds.width()) / 2.0f;
float height2 = ((height - this.mTextBounds.height()) / 2.0f) + this.mTextBounds.height();
this.mTextBounds.offset((int) width2, (int) height2);
Rect rect = this.mTextBounds;
int i = rect.left;
int i2 = this.mMargin;
rect.set(i - i2, rect.top - i2, rect.right + i2, rect.bottom + i2);
canvas2.drawRect(this.mTextBounds, this.mPaintTextBackground);
canvas2.drawText(this.mText, width2, height2, this.mPaintText);
}
public MockView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mPaintDiagonals = new Paint();
this.mPaintText = new Paint();
this.mPaintTextBackground = new Paint();
this.mDrawDiagonals = true;
this.mDrawLabel = true;
this.mText = null;
this.mTextBounds = new Rect();
this.mDiagonalsColor = Color.argb(255, 0, 0, 0);
this.mTextColor = Color.argb(255, 200, 200, 200);
this.mTextBackgroundColor = Color.argb(255, 50, 50, 50);
this.mMargin = 4;
init(context, attributeSet);
}
public MockView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mPaintDiagonals = new Paint();
this.mPaintText = new Paint();
this.mPaintTextBackground = new Paint();
this.mDrawDiagonals = true;
this.mDrawLabel = true;
this.mText = null;
this.mTextBounds = new Rect();
this.mDiagonalsColor = Color.argb(255, 0, 0, 0);
this.mTextColor = Color.argb(255, 200, 200, 200);
this.mTextBackgroundColor = Color.argb(255, 50, 50, 50);
this.mMargin = 4;
init(context, attributeSet);
}
}