187 lines
6.6 KiB
Java
187 lines
6.6 KiB
Java
package e0.a.a.a;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.CornerPathEffect;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.Point;
|
|
import android.graphics.Rect;
|
|
import android.view.View;
|
|
import c.q.a.k.a;
|
|
import me.dm7.barcodescanner.core.R;
|
|
/* compiled from: ViewFinderView */
|
|
public class g extends View implements f {
|
|
public static final int[] i = {0, 64, 128, 192, 255, 192, 128, 64};
|
|
public Rect j;
|
|
public int k;
|
|
public final int l;
|
|
public final int m;
|
|
public final int n;
|
|
public final int o;
|
|
public final int p;
|
|
public Paint q;
|
|
public Paint r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public Paint f2694s;
|
|
public int t;
|
|
public boolean u;
|
|
public boolean v;
|
|
public int w = 0;
|
|
|
|
public g(Context context) {
|
|
super(context);
|
|
int color = getResources().getColor(R.a.viewfinder_laser);
|
|
this.l = color;
|
|
int color2 = getResources().getColor(R.a.viewfinder_mask);
|
|
this.m = color2;
|
|
int color3 = getResources().getColor(R.a.viewfinder_border);
|
|
this.n = color3;
|
|
int integer = getResources().getInteger(R.b.viewfinder_border_width);
|
|
this.o = integer;
|
|
int integer2 = getResources().getInteger(R.b.viewfinder_border_length);
|
|
this.p = integer2;
|
|
Paint paint = new Paint();
|
|
this.q = paint;
|
|
paint.setColor(color);
|
|
this.q.setStyle(Paint.Style.FILL);
|
|
Paint paint2 = new Paint();
|
|
this.r = paint2;
|
|
paint2.setColor(color2);
|
|
Paint paint3 = new Paint();
|
|
this.f2694s = paint3;
|
|
paint3.setColor(color3);
|
|
this.f2694s.setStyle(Paint.Style.STROKE);
|
|
this.f2694s.setStrokeWidth((float) integer);
|
|
this.f2694s.setAntiAlias(true);
|
|
this.t = integer2;
|
|
}
|
|
|
|
public synchronized void a() {
|
|
int i2;
|
|
int i3;
|
|
Point point = new Point(getWidth(), getHeight());
|
|
int v = a.v(getContext());
|
|
if (this.u) {
|
|
i3 = (int) (((float) (v != 1 ? getHeight() : getWidth())) * 0.625f);
|
|
i2 = i3;
|
|
} else if (v != 1) {
|
|
int height = (int) (((float) getHeight()) * 0.625f);
|
|
i2 = height;
|
|
i3 = (int) (((float) height) * 1.4f);
|
|
} else {
|
|
i3 = (int) (((float) getWidth()) * 0.75f);
|
|
i2 = (int) (((float) i3) * 0.75f);
|
|
}
|
|
if (i3 > getWidth()) {
|
|
i3 = getWidth() - 50;
|
|
}
|
|
if (i2 > getHeight()) {
|
|
i2 = getHeight() - 50;
|
|
}
|
|
int i4 = (point.x - i3) / 2;
|
|
int i5 = (point.y - i2) / 2;
|
|
int i6 = this.w;
|
|
this.j = new Rect(i4 + i6, i5 + i6, (i4 + i3) - i6, (i5 + i2) - i6);
|
|
}
|
|
|
|
public Rect getFramingRect() {
|
|
return this.j;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onDraw(Canvas canvas) {
|
|
if (getFramingRect() != null) {
|
|
int width = canvas.getWidth();
|
|
int height = canvas.getHeight();
|
|
Rect framingRect = getFramingRect();
|
|
float f = (float) width;
|
|
canvas.drawRect(0.0f, 0.0f, f, (float) framingRect.top, this.r);
|
|
canvas.drawRect(0.0f, (float) framingRect.top, (float) framingRect.left, (float) (framingRect.bottom + 1), this.r);
|
|
canvas.drawRect((float) (framingRect.right + 1), (float) framingRect.top, f, (float) (framingRect.bottom + 1), this.r);
|
|
canvas.drawRect(0.0f, (float) (framingRect.bottom + 1), f, (float) height, this.r);
|
|
Rect framingRect2 = getFramingRect();
|
|
Path path = new Path();
|
|
path.moveTo((float) framingRect2.left, (float) (framingRect2.top + this.t));
|
|
path.lineTo((float) framingRect2.left, (float) framingRect2.top);
|
|
path.lineTo((float) (framingRect2.left + this.t), (float) framingRect2.top);
|
|
canvas.drawPath(path, this.f2694s);
|
|
path.moveTo((float) framingRect2.right, (float) (framingRect2.top + this.t));
|
|
path.lineTo((float) framingRect2.right, (float) framingRect2.top);
|
|
path.lineTo((float) (framingRect2.right - this.t), (float) framingRect2.top);
|
|
canvas.drawPath(path, this.f2694s);
|
|
path.moveTo((float) framingRect2.right, (float) (framingRect2.bottom - this.t));
|
|
path.lineTo((float) framingRect2.right, (float) framingRect2.bottom);
|
|
path.lineTo((float) (framingRect2.right - this.t), (float) framingRect2.bottom);
|
|
canvas.drawPath(path, this.f2694s);
|
|
path.moveTo((float) framingRect2.left, (float) (framingRect2.bottom - this.t));
|
|
path.lineTo((float) framingRect2.left, (float) framingRect2.bottom);
|
|
path.lineTo((float) (framingRect2.left + this.t), (float) framingRect2.bottom);
|
|
canvas.drawPath(path, this.f2694s);
|
|
if (this.v) {
|
|
Rect framingRect3 = getFramingRect();
|
|
Paint paint = this.q;
|
|
int[] iArr = i;
|
|
paint.setAlpha(iArr[this.k]);
|
|
this.k = (this.k + 1) % iArr.length;
|
|
int height2 = (framingRect3.height() / 2) + framingRect3.top;
|
|
canvas.drawRect((float) (framingRect3.left + 2), (float) (height2 - 1), (float) (framingRect3.right - 1), (float) (height2 + 2), this.q);
|
|
postInvalidateDelayed(80, framingRect3.left - 10, framingRect3.top - 10, framingRect3.right + 10, framingRect3.bottom + 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onSizeChanged(int i2, int i3, int i4, int i5) {
|
|
a();
|
|
}
|
|
|
|
public void setBorderAlpha(float f) {
|
|
this.f2694s.setAlpha((int) (f * 255.0f));
|
|
}
|
|
|
|
public void setBorderColor(int i2) {
|
|
this.f2694s.setColor(i2);
|
|
}
|
|
|
|
public void setBorderCornerRadius(int i2) {
|
|
this.f2694s.setPathEffect(new CornerPathEffect((float) i2));
|
|
}
|
|
|
|
public void setBorderCornerRounded(boolean z2) {
|
|
if (z2) {
|
|
this.f2694s.setStrokeJoin(Paint.Join.ROUND);
|
|
} else {
|
|
this.f2694s.setStrokeJoin(Paint.Join.BEVEL);
|
|
}
|
|
}
|
|
|
|
public void setBorderLineLength(int i2) {
|
|
this.t = i2;
|
|
}
|
|
|
|
public void setBorderStrokeWidth(int i2) {
|
|
this.f2694s.setStrokeWidth((float) i2);
|
|
}
|
|
|
|
public void setLaserColor(int i2) {
|
|
this.q.setColor(i2);
|
|
}
|
|
|
|
public void setLaserEnabled(boolean z2) {
|
|
this.v = z2;
|
|
}
|
|
|
|
public void setMaskColor(int i2) {
|
|
this.r.setColor(i2);
|
|
}
|
|
|
|
public void setSquareViewFinder(boolean z2) {
|
|
this.u = z2;
|
|
}
|
|
|
|
public void setViewFinderOffset(int i2) {
|
|
this.w = i2;
|
|
}
|
|
}
|