package o; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.YuvImage; import android.os.Handler; import com.journeyapps.barcodescanner.BarcodeView; import com.journeyapps.barcodescanner.CameraPreview; import com.journeyapps.barcodescanner.DecoratedBarcodeView; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import o.C17083tlK; import o.C8820dWv; /* renamed from: o.dWv, reason: case insensitive filesystem */ /* loaded from: classes3.dex */ public final class C8820dWv { public DecoratedBarcodeView a; public boolean b; public C16303nKe d; public Activity e; public C15906jXf h; public Handler i; private final CameraPreview.Sts l; public int m = -1; public boolean k = false; /* renamed from: o, reason: collision with root package name */ public boolean f8858o = true; public String g = ""; public boolean f = false; boolean j = false; public InterfaceC15330gnf c = new AnonymousClass5(this); /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.dWv$5, reason: invalid class name */ /* loaded from: classes3.dex */ public final class AnonymousClass5 implements InterfaceC15330gnf { C8820dWv d; @Override // o.InterfaceC15330gnf public final void e(List list) { } AnonymousClass5(C8820dWv c8820dWv) { this.d = c8820dWv; } @Override // o.InterfaceC15330gnf public final void c(final C17725zIe c17725zIe) { this.d.a.d.e(); C16303nKe c16303nKe = this.d.d; synchronized (c16303nKe) { if (c16303nKe.c) { c16303nKe.NK_(); } boolean z = c16303nKe.b; } this.d.i.post(new Runnable(this, c17725zIe) { // from class: o.cHo private C8820dWv.AnonymousClass5 c; private C17725zIe d; @Override // java.lang.Runnable public final void run() { C8820dWv.AnonymousClass5 anonymousClass5 = this.c; C17725zIe c17725zIe2 = this.d; C8820dWv c8820dWv = anonymousClass5.d; String d = c8820dWv.d(c17725zIe2); Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.addFlags(524288); intent.putExtra("SCAN_RESULT", c17725zIe2.toString()); intent.putExtra("SCAN_RESULT_FORMAT", c17725zIe2.c.d.toString()); byte[] bArr = c17725zIe2.c.a; if (bArr != null && bArr.length > 0) { intent.putExtra("SCAN_RESULT_BYTES", bArr); } Map map = c17725zIe2.c.e; if (map != null) { if (map.containsKey(MoF.UPC_EAN_EXTENSION)) { intent.putExtra("SCAN_RESULT_UPC_EAN_EXTENSION", map.get(MoF.UPC_EAN_EXTENSION).toString()); } Number number = (Number) map.get(MoF.ORIENTATION); if (number != null) { intent.putExtra("SCAN_RESULT_ORIENTATION", number.intValue()); } String str = (String) map.get(MoF.ERROR_CORRECTION_LEVEL); if (str != null) { intent.putExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL", str); } Iterable iterable = (Iterable) map.get(MoF.BYTE_SEGMENTS); if (iterable != null) { Iterator it = iterable.iterator(); int i = 0; while (it.hasNext()) { intent.putExtra("SCAN_RESULT_BYTE_SEGMENTS_".concat(String.valueOf(i)), (byte[]) it.next()); i++; } } } if (d != null) { intent.putExtra("SCAN_RESULT_IMAGE_PATH", d); } c8820dWv.e.setResult(-1, intent); c8820dWv.e(); } { this.c = this; this.d = c17725zIe; } }); } } public C8820dWv(Activity activity, DecoratedBarcodeView decoratedBarcodeView) { CameraPreview.Sts sts = new CameraPreview.Sts(this) { // from class: o.dWv.4 private C8820dWv c; @Override // com.journeyapps.barcodescanner.CameraPreview.Sts public final void c() { } @Override // com.journeyapps.barcodescanner.CameraPreview.Sts public final void d() { } @Override // com.journeyapps.barcodescanner.CameraPreview.Sts public final void e() { } { this.c = this; } @Override // com.journeyapps.barcodescanner.CameraPreview.Sts public final void b() { if (this.c.j) { this.c.e.finish(); } } @Override // com.journeyapps.barcodescanner.CameraPreview.Sts public final void d(Exception exc) { C8820dWv c8820dWv = this.c; c8820dWv.d(c8820dWv.e.getString(C17083tlK.RVV.zxing_msg_camera_framework_bug)); } }; this.l = sts; this.b = false; this.e = activity; this.a = decoratedBarcodeView; ((BarcodeView) decoratedBarcodeView.findViewById(C17083tlK.LWm.zxing_barcode_surface)).h.add(sts); this.i = new Handler(); this.h = new C15906jXf(activity, new Runnable(this) { // from class: o.ilP private C8820dWv e; @Override // java.lang.Runnable public final void run() { this.e.e.finish(); } { this.e = this; } }); this.d = new C16303nKe(activity); } public final void d(int i, int[] iArr) { if (i == 250) { if (iArr.length > 0 && iArr[0] == 0) { this.a.d.i(); return; } Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("MISSING_CAMERA_PERMISSION", true); this.e.setResult(0, intent); if (this.f8858o) { d(this.g); } else { e(); } } } /* JADX INFO: Access modifiers changed from: package-private */ public final String d(C17725zIe c17725zIe) { if (this.k) { GuZ guZ = c17725zIe.b; Rect rect = new Rect(0, 0, guZ.d.d, guZ.d.a); YuvImage yuvImage = new YuvImage(guZ.d.e, guZ.c, guZ.d.d, guZ.d.a, null); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); yuvImage.compressToJpeg(rect, 90, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2; Bitmap decodeByteArray = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length, options); if (guZ.a != 0) { Matrix matrix = new Matrix(); matrix.postRotate(guZ.a); decodeByteArray = Bitmap.createBitmap(decodeByteArray, 0, 0, decodeByteArray.getWidth(), decodeByteArray.getHeight(), matrix, false); } try { File createTempFile = File.createTempFile("barcodeimage", ".jpg", this.e.getCacheDir()); FileOutputStream fileOutputStream = new FileOutputStream(createTempFile); decodeByteArray.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); fileOutputStream.close(); return createTempFile.getAbsolutePath(); } catch (IOException unused) { } } return null; } protected final void d(String str) { if (this.e.isFinishing() || this.f || this.j) { return; } if (str.isEmpty()) { str = this.e.getString(C17083tlK.RVV.zxing_msg_camera_framework_bug); } AlertDialog.Builder builder = new AlertDialog.Builder(this.e); builder.setTitle(this.e.getString(C17083tlK.RVV.zxing_app_name)); builder.setMessage(str); builder.setPositiveButton(C17083tlK.RVV.zxing_button_ok, new DialogInterface.OnClickListener(this) { // from class: o.AvV private C8820dWv d; @Override // android.content.DialogInterface.OnClickListener public final void onClick(DialogInterface dialogInterface, int i) { this.d.e.finish(); } { this.d = this; } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener(this) { // from class: o.QcO private C8820dWv e; @Override // android.content.DialogInterface.OnCancelListener public final void onCancel(DialogInterface dialogInterface) { this.e.e.finish(); } { this.e = this; } }); builder.show(); } /* JADX INFO: Access modifiers changed from: package-private */ public final void e() { C12047eqo c12047eqo = ((BarcodeView) this.a.findViewById(C17083tlK.LWm.zxing_barcode_surface)).a; if (c12047eqo != null && !c12047eqo.d) { this.j = true; } else { this.e.finish(); } this.a.d.e(); this.h.d(); } }