导航菜单

页面标题

页面副标题

OVO v3.139.0 - HVDocsActivity.java 源代码

正在查看: OVO v3.139.0 应用的 HVDocsActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package co.hyperverge.hypersnapsdk.activities;

import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.graphics.RectF;
import android.hardware.Camera;
import android.hardware.SensorManager;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.ScaleAnimation;
import android.webkit.MimeTypeMap;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertController;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.b;
import androidx.constraintlayout.widget.ConstraintLayout;
import co.hyperverge.hvcamera.HVMagicView;
import co.hyperverge.hypersnapsdk.activities.HVDocsActivity;
import com.google.android.gms.internal.vision.zzk;
import com.google.android.material.bottomsheet.b;
import com.google.firebase.firestore.util.AsyncQueue;
import com.vkey.android.internal.vguard.webservice.VTrackResponseHandler;
import com.vkey.android.internal.vguard.webservice.VTrackWebService;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import o.i.Function110;
import o.i.av6;
import o.i.c4c;
import o.i.cv6;
import o.i.d1c;
import o.i.dc0;
import o.i.djj;
import o.i.dri;
import o.i.e41;
import o.i.ew6;
import o.i.fph;
import o.i.fvi;
import o.i.fxa;
import o.i.g3c;
import o.i.hfh;
import o.i.i17;
import o.i.ih6;
import o.i.j;
import o.i.j92;
import o.i.jh6;
import o.i.krj;
import o.i.lh6;
import o.i.lmi;
import o.i.mh6;
import o.i.mjj;
import o.i.n4h;
import o.i.n7c;
import o.i.nh6;
import o.i.o3j;
import o.i.oh6;
import o.i.oid;
import o.i.ph6;
import o.i.qxh;
import o.i.r20;
import o.i.r4i;
import o.i.r81;
import o.i.r89;
import o.i.reh;
import o.i.tx2;
import o.i.uac;
import o.i.ug6;
import o.i.uh;
import o.i.vg6;
import o.i.vk7;
import o.i.w1n;
import o.i.wg6;
import o.i.wh6;
import o.i.x1c;
import o.i.xg6;
import o.i.xh;
import o.i.xh6;
import o.i.xu6;
import o.i.y3h;
import o.i.yem;
import o.i.yg6;
import o.i.yih;
import o.i.z1d;
import o.i.zfi;
import org.json.JSONException;
import org.json.JSONObject;
import ovo.id.analytics.AnalyticType;
import ovo.id.billpayment.core.data.entity.response.ComponentResponse;
import ovo.id.billpayment.core.data.entity.response.FormActionResponse;
import ovo.id.billpayment.core.data.entity.response.FormPairValueResponse;
import ovo.id.billpayment.core.data.entity.response.FormPropertiesResponse;
import ovo.id.billpayment.core.data.entity.response.FormValidationResponse;
import ovo.id.billpayment.core.domain.entity.model.Category;
import ovo.id.billpayment.core.domain.entity.model.Inquiry;
import ovo.id.billpayment.ui.presentation.dynamicform.screen.PayBillFormActivity;
import ovo.id.billpayment.ui.presentation.form.emoney.fragment.EmoneyLandingFragment;
import ovo.id.billpayment.ui.presentation.inquiry.screen.InquiryPayBillFragment;
import ovo.id.kyc.upgrade.sdk.ui.presentation.fragment.IdCardProfileConfirmationFragment;
import ovo.id.loyalty.randomizecashback.ui.presentation.fragment.LandingRandomizedCashbackFragment;
import ovo.id.wallet.checkout.core.domain.entity.model.CheckoutSummaryData;
import ovo.id.wallet.payment.ui.qrinputnominal.InputNominalFragment;
import ovo.id.wallet.withdrawal.ui.presentation.CancelWithdrawalFragment;

public class HVDocsActivity extends co.hyperverge.hypersnapsdk.activities.c implements View.OnClickListener {
    public static av6 o1;
    public HVMagicView A0;
    public View B0;
    public View C0;
    public ew6 D0;
    public final a E0;
    public ConstraintLayout F0;
    public yg6.a G;
    public ImageView G0;
    public yg6 H;
    public ImageView H0;
    public TextView I0;
    public TextView J0;
    public co.hyperverge.hypersnapsdk.views.b K0;
    public co.hyperverge.hypersnapsdk.views.d L0;
    public File M0;
    public File N0;
    public boolean O0;
    public ph6 P;
    public SensorManager P0;
    public zfi Q0;
    public oh6 R0;
    public String S0;
    public String T0;
    public String U0;
    public Location V;
    public double V0;
    public final float[][] W;
    public String W0;
    public final float[][] X;
    public String X0;
    public final float[][] Y;
    public String Y0;
    public final float[][] Z;
    public File Z0;

    public File f972a1;
    public int b1;
    public int c1;
    public float d1;
    public float e1;

    public float f973f1;

    public AtomicBoolean f974g1;
    public int h1;
    public int i1;
    public final b j1;
    public float k1;
    public float l1;
    public final xh6 m1;
    public final ArrayList<wg6> n1;
    public final float[] u0;
    public final float[] v0;
    public final float[] w0;
    public final float[] x0;
    public FrameLayout y0;
    public FrameLayout z0;
    public final krj I = new krj();
    public final krj J = new krj();
    public final krj K = new krj();
    public final krj L = new krj();
    public final krj M = new krj();
    public final krj N = new krj();
    public final krj O = new krj();
    public final ug6 Q = new ug6();
    public boolean R = false;
    public final Handler S = new Handler();
    public String T = "";
    public int U = 0;

    public class a implements Animation.AnimationListener {
        public a() {
        }

        @Override
        public final void onAnimationEnd(Animation animation) {
            HVDocsActivity.this.B0.setVisibility(8);
        }

        @Override
        public final void onAnimationRepeat(Animation animation) {
        }

        @Override
        public final void onAnimationStart(Animation animation) {
            HVDocsActivity.this.B0.setVisibility(0);
        }
    }

    public class b extends xg6 {

        public class a implements g {
            public final r4i a;

            public final ProgressDialog f975b;

            public a(r4i r4iVar, ProgressDialog progressDialog) {
                this.a = r4iVar;
                this.f975b = progressDialog;
            }
        }

        public class RunnableC0061b implements Runnable {
            public final float a;

            public final float f976b;
            public final boolean c;

            public RunnableC0061b(float f, float f3, boolean z) {
                this.a = f;
                this.f976b = f3;
                this.c = z;
            }

            @Override
            public final void run() {
                boolean z = this.c;
                float f = this.f976b;
                b bVar = b.this;
                float f3 = this.a;
                if (f3 > 0.0f || f > 0.0f) {
                    HVDocsActivity.this.K0.a(f3 * r2.b1, f * r2.c1, z);
                } else {
                    HVDocsActivity.this.K0.a(r1.b1 / 2, r1.c1 / 2, z);
                }
            }
        }

        public class c implements Runnable {
            public c() {
            }

            @Override
            public final void run() {
                HVDocsActivity hVDocsActivity = HVDocsActivity.this;
                av6 av6Var = HVDocsActivity.o1;
                hVDocsActivity.getClass();
                AlphaAnimation alphaAnimation = new AlphaAnimation(0.6f, 0.0f);
                alphaAnimation.setDuration(300L);
                alphaAnimation.setInterpolator(new DecelerateInterpolator(2.0f));
                alphaAnimation.setFillAfter(true);
                alphaAnimation.setAnimationListener(hVDocsActivity.E0);
                hVDocsActivity.B0.startAnimation(alphaAnimation);
            }
        }

        public b() {
        }

        public static void A(b bVar, String str, String str2, String str3, ew6 ew6Var, r4i r4iVar, ProgressDialog progressDialog, JSONObject jSONObject) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            if (hVDocsActivity.H.isShouldReadQR()) {
                Bitmap decodeFile = BitmapFactory.decodeFile(str);
                try {
                    hVDocsActivity.T = hVDocsActivity.Q.a(decodeFile);
                } catch (NoClassDefFoundError unused) {
                    av6 av6Var = HVDocsActivity.o1;
                }
                JSONObject ocrParams = hVDocsActivity.H.getOcrParams();
                try {
                    ocrParams.put("qrString", hVDocsActivity.T);
                    hVDocsActivity.H.ocrParams = ocrParams.toString();
                } catch (Exception e) {
                    av6 av6Var2 = HVDocsActivity.o1;
                    fvi.d(e);
                }
                decodeFile.recycle();
            }
            r4iVar.c(str, str3, ew6Var);
            if (progressDialog.isShowing()) {
                progressDialog.cancel();
            }
            if (hVDocsActivity.H.shouldShowReviewScreen()) {
                hVDocsActivity.d1(str, str2);
            } else if (hVDocsActivity.H.isShouldDoOCR()) {
                hVDocsActivity.W0(str, str2);
            } else {
                hVDocsActivity.e1();
                hVDocsActivity.R0(null, new xh6(jSONObject, new JSONObject(), str, hVDocsActivity.T0));
            }
        }

        @Override
        public final void a() {
            new Handler(Looper.getMainLooper()).post(new c());
        }

        @Override
        public final void b() {
        }

        @Override
        public final File c() {
            return new File(HVDocsActivity.this.W0).getParentFile();
        }

        @Override
        public final String d() {
            return "IS_" + System.currentTimeMillis() + ".jpg";
        }

        @Override
        public final float e() {
            return 2.0f;
        }

        @Override
        public final float f() {
            return 2.0f;
        }

        @Override
        public final boolean g() {
            return HVDocsActivity.this.H.isShouldReadQR();
        }

        @Override
        public final void h() {
        }

        @Override
        public final void i() {
        }

        @Override
        public final void j() {
        }

        @Override
        public final void k() {
            HVDocsActivity.this.H.isShouldShowFlashIcon();
        }

        @Override
        public final void l() {
        }

        @Override
        public final void m() {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            try {
                if (hVDocsActivity.H.isShouldShowFlashIcon()) {
                    hVDocsActivity.G0.setVisibility(0);
                    hVDocsActivity.G0.setImageResource(g3c.ic_torch_off_svg);
                }
            } catch (Exception e) {
                av6 av6Var = HVDocsActivity.o1;
                fvi.d(e);
                if (djj.e().g != null) {
                    djj.e().g.a();
                }
            }
        }

        @Override
        public final void n() {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            try {
                if (hVDocsActivity.H.isShouldShowFlashIcon()) {
                    hVDocsActivity.G0.setVisibility(0);
                    hVDocsActivity.G0.setImageResource(g3c.ic_torch_on_svg);
                    if (r81.a || hVDocsActivity.A0 == null) {
                        return;
                    }
                    HVMagicView.b();
                }
            } catch (Exception e) {
                av6 av6Var = HVDocsActivity.o1;
                fvi.d(e);
                if (djj.e().g != null) {
                    djj.e().g.a();
                }
            }
        }

        @Override
        public final void o() {
        }

        @Override
        public final void p() {
            av6 av6Var = HVDocsActivity.o1;
            HVDocsActivity.this.L0(true);
        }

        @Override
        public final void q(byte[] bArr, int i, int i2, byte[] bArr2, int i3, int i4) {
        }

        @Override
        public final void r() {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            hVDocsActivity.f974g1.set(true);
            hVDocsActivity.P = new ph6(2, "failure logged in document onPictureFailed()");
            long longValue = hVDocsActivity.M.b().longValue();
            if (!djj.e().i() || djj.e().h == null) {
                return;
            }
            djj.e().h.r0(hVDocsActivity.P, longValue);
        }

        @Override
        public final void s(byte[] bArr) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            long longValue = hVDocsActivity.M.b().longValue();
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.y0(longValue);
            }
            r4i r4iVar = new r4i();
            r4iVar.d(bArr, hVDocsActivity.W0, hVDocsActivity.V);
            try {
                ProgressDialog progressDialog = new ProgressDialog(hVDocsActivity);
                progressDialog.setMessage(r20.d);
                progressDialog.setCancelable(false);
                progressDialog.show();
                hVDocsActivity.new h(bArr, new a(r4iVar, progressDialog)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
            } catch (Exception unused) {
                if (djj.e().g != null) {
                    djj.e().g.a();
                }
            }
        }

        @Override
        public final void t(File file) {
            long longValue = HVDocsActivity.this.M.b().longValue();
            if (!djj.e().i() || djj.e().h == null) {
                return;
            }
            djj.e().h.u0(file.getAbsolutePath(), longValue);
        }

        @Override
        public final void u(int i, int i2) {
        }

        @Override
        public final void v() {
        }

        @Override
        public final void w(int i, int i2) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            hVDocsActivity.c1 = i2;
            hVDocsActivity.b1 = i;
            hVDocsActivity.S0();
            hVDocsActivity.U0();
            hVDocsActivity.N0();
        }

        @Override
        public final void x() {
        }

        @Override
        public final void y(float f, float f3, boolean z) {
            new Handler(Looper.getMainLooper()).post(new RunnableC0061b(f, f3, z));
        }

        @Override
        public final void z() {
        }
    }

    public class c implements hfh {
        public final Context a;

        public c(Context context) {
            this.a = context;
        }

        @Override
        public final void a(Location location) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            if (location != null) {
                if (hVDocsActivity.H0 != null) {
                    hVDocsActivity.V0();
                }
                hVDocsActivity.V = location;
            } else {
                hVDocsActivity.V = y3h.b(this.a).a();
                if (hVDocsActivity.V == null || hVDocsActivity.H0 == null) {
                    return;
                }
                hVDocsActivity.V0();
            }
        }
    }

    public class d implements Runnable {
        public d() {
        }

        @Override
        public final void run() {
            if (djj.e().l) {
                HVDocsActivity hVDocsActivity = HVDocsActivity.this;
                hVDocsActivity.C0(hVDocsActivity.H, null);
            }
        }
    }

    public class e implements HVMagicView.a {
        public e() {
        }

        @Override
        public final void a() {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            hVDocsActivity.z0.getWidth();
            hVDocsActivity.z0.getHeight();
            hVDocsActivity.K0.a(hVDocsActivity.b1 / 2, hVDocsActivity.c1 / 2, false);
        }
    }

    public class f implements View.OnTouchListener {
        public boolean a;

        public f() {
        }

        @Override
        public final boolean onTouch(View view, MotionEvent motionEvent) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            if (!hVDocsActivity.H.isShouldAllowPhoneTilt() && hVDocsActivity.O0) {
                return false;
            }
            int action = motionEvent.getAction();
            if (action == 0) {
                this.a = hVDocsActivity.f974g1.get();
                if (!hVDocsActivity.f974g1.get()) {
                    return false;
                }
                ImageView imageView = hVDocsActivity.H0;
                imageView.clearAnimation();
                imageView.clearAnimation();
                ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.8f, 1.0f, 0.8f, 1, 0.5f, 1, 0.5f);
                scaleAnimation.setDuration(150L);
                scaleAnimation.setInterpolator(new AccelerateInterpolator());
                scaleAnimation.setFillAfter(true);
                imageView.startAnimation(scaleAnimation);
                hVDocsActivity.H0.startAnimation(scaleAnimation);
                return false;
            }
            if (action != 1 || !this.a) {
                return false;
            }
            ImageView imageView2 = hVDocsActivity.H0;
            imageView2.clearAnimation();
            hVDocsActivity.H0.clearAnimation();
            ScaleAnimation scaleAnimation2 = new ScaleAnimation(0.8f, 1.0f, 0.8f, 1.0f, 1, 0.5f, 1, 0.5f);
            scaleAnimation2.setDuration(150L);
            scaleAnimation2.setInterpolator(new AccelerateInterpolator());
            scaleAnimation2.setFillAfter(true);
            scaleAnimation2.setAnimationListener(new lh6());
            hVDocsActivity.H0.startAnimation(scaleAnimation2);
            imageView2.startAnimation(scaleAnimation2);
            return false;
        }
    }

    public interface g {
    }

    public class h extends AsyncTask<Void, Void, Void> {
        public final byte[] a;

        public final g f979b;
        public Bitmap c;

        public h(byte[] bArr, b.a aVar) {
            this.a = bArr;
            this.f979b = aVar;
        }

        public final Bitmap a(Bitmap bitmap) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            try {
                double width = bitmap.getWidth() * hVDocsActivity.G.getAspectRatio() * hVDocsActivity.H.padding;
                hVDocsActivity.X0();
                hVDocsActivity.Y0();
                if (!hVDocsActivity.H.isShouldSetPadding() || hVDocsActivity.G.getAspectRatio() > 1.0f) {
                    width = 0.0d;
                }
                hVDocsActivity.V0 = width;
                int Y0 = (int) (((int) (((hVDocsActivity.Y0() + hVDocsActivity.h1) / hVDocsActivity.c1) * bitmap.getHeight())) - width);
                if (Y0 < 0) {
                    Y0 = 0;
                }
                int X0 = (int) ((((int) (((hVDocsActivity.X0() + hVDocsActivity.h1) / hVDocsActivity.c1) * bitmap.getHeight())) - Y0) + width);
                if (X0 > bitmap.getHeight()) {
                    X0 = bitmap.getHeight();
                }
                if (Y0 + X0 > bitmap.getHeight()) {
                    Y0 = (int) (((hVDocsActivity.Y0() + hVDocsActivity.h1) / hVDocsActivity.c1) * bitmap.getHeight());
                    X0 = ((int) (((hVDocsActivity.X0() + hVDocsActivity.h1) / hVDocsActivity.c1) * bitmap.getHeight())) - Y0;
                    hVDocsActivity.H.setShouldAddPadding(false);
                }
                return Bitmap.createBitmap(bitmap, 0, Y0, bitmap.getWidth(), X0);
            } catch (Exception | OutOfMemoryError e) {
                av6 av6Var = HVDocsActivity.o1;
                fvi.d(e);
                if (djj.e().g == null) {
                    return null;
                }
                djj.e().g.a();
                return null;
            }
        }

        @Override
        public final Void doInBackground(Void[] voidArr) {
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            byte[] bArr = this.a;
            try {
                Bitmap f = lmi.f(BitmapFactory.decodeByteArray(bArr, 0, bArr.length), fvi.a(w1n.h(bArr)));
                if (f == null) {
                    return null;
                }
                Bitmap a = a(f);
                hVDocsActivity.f972a1 = new File(hVDocsActivity.Y0);
                FileOutputStream fileOutputStream = new FileOutputStream(hVDocsActivity.f972a1);
                a.compress(Bitmap.CompressFormat.JPEG, 95, fileOutputStream);
                fileOutputStream.close();
                if (hVDocsActivity.H.isShouldReadQR()) {
                    Bitmap b3 = fvi.b(a);
                    hVDocsActivity.Z0 = new File(hVDocsActivity.X0);
                    try {
                        if (b3 == null) {
                            return null;
                        }
                        try {
                            FileOutputStream fileOutputStream2 = new FileOutputStream(hVDocsActivity.Z0);
                            try {
                                b3.compress(Bitmap.CompressFormat.JPEG, 95, fileOutputStream2);
                                fileOutputStream2.close();
                            } catch (Throwable th) {
                                try {
                                    fileOutputStream2.close();
                                } catch (Throwable th2) {
                                    th.addSuppressed(th2);
                                }
                                throw th;
                            }
                        } catch (Exception e) {
                            av6 av6Var = HVDocsActivity.o1;
                            fvi.d(e);
                        }
                        b3.recycle();
                    } catch (Throwable th3) {
                        b3.recycle();
                        throw th3;
                    }
                }
                this.c = fvi.h(a);
                a.recycle();
                if (this.c == null) {
                    return null;
                }
                hVDocsActivity.M0 = new File(hVDocsActivity.W0);
                FileOutputStream fileOutputStream3 = new FileOutputStream(hVDocsActivity.M0);
                this.c.compress(Bitmap.CompressFormat.JPEG, 95, fileOutputStream3);
                fileOutputStream3.close();
                return null;
            } catch (Exception | OutOfMemoryError e2) {
                av6 av6Var2 = HVDocsActivity.o1;
                fvi.d(e2);
                if (djj.e().g == null) {
                    return null;
                }
                djj.e().g.a();
                return null;
            }
        }

        @Override
        public final void onPostExecute(Void r12) {
            Void r122 = r12;
            String str = HVDocsActivity.this.W0;
            Bitmap bitmap = this.c;
            b.a aVar = (b.a) this.f979b;
            aVar.getClass();
            File file = new File(str);
            b bVar = b.this;
            bVar.t(file);
            HVDocsActivity hVDocsActivity = HVDocsActivity.this;
            hVDocsActivity.f974g1.set(true);
            if (bitmap == null || !new File(str).exists()) {
                hVDocsActivity.e1();
                hVDocsActivity.R0(new ph6(2, "Error while capturing the document"), new xh6(null, null, null, hVDocsActivity.T0));
            } else {
                JSONObject jSONObject = new JSONObject();
                try {
                    if (hVDocsActivity.H.isShouldExportPDF()) {
                        String a = o3j.a(hVDocsActivity.N0.getPath() + "/hv_" + System.currentTimeMillis() + ".pdf", bitmap);
                        hVDocsActivity.S0 = a;
                        jSONObject.put("pdfUri", a);
                    }
                    String h = (hVDocsActivity.H.getOcrHeaders() == null || !hVDocsActivity.H.getOcrHeaders().has("transactionId")) ? mjj.h() : hVDocsActivity.H.getOcrHeaders().getString("transactionId");
                    if (djj.e().f().f()) {
                        new fph().a(new co.hyperverge.hypersnapsdk.activities.a(aVar, str, h, jSONObject));
                    } else {
                        b.A(bVar, str, hVDocsActivity.X0, h, null, aVar.a, aVar.f975b, jSONObject);
                    }
                } catch (Exception e) {
                    av6 av6Var = HVDocsActivity.o1;
                    fvi.d(e);
                    if (djj.e().g != null) {
                        djj.e().g.a();
                    }
                }
            }
            super.onPostExecute(r122);
        }
    }

    public HVDocsActivity() {
        Class cls = Float.TYPE;
        this.W = (float[][]) Array.newInstance((Class<?>) cls, 1, 1);
        this.X = (float[][]) Array.newInstance((Class<?>) cls, 1, 1);
        this.Y = new float[][]{new float[3]};
        this.Z = new float[][]{new float[3]};
        this.u0 = new float[3];
        this.v0 = new float[1];
        this.w0 = new float[1];
        this.x0 = new float[1];
        this.E0 = new a();
        this.O0 = false;
        this.h1 = 50;
        this.i1 = 35;
        this.j1 = new b();
        this.m1 = new xh6();
        this.n1 = new ArrayList<>();
    }

    public static void P0(ph6 ph6Var, xh6 xh6Var) {
        xu6.c().getClass();
        if (xu6.f6575b.isShouldUseSensorBiometrics() && djj.e().j != null) {
            djj.e().j.c();
        }
        av6 av6Var = o1;
        Context context = av6Var.a;
        vk7.f(context, "$context");
        String str = av6Var.b;
        vk7.f(str, "$documentType");
        Function110 function110 = av6Var.c;
        vk7.f(function110, "$onSuccess");
        Function110 function1102 = av6Var.d;
        vk7.f(function1102, "$onFailed");
        uh.a(context, new xh(AnalyticType.LEANPLUM_EVENT, "event/product_booking", r89.w(new fxa[]{new fxa("Trigger", "Button Click"), new fxa("Trigger Value", "Capture"), new fxa("Page", "KTP capture page"), new fxa("Product", "eKYC")}), 8));
        cv6.b(xh6Var, ph6Var, str, new cv6.a(function110), new cv6.b(function1102));
    }

    @Override
    public final vg6 B0() {
        return this.H;
    }

    @Override
    public final void E0() {
        if (this.H.isDocumentUploadEnabled() && this.F0.getVisibility() != 0) {
            e1();
            J0();
            return;
        }
        if (djj.e().i() && djj.e().h != null) {
            djj.e().h.g0();
        }
        e1();
        R0(new ph6(3, getString(uac.operation_cancelled)), new xh6(new JSONObject(), null, null, this.T0));
    }

    @Override
    public final boolean F0() {
        return this.H.isDocumentUploadEnabled() ? this.H.shouldShowCloseAlert() && this.F0.getVisibility() == 0 : this.H.shouldShowCloseAlert();
    }

    @Override
    public final void I0() {
        xu6.c().getClass();
        if (xu6.f6575b.isShouldUseSensorBiometrics()) {
            String l = fvi.l("doc");
            if (djj.e().j != null) {
                djj.e().j.g(l);
            }
            JSONObject ocrHeaders = this.H.getOcrHeaders();
            try {
                ocrHeaders.put("sensorDataZipFileName", l);
                this.H.ocrHeaders = ocrHeaders.toString();
            } catch (Exception e2) {
                fvi.d(e2);
            }
        }
        try {
            try {
                ug6 ug6Var = this.Q;
                Context applicationContext = getApplicationContext();
                ug6Var.getClass();
                if (applicationContext != null) {
                    new zzk().a = 6416;
                    ug6Var.a = new dc0(new yem(applicationContext));
                }
            } catch (Exception e3) {
                fvi.d(e3);
                if (djj.e().i() && djj.e().h != null) {
                    djj.e().h.F(new ph6(2, fvi.d(e3)));
                }
                if (djj.e().g != null) {
                    djj.e().g.a();
                }
                a1(new ph6(2, getResources().getString(uac.internal_error)));
                return;
            }
        } catch (NoClassDefFoundError unused) {
        }
        T0();
        C0(this.H, null);
        this.f974g1 = new AtomicBoolean(true);
        try {
            if (!this.H.isShouldAllowPhoneTilt()) {
                try {
                    this.P0 = (SensorManager) getSystemService("sensor");
                    this.R0 = new oh6(this);
                } catch (Exception e4) {
                    fvi.d(e4);
                    if (djj.e().g != null) {
                        djj.e().g.a();
                    }
                }
                SensorManager sensorManager = this.P0;
                sensorManager.registerListener(this.R0, sensorManager.getDefaultSensor(1), 3);
                SensorManager sensorManager2 = this.P0;
                sensorManager2.registerListener(this.R0, sensorManager2.getDefaultSensor(2), 3);
            }
        } catch (Exception e5) {
            fvi.d(e5);
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.F(new ph6(2, fvi.d(e5)));
            }
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        }
        if (!djj.e().i() || djj.e().h == null) {
            return;
        }
        long longValue = this.L.b().longValue();
        djj.e().h.C();
        djj.e().h.L(longValue);
        djj.e().h.y();
        this.O.c();
    }

    public final void J0() {
        krj krjVar = this.I;
        krjVar.c();
        final int i = 0;
        this.F0.setVisibility(0);
        C0(this.H, this.F0);
        this.F0.findViewById(c4c.ivClose).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Context context;
                int i2 = i;
                Object obj = this;
                switch (i2) {
                    case 0:
                        HVDocsActivity hVDocsActivity = (HVDocsActivity) obj;
                        av6 av6Var = HVDocsActivity.o1;
                        hVDocsActivity.getClass();
                        if (djj.e().i()) {
                            djj.e().a(hVDocsActivity.getApplicationContext()).g();
                        }
                        hVDocsActivity.onBackPressed();
                        break;
                    case 1:
                        EmoneyLandingFragment emoneyLandingFragment = (EmoneyLandingFragment) obj;
                        int i3 = EmoneyLandingFragment.z;
                        vk7.f(emoneyLandingFragment, "this$0");
                        lrc n0 = emoneyLandingFragment.n0();
                        Category category = ((rd0) emoneyLandingFragment.f0()).q;
                        String str = category != null ? category.a : null;
                        if (str == null) {
                            str = "";
                        }
                        lrc.x(n0, str, (String) null, (String) null, 6);
                        break;
                    case 2:
                        InquiryPayBillFragment inquiryPayBillFragment = (InquiryPayBillFragment) obj;
                        int i4 = InquiryPayBillFragment.y;
                        vk7.f(inquiryPayBillFragment, "this$0");
                        od7 od7Var = (od7) inquiryPayBillFragment.v.getValue();
                        ((ch0) od7Var).c.setValue(8);
                        Inquiry inquiry = od7Var.z;
                        if (inquiry != null) {
                            od7Var.s.setValue(inquiry);
                            break;
                        }
                        break;
                    case 3:
                        px6 px6Var = (px6) obj;
                        int i5 = IdCardProfileConfirmationFragment.l;
                        vk7.f(px6Var, "$this_with");
                        px6Var.w("MARITAL_STATUS");
                        break;
                    default:
                        InputNominalFragment inputNominalFragment = (InputNominalFragment) obj;
                        int i6 = InputNominalFragment.l;
                        vk7.f(inputNominalFragment, "this$0");
                        inputNominalFragment.c0();
                        CheckoutSummaryData checkoutSummaryData = inputNominalFragment.d0().K;
                        if (checkoutSummaryData != null && (context = inputNominalFragment.getContext()) != null) {
                            b a2 = id9.a(context, checkoutSummaryData);
                            a2.show();
                            inputNominalFragment.i = a2;
                            break;
                        }
                        break;
                }
            }
        });
        this.F0.findViewById(c4c.btnUploadDoc).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                FormActionResponse formActionResponse;
                FormValidationResponse formValidationResponse;
                String referenceViewId;
                FormPropertiesResponse properties;
                int i2 = i;
                Object obj = this;
                switch (i2) {
                    case 0:
                        HVDocsActivity hVDocsActivity = (HVDocsActivity) obj;
                        long longValue = hVDocsActivity.J.b().longValue();
                        if (djj.e().i()) {
                            djj.e().a(hVDocsActivity.getApplicationContext()).J(longValue);
                        }
                        Intent intent = new Intent("android.intent.action.GET_CONTENT");
                        intent.setType("*/*");
                        intent.putExtra("android.intent.extra.MIME_TYPES", new String[]{"image/*", "application/pdf"});
                        hVDocsActivity.startActivityForResult(intent, 1000);
                        return;
                    case 1:
                        PayBillFormActivity payBillFormActivity = (PayBillFormActivity) obj;
                        int i3 = PayBillFormActivity.R;
                        vk7.f(payBillFormActivity, "this$0");
                        s0b N0 = payBillFormActivity.N0();
                        ph5 ph5Var = (ph5) N0.v.getValue();
                        List<ComponentResponse> list = ph5Var != null ? ph5Var.b : null;
                        a0b a0bVar = (a0b) N0.x.getValue();
                        if (a0bVar == null || (formActionResponse = a0bVar.b) == null) {
                            return;
                        }
                        List params = formActionResponse.getParams();
                        ArrayList X0 = params != null ? ru1.X0(params) : new ArrayList();
                        if (list != null) {
                            for (ComponentResponse componentResponse : list) {
                                List validation = componentResponse.getValidation();
                                if (validation != null && (formValidationResponse = (FormValidationResponse) ru1.o0(validation)) != null && (referenceViewId = formValidationResponse.getReferenceViewId()) != null && (properties = componentResponse.getProperties()) != null) {
                                    String productId = properties.getProductId();
                                    if (productId == null && (productId = properties.getText()) == null) {
                                        productId = "";
                                    }
                                    X0.add(new FormPairValueResponse(referenceViewId, productId));
                                }
                            }
                        }
                        formActionResponse.setParams(X0);
                        N0.w(new h02(formActionResponse, -1, (String) null, 12));
                        return;
                    case 2:
                        EmoneyLandingFragment emoneyLandingFragment = (EmoneyLandingFragment) obj;
                        int i4 = EmoneyLandingFragment.z;
                        vk7.f(emoneyLandingFragment, "this$0");
                        emoneyLandingFragment.p0().Q(emoneyLandingFragment.h0(), false);
                        return;
                    case 3:
                        px6 px6Var = (px6) obj;
                        int i5 = IdCardProfileConfirmationFragment.l;
                        vk7.f(px6Var, "$this_with");
                        px6Var.w("OCCUPATION");
                        return;
                    case 4:
                        LandingRandomizedCashbackFragment landingRandomizedCashbackFragment = (LandingRandomizedCashbackFragment) obj;
                        int i6 = LandingRandomizedCashbackFragment.j;
                        vk7.f(landingRandomizedCashbackFragment, "this$0");
                        landingRandomizedCashbackFragment.c0(false);
                        return;
                    default:
                        CancelWithdrawalFragment cancelWithdrawalFragment = (CancelWithdrawalFragment) obj;
                        int i7 = CancelWithdrawalFragment.k;
                        vk7.f(cancelWithdrawalFragment, "this$0");
                        AppCompatActivity S = cancelWithdrawalFragment.S();
                        sid sidVar = cancelWithdrawalFragment.g;
                        if (sidVar == null) {
                            vk7.m("screenRouter");
                            throw null;
                        }
                        Context requireContext = cancelWithdrawalFragment.requireContext();
                        vk7.e(requireContext, "requireContext()");
                        Intent c2 = sidVar.c(requireContext, new oid.c1((fxa[]) null));
                        c2.setFlags(335577088);
                        q0f.u(S, c2, false, 6);
                        cancelWithdrawalFragment.Z(new xh(AnalyticType.LEANPLUM_STATE, "state/payment_receipt", (Map) null, 12));
                        cancelWithdrawalFragment.Z(new xh(AnalyticType.LEANPLUM_EVENT, "event/payment_receipt", r89.w(new fxa[]{new fxa("Trigger", "Button Click"), new fxa("Trigger Value", "Buat Baru"), new fxa("Page", "Tarik Tunai Token Page - Pembatalan Sukses"), new fxa("Product", "Withdrawal")}), 8));
                        return;
                }
            }
        });
        this.F0.findViewById(c4c.btnCaptureDoc).setOnClickListener(new ih6(i, this));
        long longValue = krjVar.b().longValue();
        if (djj.e().i()) {
            djj.e().a(getApplicationContext()).G(longValue);
            djj.e().a(getApplicationContext()).l();
        }
        this.J.c();
        this.K.c();
    }

    public final void K0() {
        this.F0.setVisibility(8);
        try {
            this.Q0 = new zfi();
            if (djj.e().h != null) {
                djj.e().h.D(this.H);
            }
            if (this.H.isShouldShowInstructionPage()) {
                c1();
            } else {
                Q0();
            }
        } catch (Exception e2) {
            fvi.d(e2);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
            a1(new ph6(2, getResources().getString(uac.internal_error)));
        }
    }

    public final void L0(boolean z) {
        if (fvi.k(this) || Z0()) {
            this.i1 = (int) getResources().getDimension(x1c.margin_doc_top_bar_height_nav);
        } else {
            this.i1 = (int) getResources().getDimension(x1c.margin_doc_top_bar_height_no_nav);
        }
        LinearLayout linearLayout = (LinearLayout) findViewById(c4c.llTopBar);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) linearLayout.getLayoutParams();
        layoutParams.height = this.i1;
        linearLayout.setLayoutParams(layoutParams);
        ViewGroup.LayoutParams layoutParams2 = ((ImageView) findViewById(c4c.camera_cross)).getLayoutParams();
        int i = this.i1;
        layoutParams2.height = i;
        layoutParams2.width = i;
        ViewGroup.LayoutParams layoutParams3 = ((ImageView) findViewById(c4c.camera_flash)).getLayoutParams();
        int i2 = this.i1;
        layoutParams3.height = i2;
        layoutParams3.width = i2;
        FrameLayout frameLayout = (FrameLayout) findViewById(c4c.cameraContainer);
        if (Z0()) {
            FrameLayout.LayoutParams layoutParams4 = (FrameLayout.LayoutParams) frameLayout.getLayoutParams();
            layoutParams4.setMargins(dri.a(10.0f, this), (int) ((((float) (this.e1 - ((this.f973f1 * 4.0d) / 3.0d))) / 2.0f) * this.d1), dri.a(10.0f, this), 0);
            layoutParams4.height = -2;
            frameLayout.setLayoutParams(layoutParams4);
        } else {
            FrameLayout.LayoutParams layoutParams5 = (FrameLayout.LayoutParams) frameLayout.getLayoutParams();
            if (this.H.getDocument() == yg6.a.A4) {
                layoutParams5.setMargins(dri.a(45.0f, this), this.i1 + 75, dri.a(45.0f, this), 0);
            } else {
                layoutParams5.setMargins(dri.a(10.0f, this), this.i1, dri.a(10.0f, this), 0);
            }
            layoutParams5.height = -2;
            frameLayout.setLayoutParams(layoutParams5);
        }
        FrameLayout frameLayout2 = (FrameLayout) findViewById(c4c.overlay1);
        FrameLayout frameLayout3 = (FrameLayout) findViewById(c4c.overlay2);
        int Y0 = Y0();
        X0();
        FrameLayout.LayoutParams layoutParams6 = (FrameLayout.LayoutParams) frameLayout2.getLayoutParams();
        layoutParams6.height = Y0 + this.h1;
        frameLayout2.setLayoutParams(layoutParams6);
        frameLayout3.setVisibility(0);
        FrameLayout.LayoutParams layoutParams7 = (FrameLayout.LayoutParams) frameLayout3.getLayoutParams();
        layoutParams7.setMargins(0, X0() + this.h1, 0, 0);
        frameLayout3.setLayoutParams(layoutParams7);
        if (z) {
            FrameLayout frameLayout4 = this.y0;
            frameLayout4.measure(View.MeasureSpec.makeMeasureSpec(frameLayout4.getMeasuredWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(frameLayout4.getMeasuredHeight(), 1073741824));
            frameLayout4.layout(frameLayout4.getLeft(), frameLayout4.getTop(), frameLayout4.getRight(), frameLayout4.getBottom());
        }
    }

    public final void M0(JSONObject jSONObject) {
        String str;
        try {
            if (!this.H.isShouldExportPDF() || (str = this.S0) == null) {
                return;
            }
            jSONObject.put("pdfUri", str);
        } catch (JSONException e2) {
            fvi.d(e2);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        }
    }

    public final void N0() {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.J0.getLayoutParams();
        if (this.G.getAspectRatio() < 1.0f) {
            layoutParams.setMargins(dri.a(30.0f, this), dri.a(60.0f, this), dri.a(30.0f, this), 0);
        }
        this.J0.requestLayout();
        FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) this.I0.getLayoutParams();
        layoutParams2.setMargins(0, X0() - (this.G.getAspectRatio() < 1.0f ? -((int) getResources().getDimension(x1c.margin_doc_status_negative)) : (int) getResources().getDimension(x1c.margin_doc_status_top)), 0, 0);
        this.I0.setLayoutParams(layoutParams2);
        this.I0.requestLayout();
        this.z0.requestLayout();
    }

    public final void O0(Context context) {
        if (((LocationManager) y3h.b(this).e.getSystemService("location")).isProviderEnabled("gps")) {
            y3h.b(context).c();
            y3h.b(context).f6625b = new c(context);
            return;
        }
        b.a aVar = new b.a(this);
        aVar.setTitle("GPS Switched Off");
        AlertController.b bVar = aVar.a;
        bVar.f = "Please enable GPS to continue";
        bVar.k = false;
        mh6 mh6Var = new mh6(this);
        bVar.g = "Open settings";
        bVar.h = mh6Var;
        nh6 nh6Var = new nh6(this);
        bVar.i = "Cancel";
        bVar.j = nh6Var;
        aVar.create().show();
    }

    public final void Q0() {
        krj krjVar = this.N;
        krjVar.c();
        ArrayList arrayList = new ArrayList(Arrays.asList("android.permission.CAMERA"));
        this.Q0.getClass();
        zfi.a(this, arrayList);
        this.Q0.getClass();
        if (zfi.b(this, arrayList).a.isEmpty()) {
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.I(krjVar.b().longValue());
            }
            D0();
        }
    }

    public final void R0(final ph6 ph6Var, final xh6 xh6Var) {
        try {
            if (!(r81.a ? yih.n : n4h.h)) {
                final int i = 0;
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        int i2 = i;
                        Object obj = xh6Var;
                        Object obj2 = ph6Var;
                        Object obj3 = this;
                        switch (i2) {
                            case 0:
                                av6 av6Var = HVDocsActivity.o1;
                                ((HVDocsActivity) obj3).R0((ph6) obj2, (xh6) obj);
                                break;
                            case 1:
                                AsyncQueue.e((Callable) obj3, (Executor) obj2, (v1f) obj);
                                break;
                            default:
                                VTrackWebService.j((String) obj3, (Context) obj2, (VTrackResponseHandler) obj);
                                break;
                        }
                    }
                }, 20L);
            } else {
                if (o1 != null) {
                    P0(ph6Var, xh6Var);
                }
                qxh.h = null;
                finish();
            }
        } catch (Exception e2) {
            fvi.d(e2);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        }
    }

    public final void S0() {
        if (this.K0.getParent() != null) {
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.K0.getLayoutParams();
            layoutParams.height = this.c1;
            layoutParams.width = this.b1;
            HVMagicView hVMagicView = this.A0;
            if (hVMagicView != null) {
                this.K0.setX(hVMagicView.getX());
                this.K0.setY(this.A0.getY());
            }
            this.K0.requestLayout();
        }
        this.z0.requestLayout();
    }

    public final void T0() {
        ImageView imageView = (ImageView) findViewById(c4c.camera_bubble);
        this.H0 = imageView;
        imageView.setImageResource(g3c.camera_disabled);
        this.H0.setClickable(false);
        this.H0.setEnabled(false);
        xu6.c().getClass();
        if (!xu6.f6575b.isShouldUseLocation()) {
            V0();
        } else if (this.V != null) {
            V0();
        }
        ImageView imageView2 = (ImageView) findViewById(c4c.camera_flash);
        this.G0 = imageView2;
        imageView2.setImageResource(g3c.ic_torch_off_svg);
        this.C0 = findViewById(c4c.black_overlay);
        new Handler(Looper.getMainLooper()).postDelayed(new d(), 100L);
        if (!this.H.isShouldShowFlashIcon()) {
            this.G0.setVisibility(4);
        }
        this.B0.setVisibility(8);
        this.h1 = this.G.getAspectRatio() > 1.0f ? 0 : dri.a(50.0f, this);
        this.y0 = (FrameLayout) findViewById(c4c.camera_preview);
        this.z0 = (FrameLayout) findViewById(c4c.cameraContainer);
        tx2.i(this, true);
        r81.e = false;
        r81.d = false;
        r81.c = 1.0f;
        r81.f5067b = false;
        try {
            if (this.A0 == null) {
                HVMagicView hVMagicView = new HVMagicView(this, this.j1, false);
                HVMagicView.g = hVMagicView;
                this.A0 = hVMagicView;
            }
            HVMagicView hVMagicView2 = this.A0;
            hVMagicView2.f971b.disable();
            hVMagicView2.d = true;
            if (r81.a) {
                yih.e = 0;
            } else {
                n4h.m = 0;
                try {
                    Camera camera = n4h.a;
                    if (camera != null && !n4h.h) {
                        reh.a(n4h.f4108b, camera, 0);
                    }
                } catch (Exception e2) {
                    e2.getMessage();
                }
            }
            this.z0.addView(this.A0, 0);
            HVMagicView hVMagicView3 = this.A0;
            if (hVMagicView3 != null) {
                this.A0.setSensorCallback(new e());
            }
            FrameLayout frameLayout = this.z0;
            co.hyperverge.hypersnapsdk.views.b bVar = new co.hyperverge.hypersnapsdk.views.b(this);
            this.K0 = bVar;
            frameLayout.addView(bVar, -1);
            frameLayout.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public final boolean onTouch(View view, MotionEvent motionEvent) {
                    av6 av6Var = HVDocsActivity.o1;
                    HVDocsActivity hVDocsActivity = HVDocsActivity.this;
                    hVDocsActivity.getClass();
                    int actionMasked = motionEvent.getActionMasked();
                    if (actionMasked == 0) {
                        hVDocsActivity.k1 = motionEvent.getX();
                        hVDocsActivity.l1 = motionEvent.getY();
                    } else if (actionMasked == 1 && Math.abs(motionEvent.getX() - hVDocsActivity.k1) < 20.0f && Math.abs(motionEvent.getY() - hVDocsActivity.l1) < 20.0f) {
                        hVDocsActivity.K0.a(motionEvent.getX(), motionEvent.getY(), false);
                        HVMagicView hVMagicView4 = hVDocsActivity.A0;
                        if (hVMagicView4 != null) {
                            hVMagicView4.c(motionEvent.getX() / hVDocsActivity.b1, motionEvent.getY() / hVDocsActivity.c1);
                        }
                    }
                    return true;
                }
            });
            FrameLayout frameLayout2 = this.z0;
            co.hyperverge.hypersnapsdk.views.d dVar = new co.hyperverge.hypersnapsdk.views.d(this);
            this.L0 = dVar;
            frameLayout2.addView(dVar, -1);
            ImageView imageView3 = (ImageView) findViewById(c4c.camera_cross);
            imageView3.setImageResource(g3c.ic_camera_cross);
            imageView3.setOnClickListener(this);
            this.I0 = (TextView) findViewById(c4c.tv_hint);
            try {
                if (this.H.getHintTypeface() > 0) {
                    this.I0.setTypeface(z1d.c(getApplicationContext(), this.H.getHintTypeface()));
                }
                String docCaptureSubText = this.H.getDocCaptureSubText();
                if (!TextUtils.isEmpty(docCaptureSubText)) {
                    this.I0.setText(docCaptureSubText);
                }
                this.J0 = (TextView) findViewById(c4c.tv_step);
                if (this.H.getDescTypeface() > 0) {
                    this.J0.setTypeface(z1d.c(getApplicationContext(), this.H.getDescTypeface()));
                }
                if (this.H.getDocCaptureDescription() != null && !this.H.getDocCaptureDescription().isEmpty()) {
                    this.J0.setText(this.H.getDocCaptureDescription());
                }
            } catch (Exception e3) {
                fvi.d(e3);
                if (djj.e().i() && djj.e().h != null) {
                    djj.e().h.F(new ph6(2, fvi.d(e3)));
                }
                if (djj.e().g != null) {
                    djj.e().g.a();
                }
            }
            if (r81.a) {
                yih.a = true;
            } else {
                n4h.q = true;
            }
            Display defaultDisplay = getWindowManager().getDefaultDisplay();
            defaultDisplay.getSize(new Point());
            defaultDisplay.getMetrics(new DisplayMetrics());
            if (r81.a) {
                boolean z = yih.a;
            } else {
                Camera camera2 = n4h.a;
            }
            float f3 = getResources().getDisplayMetrics().density;
            this.d1 = f3;
            this.e1 = r4.heightPixels / f3;
            this.f973f1 = r4.widthPixels / f3;
            if (fvi.k(this) || Z0()) {
                ViewGroup.LayoutParams layoutParams = this.H0.getLayoutParams();
                layoutParams.width = (int) getResources().getDimension(x1c.resource_camera_size);
                layoutParams.height = (int) getResources().getDimension(x1c.resource_camera_size);
                this.H0.requestLayout();
            } else {
                ViewGroup.LayoutParams layoutParams2 = this.H0.getLayoutParams();
                layoutParams2.width = (int) getResources().getDimension(x1c.margin_doc_button_nav);
                layoutParams2.height = (int) getResources().getDimension(x1c.margin_doc_button_nav);
                this.H0.requestLayout();
            }
            L0(false);
            S0();
            N0();
            U0();
            String capturePageTitleText = this.H.getCapturePageTitleText();
            TextView textView = (TextView) findViewById(c4c.title_text);
            if (!TextUtils.isEmpty(capturePageTitleText)) {
                textView.setText(capturePageTitleText);
            }
            if (this.H.getTitleTypeface() > 0) {
                textView.setTypeface(z1d.c(getApplicationContext(), this.H.getTitleTypeface()));
            }
            TextView textView2 = (TextView) findViewById(c4c.tvSubtitle);
            String capturePageSubtitleText = this.H.getCapturePageSubtitleText();
            textView2.setText(capturePageSubtitleText);
            textView2.setVisibility(TextUtils.isEmpty(capturePageSubtitleText) ? 8 : 0);
            if (this.H.getSubtitleTypeface() > 0) {
                textView2.setTypeface(z1d.c(getApplicationContext(), this.H.getSubtitleTypeface()));
            }
            this.H0.setOnClickListener(this);
            this.G0.setOnClickListener(this);
            this.H0.setOnTouchListener(new f());
            HVMagicView hVMagicView4 = this.A0;
            if (hVMagicView4 != null) {
                hVMagicView4.onResume();
            } else {
                if (!djj.e().i() || djj.e().h == null) {
                    return;
                }
                djj.e().h.F(new ph6(2, "CameraView is null"));
            }
        } catch (Exception e4) {
            fvi.d(e4);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
            ph6 ph6Var = new ph6(5, getResources().getString(uac.camera_error));
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.F(ph6Var);
            }
            a1(ph6Var);
        }
    }

    public final void U0() {
        if (this.L0.getParent() != null) {
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.L0.getLayoutParams();
            int i = this.b1;
            int X0 = X0() - Y0();
            layoutParams.height = X0;
            layoutParams.width = i;
            int Y0 = Y0() + this.h1;
            X0();
            this.L0.setX(0);
            this.L0.setY(Y0);
            co.hyperverge.hypersnapsdk.views.d dVar = this.L0;
            RectF rectF = new RectF(0.0f, 0.0f, i, X0);
            dVar.getClass();
            Point point = new Point();
            Point point2 = new Point();
            point.x = ((int) rectF.left) + ((int) (rectF.width() * 0.02f));
            point.y = ((int) rectF.top) + ((int) (rectF.height() * 0.02f));
            point2.x = ((int) rectF.right) - ((int) (rectF.width() * 0.02f));
            point2.y = ((int) rectF.bottom) - ((int) (0.02f * ((int) rectF.height())));
            dVar.a = new RectF(point.x, point.y, point2.x, point2.y);
            dVar.f987b = true;
            this.L0.requestLayout();
        }
        this.z0.requestLayout();
    }

    public final void V0() {
        if (this.H.isShouldReadQR() && !this.R) {
            this.S.postDelayed(new e41(3, this), 2000L);
            return;
        }
        ImageView imageView = this.H0;
        if (imageView != null) {
            i17.a(imageView, ColorStateList.valueOf(getResources().getColor(d1c.camera_button_color)));
            this.H0.setImageResource(g3c.ic_camera_button_svg);
            this.H0.setClickable(true);
            this.H0.setEnabled(true);
        }
    }

    public final void W0(String str, String str2) {
        try {
            ProgressDialog progressDialog = new ProgressDialog(this);
            progressDialog.setMessage(r20.d);
            progressDialog.show();
            View view = this.C0;
            if (view != null) {
                view.setVisibility(0);
            }
            if (qxh.h == null) {
                qxh.h = new qxh();
            }
            qxh.h.a(this, str, str2, this.H, new jh6(this, progressDialog, str));
        } catch (Exception unused) {
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        }
    }

    public final int X0() {
        int aspectRatio = ((int) ((this.G.getAspectRatio() * this.b1) + this.c1)) / 2;
        int i = (int) (this.d1 * 0.4f);
        int i2 = aspectRatio + i;
        int i3 = this.c1;
        return i2 >= i3 ? i3 - i : aspectRatio;
    }

    public final int Y0() {
        int aspectRatio = ((int) (this.c1 - (this.G.getAspectRatio() * this.b1))) / 2;
        if (aspectRatio < 0) {
            return 20;
        }
        return aspectRatio;
    }

    public final boolean Z0() {
        return ((double) this.e1) <= (((double) this.f973f1) * 4.0d) / 3.0d;
    }

    public final void a1(ph6 ph6Var) {
        if (o1 != null) {
            P0(ph6Var, null);
        }
        qxh.h = null;
        finish();
    }

    public final void b1() {
        if (this.O0) {
            this.J0.setText(getResources().getString(uac.docCaptureTilt));
            this.J0.setTextColor(getResources().getColor(d1c.text_red));
            return;
        }
        this.J0.setTextColor(getResources().getColor(d1c.content_text_color));
        if (this.H.getDocCaptureDescription() == null || this.H.getDocCaptureDescription().isEmpty()) {
            this.J0.setText(getResources().getString(uac.docCaptureDescription));
        } else {
            this.J0.setText(this.H.getDocCaptureDescription());
        }
    }

    public final void c1() {
        try {
            Intent intent = new Intent(this, (Class<?>) HVDocInstructionActivity.class);
            intent.putExtra("customUIStrings", this.H.getCustomUIStrings().toString());
            startActivityForResult(intent, 1);
        } catch (Exception e2) {
            fvi.d(e2);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        } catch (NoClassDefFoundError e3) {
            fvi.d(e3);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
            P0(new ph6(31, getResources().getString(uac.instructions_error)), null);
            finish();
        }
    }

    public final void d1(String str, String str2) {
        try {
            Intent intent = new Intent(this, (Class<?>) HVDocReviewActivity.class);
            intent.putExtra("imageUri", str);
            if (this.H.isShouldReadQR() && !j92.c(str2) && new File(str2).exists()) {
                intent.putExtra("qrCodeCroppedImageUri", str2);
            }
            intent.putExtra("aspectRatio", this.G.getAspectRatio());
            intent.putExtra(yg6.KEY, this.H);
            intent.putExtra("extraPadding", this.V0);
            co.hyperverge.hypersnapsdk.views.d dVar = this.L0;
            if (dVar != null) {
                intent.putExtra("viewWidth", dVar.getWidth());
                intent.putExtra("viewHeight", this.L0.getHeight());
            }
            startActivityForResult(intent, 1);
        } catch (Exception e2) {
            fvi.d(e2);
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.P(new ph6(2, fvi.d(e2)));
            }
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        }
    }

    public final void e1() {
        HVMagicView hVMagicView = this.A0;
        if (hVMagicView != null) {
            hVMagicView.setSensorCallback(null);
            HVMagicView hVMagicView2 = this.A0;
            hVMagicView2.getClass();
            HVMagicView.g = null;
            HVMagicView.f = null;
            hVMagicView2.queueEvent(new wh6(hVMagicView2));
            this.A0.onPause();
            this.V = null;
        }
    }

    @Override
    public final void onActivityResult(int i, int i2, Intent intent) {
        String str;
        byte[] g3;
        super.onActivityResult(i, i2, intent);
        Objects.toString(intent);
        try {
            this.I.c();
            this.K.c();
            this.J.c();
            this.L.c();
            this.M.c();
            this.N.c();
            this.O.c();
        } catch (Exception e2) {
            fvi.d(e2);
        }
        if (i == 1001) {
            try {
                O0(this);
            } catch (NoClassDefFoundError unused) {
            }
        }
        if (i == 1000 && i2 == -1 && intent != null) {
            Uri data = intent.getData();
            File file = new File(getFilesDir(), "hv");
            ContentResolver contentResolver = getContentResolver();
            int i3 = fvi.a;
            Objects.toString(contentResolver);
            Objects.toString(data);
            Objects.toString(file);
            String extensionFromMimeType = MimeTypeMap.getSingleton().getExtensionFromMimeType(contentResolver.getType(data));
            File file2 = new File(file, System.currentTimeMillis() + "." + extensionFromMimeType);
            int i4 = 2;
            r3 = 2;
            i4 = 2;
            int i5 = 2;
            i4 = 2;
            i4 = 2;
            try {
                g3 = fvi.g(contentResolver, data);
            } catch (Exception e3) {
                Object[] objArr = new Object[i4];
                objArr[0] = file2.getPath();
                objArr[1] = fvi.d(e3);
                String.format("Error writing bytes to file: %s,\nerror: %s", objArr);
                i5 = objArr;
            } catch (OutOfMemoryError e4) {
                Object[] objArr2 = new Object[i4];
                objArr2[0] = file2.getPath();
                objArr2[1] = fvi.d(e4);
                String.format("Out of memory error: %s,\nerror: %s", objArr2);
                i5 = objArr2;
            }
            if (g3 != null) {
                if (Objects.equals(extensionFromMimeType, "pdf")) {
                    new FileOutputStream(file2).write(g3);
                } else {
                    Bitmap h2 = fvi.h(lmi.a(MediaStore.Images.Media.getBitmap(contentResolver, data), w1n.h(g3)));
                    FileOutputStream fileOutputStream = new FileOutputStream(file2);
                    if (h2 != null) {
                        h2.compress(Bitmap.CompressFormat.JPEG, 90, fileOutputStream);
                        h2.recycle();
                    }
                }
                if (file2 == null && file2.exists()) {
                    String path = file2.getPath();
                    JSONObject jSONObject = new JSONObject();
                    try {
                        str = path.substring(path.lastIndexOf(".") + 1);
                    } catch (Exception unused2) {
                        str = null;
                    }
                    if (str != null && !str.equals("pdf")) {
                        try {
                            r4i r4iVar = new r4i();
                            r4iVar.b(file2, this.V);
                            if (this.H.isShouldExportPDF()) {
                                String a2 = o3j.a(this.N0.getPath() + "/hv_" + System.currentTimeMillis() + ".pdf", BitmapFactory.decodeFile(path));
                                this.S0 = a2;
                                jSONObject.put("pdfUri", a2);
                            }
                            r4iVar.c(path, (this.H.getOcrHeaders() == null || !this.H.getOcrHeaders().has("transactionId")) ? mjj.h() : this.H.getOcrHeaders().getString("transactionId"), this.D0);
                        } catch (Exception e5) {
                            fvi.d(e5);
                            if (djj.e().g != null) {
                                djj.e().g.a();
                            }
                        }
                    }
                    if (this.H.shouldShowReviewScreen()) {
                        d1(path, null);
                    } else if (this.H.isShouldDoOCR()) {
                        W0(path, null);
                    } else {
                        M0(jSONObject);
                        R0(null, new xh6(jSONObject, new JSONObject(), path, this.T0));
                    }
                } else {
                    R0(new ph6(6, "Selected file invalid or corrupt"), null);
                }
            }
            file2 = null;
            i4 = i5;
            if (file2 == null) {
            }
            R0(new ph6(6, "Selected file invalid or corrupt"), null);
        }
        if (i2 == 10) {
            Q0();
            return;
        }
        if (i2 == 11) {
            E0();
            return;
        }
        if (i2 != 18) {
            if (i2 == 6) {
                this.U++;
                long longExtra = intent.getLongExtra("timeTakenToClickRetakeButton", 0L);
                if (djj.e().i() && djj.e().h != null) {
                    djj.e().h.X(this.H, longExtra);
                }
                ImageView imageView = this.H0;
                if (imageView != null) {
                    i17.a(imageView, null);
                    this.H0.setImageResource(g3c.camera_disabled);
                    this.H0.setClickable(false);
                    this.H0.setEnabled(false);
                }
                this.R = false;
                V0();
                return;
            }
            if (i2 == 7) {
                long longExtra2 = intent.getLongExtra("timeTakenToClickConfirmButton", 0L);
                if (djj.e().i() && djj.e().h != null) {
                    djj.e().h.t0(this.H, this.U, longExtra2);
                }
                this.U = 0;
                String stringExtra = intent.getStringExtra("imageUri");
                String stringExtra2 = this.H.isShouldReadQR() ? intent.getStringExtra("qrCodeCroppedImageUri") : null;
                if (this.H.isShouldDoOCR()) {
                    W0(stringExtra, stringExtra2);
                    return;
                }
                JSONObject jSONObject2 = new JSONObject();
                M0(jSONObject2);
                R0(null, new xh6(jSONObject2, new JSONObject(), stringExtra, this.T0));
                return;
            }
            if (i2 != 8) {
                return;
            }
        }
        e1();
        R0((ph6) intent.getSerializableExtra("hvError"), null);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == c4c.camera_cross) {
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.i();
            }
            H0();
            return;
        }
        if (id != c4c.camera_bubble) {
            if (id == c4c.camera_flash) {
                if (djj.e().i() && djj.e().h != null) {
                    djj.e().h.u();
                }
                if (this.A0 != null) {
                    HVMagicView.b();
                    return;
                }
                return;
            }
            return;
        }
        if (djj.e().i() && djj.e().h != null) {
            djj.e().h.c0(this.H, this.O.b().longValue());
        }
        if (this.H.isShouldAllowPhoneTilt() || !this.O0) {
            krj krjVar = this.M;
            if (this.f974g1.get()) {
                this.f974g1.set(false);
                try {
                    krjVar.c();
                    HVMagicView hVMagicView = this.A0;
                    if (hVMagicView != null) {
                        hVMagicView.c(0.5f, 0.5f);
                        this.A0.d();
                    } else {
                        this.P = new ph6(2, "camerView is null");
                        long longValue = krjVar.b().longValue();
                        if (djj.e().i() && djj.e().h != null) {
                            djj.e().h.r0(this.P, longValue);
                        }
                    }
                } catch (Exception e2) {
                    fvi.d(e2);
                    this.P = new ph6(2, fvi.d(e2));
                    long longValue2 = krjVar.b().longValue();
                    if (djj.e().i() && djj.e().h != null) {
                        djj.e().h.r0(this.P, longValue2);
                    }
                    if (djj.e().g != null) {
                        djj.e().g.a();
                    }
                }
            }
        }
    }

    @Override
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        try {
            setContentView(n7c.hv_activity_doc_capture);
        } catch (Exception e2) {
            fvi.d(e2);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
            a1(new ph6(2, getResources().getString(uac.internal_error)));
        }
        this.H = (yg6) getIntent().getSerializableExtra(yg6.KEY);
        if (djj.e().i() && djj.e().h != null) {
            djj.e().h.D(this.H);
        }
        xu6.c().getClass();
        if (xu6.f6575b.isShouldUseLocation()) {
            try {
                O0(this);
            } catch (NoClassDefFoundError unused) {
            }
        }
        if (bundle != null) {
            finish();
        }
        this.G = this.H.getDocument();
        View findViewById = findViewById(c4c.v_flash);
        this.B0 = findViewById;
        findViewById.setVisibility(0);
        File file = new File(getFilesDir(), "hv");
        this.N0 = file;
        if (!file.exists()) {
            this.N0.mkdirs();
        }
        long currentTimeMillis = System.currentTimeMillis();
        this.W0 = this.N0.getPath() + "/" + currentTimeMillis + ".jpg";
        this.X0 = this.N0.getPath() + "/HIGH_RES_CROPPED_" + currentTimeMillis + ".jpg";
        this.Y0 = this.N0.getPath() + "/HIGH_RES_FULL_" + currentTimeMillis + ".jpg";
        this.F0 = (ConstraintLayout) findViewById(c4c.layoutDocPicker);
        if (this.H.isDocumentUploadEnabled()) {
            J0();
        } else {
            K0();
        }
    }

    @Override
    public final void onDestroy() {
        try {
            if (!this.H.isShouldAllowPhoneTilt()) {
                this.P0.unregisterListener(this.R0);
                qxh.h = null;
            }
        } catch (Exception e2) {
            fvi.d(e2);
            if (djj.e().g != null) {
                djj.e().g.a();
            }
        }
        super.onDestroy();
    }

    @Override
    public final void onPause() {
        super.onPause();
        HVMagicView hVMagicView = this.A0;
        if (hVMagicView != null) {
            hVMagicView.onPause();
        }
    }

    @Override
    public final void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        ArrayList arrayList = new ArrayList(Arrays.asList("android.permission.CAMERA"));
        this.Q0.getClass();
        ArrayList<String> arrayList2 = zfi.b(this, arrayList).a;
        boolean isEmpty = arrayList2.isEmpty();
        krj krjVar = this.N;
        if (isEmpty) {
            if (djj.e().i() && djj.e().h != null) {
                djj.e().h.I(krjVar.b().longValue());
            }
            D0();
            super.onRequestPermissionsResult(i, strArr, iArr);
            return;
        }
        ph6 ph6Var = new ph6(4, j.a("Following Permissions not granted by user: ", TextUtils.join(",", arrayList2)));
        if (djj.e().i() && djj.e().h != null) {
            djj.e().h.x0(ph6Var, krjVar.b().longValue());
        }
        P0(ph6Var, null);
        finish();
    }

    @Override
    public final void onResume() {
        super.onResume();
        HVMagicView hVMagicView = this.A0;
        if (hVMagicView != null) {
            hVMagicView.onResume();
        }
    }

    @Override
    public final void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
    }
}