discord-jadx/app/src/main/java/e0/a/a/a/a.java

261 lines
8.3 KiB
Java

package e0.a.a.a;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.hardware.Camera;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.annotation.ColorInt;
import me.dm7.barcodescanner.core.R;
/* compiled from: BarcodeScannerView */
public abstract class a extends FrameLayout implements Camera.PreviewCallback {
public int A = 0;
public float B = 0.1f;
public e i;
public d j;
public f k;
public Rect l;
public c m;
public Boolean n;
public boolean o = true;
public boolean p = true;
public boolean q = true;
@ColorInt
public int r = getResources().getColor(R.a.viewfinder_laser);
@ColorInt
/* renamed from: s reason: collision with root package name */
public int f2715s = getResources().getColor(R.a.viewfinder_border);
public int t = getResources().getColor(R.a.viewfinder_mask);
public int u = getResources().getInteger(R.b.viewfinder_border_width);
public int v = getResources().getInteger(R.b.viewfinder_border_length);
public boolean w = false;
/* renamed from: x reason: collision with root package name */
public int f2716x = 0;
/* renamed from: y reason: collision with root package name */
public boolean f2717y = false;
/* renamed from: z reason: collision with root package name */
public float f2718z = 1.0f;
/* JADX INFO: finally extract failed */
public a(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, R.c.BarcodeScannerView, 0, 0);
try {
setShouldScaleToFill(obtainStyledAttributes.getBoolean(R.c.BarcodeScannerView_shouldScaleToFill, true));
this.q = obtainStyledAttributes.getBoolean(R.c.BarcodeScannerView_laserEnabled, this.q);
this.r = obtainStyledAttributes.getColor(R.c.BarcodeScannerView_laserColor, this.r);
this.f2715s = obtainStyledAttributes.getColor(R.c.BarcodeScannerView_borderColor, this.f2715s);
this.t = obtainStyledAttributes.getColor(R.c.BarcodeScannerView_maskColor, this.t);
this.u = obtainStyledAttributes.getDimensionPixelSize(R.c.BarcodeScannerView_borderWidth, this.u);
this.v = obtainStyledAttributes.getDimensionPixelSize(R.c.BarcodeScannerView_borderLength, this.v);
this.w = obtainStyledAttributes.getBoolean(R.c.BarcodeScannerView_roundedCorner, this.w);
this.f2716x = obtainStyledAttributes.getDimensionPixelSize(R.c.BarcodeScannerView_cornerRadius, this.f2716x);
this.f2717y = obtainStyledAttributes.getBoolean(R.c.BarcodeScannerView_squaredFinder, this.f2717y);
this.f2718z = obtainStyledAttributes.getFloat(R.c.BarcodeScannerView_borderAlpha, this.f2718z);
this.A = obtainStyledAttributes.getDimensionPixelSize(R.c.BarcodeScannerView_finderOffset, this.A);
obtainStyledAttributes.recycle();
g gVar = new g(getContext());
gVar.setBorderColor(this.f2715s);
gVar.setLaserColor(this.r);
gVar.setLaserEnabled(this.q);
gVar.setBorderStrokeWidth(this.u);
gVar.setBorderLineLength(this.v);
gVar.setMaskColor(this.t);
gVar.setBorderCornerRounded(this.w);
gVar.setBorderCornerRadius(this.f2716x);
gVar.setSquareViewFinder(this.f2717y);
gVar.setViewFinderOffset(this.A);
this.k = gVar;
} catch (Throwable th) {
obtainStyledAttributes.recycle();
throw th;
}
}
public void a() {
if (this.i != null) {
this.j.e();
d dVar = this.j;
dVar.i = null;
dVar.o = null;
this.i.a.release();
this.i = null;
}
c cVar = this.m;
if (cVar != null) {
cVar.quit();
this.m = null;
}
}
public boolean getFlash() {
e eVar = this.i;
return eVar != null && c.q.a.k.a.D(eVar.a) && this.i.a.getParameters().getFlashMode().equals("torch");
}
public int getRotationCount() {
return this.j.getDisplayOrientation() / 90;
}
public void setAspectTolerance(float f) {
this.B = f;
}
public void setAutoFocus(boolean z2) {
this.o = z2;
d dVar = this.j;
if (dVar != null) {
dVar.setAutoFocus(z2);
}
}
public void setBorderAlpha(float f) {
this.f2718z = f;
((g) this.k).setBorderAlpha(f);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setBorderColor(int i) {
this.f2715s = i;
((g) this.k).setBorderColor(i);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setBorderCornerRadius(int i) {
this.f2716x = i;
((g) this.k).setBorderCornerRadius(i);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setBorderLineLength(int i) {
this.v = i;
((g) this.k).setBorderLineLength(i);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setBorderStrokeWidth(int i) {
this.u = i;
((g) this.k).setBorderStrokeWidth(i);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setFlash(boolean z2) {
this.n = Boolean.valueOf(z2);
e eVar = this.i;
if (eVar != null && c.q.a.k.a.D(eVar.a)) {
Camera.Parameters parameters = this.i.a.getParameters();
if (z2) {
if (!parameters.getFlashMode().equals("torch")) {
parameters.setFlashMode("torch");
} else {
return;
}
} else if (!parameters.getFlashMode().equals("off")) {
parameters.setFlashMode("off");
} else {
return;
}
this.i.a.setParameters(parameters);
}
}
public void setIsBorderCornerRounded(boolean z2) {
this.w = z2;
((g) this.k).setBorderCornerRounded(z2);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setLaserColor(int i) {
this.r = i;
((g) this.k).setLaserColor(i);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setLaserEnabled(boolean z2) {
this.q = z2;
((g) this.k).setLaserEnabled(z2);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setMaskColor(int i) {
this.t = i;
((g) this.k).setMaskColor(i);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setShouldScaleToFill(boolean z2) {
this.p = z2;
}
public void setSquareViewFinder(boolean z2) {
this.f2717y = z2;
((g) this.k).setSquareViewFinder(z2);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
}
public void setupCameraPreview(e eVar) {
this.i = eVar;
if (eVar != null) {
setupLayout(eVar);
g gVar = (g) this.k;
gVar.a();
gVar.invalidate();
Boolean bool = this.n;
if (bool != null) {
setFlash(bool.booleanValue());
}
setAutoFocus(this.o);
}
}
public final void setupLayout(e eVar) {
removeAllViews();
d dVar = new d(getContext(), eVar, this);
this.j = dVar;
dVar.setAspectTolerance(this.B);
this.j.setShouldScaleToFill(this.p);
if (!this.p) {
RelativeLayout relativeLayout = new RelativeLayout(getContext());
relativeLayout.setGravity(17);
relativeLayout.setBackgroundColor(-16777216);
relativeLayout.addView(this.j);
addView(relativeLayout);
} else {
addView(this.j);
}
f fVar = this.k;
if (fVar instanceof View) {
addView((View) fVar);
return;
}
throw new IllegalArgumentException("IViewFinder object returned by 'createViewFinderView()' should be instance of android.view.View");
}
}