导航菜单

页面标题

页面副标题

CreditoYa v2.1.0 - CameraXActivity.java 源代码

正在查看: CreditoYa v2.1.0 应用的 CameraXActivity.java JAVA 源代码文件

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


package com.ibeilly.kyc.camerax;

import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.util.Size;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.camera.core.j1;
import androidx.camera.core.j2;
import androidx.camera.core.n1;
import androidx.camera.core.u;
import androidx.camera.view.PreviewView;
import b2.p;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.jvm.internal.k;
import q1.x;
import r1.m;
import v0.c;
import v0.d;
import v0.e;
import v0.f;
import v0.g;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0001\u0004B\u0007¢\u0006\u0004\b\u0002\u0010\u0003¨\u0006\u0005"}, d2 = {"Lcom/ibeilly/kyc/camerax/CameraXActivity;", "Lcom/ibeilly/kyc/camerax/a;", "<init>", "()V", "a", "kyc-camerax_release"}, k = 1, mv = {1, 5, 1})
public final class CameraXActivity extends com.ibeilly.kyc.camerax.a {

    private static final String[] f4622v;

    protected w0.a f4623r;

    protected g f4624s;

    protected PreviewView f4625t;

    private final Handler f4626u;

    public static final class a {
        private a() {
        }

        public a(kotlin.jvm.internal.g gVar) {
            this();
        }
    }

    public static final class b implements j1.n {

        final File f4628b;

        b(File file) {
            this.f4628b = file;
        }

        @Override
        public void a(j1.p output) {
            k.f(output, "output");
            Uri a3 = output.a();
            if (a3 == null) {
                a3 = Uri.fromFile(this.f4628b);
            }
            Log.d("CameraXBasic", k.l("Photo capture succeeded: ", a3));
            CameraXActivity cameraXActivity = CameraXActivity.this;
            Bundle bundle = new Bundle();
            bundle.putInt("code", 200);
            bundle.putString("path", a3.getPath());
            bundle.putString("msg", "Capture success");
            x xVar = x.f6657a;
            cameraXActivity.V(-1, bundle);
        }

        @Override
        public void b(n1 exc) {
            k.f(exc, "exc");
            Log.e("CameraXBasic", k.l("Photo capture failed: ", exc.getMessage()), exc);
            CameraXActivity cameraXActivity = CameraXActivity.this;
            Bundle bundle = new Bundle();
            bundle.putInt("code", 500);
            bundle.putString("msg", "Capture error");
            x xVar = x.f6657a;
            cameraXActivity.V(0, bundle);
        }
    }

    static {
        new a(null);
        f4622v = new String[]{"android.permission.CAMERA"};
    }

    public CameraXActivity() {
        Handler createAsync = Build.VERSION.SDK_INT >= 28 ? Handler.createAsync(Looper.getMainLooper(), v0.b.c) : new Handler();
        k.e(createAsync, "if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {\n        Handler.createAsync(Looper.getMainLooper()) {\n            return@createAsync true\n        }\n    } else {\n        Handler()\n    }");
        this.f4626u = createAsync;
    }

    private final boolean Q() {
        String[] strArr = f4622v;
        int length = strArr.length;
        int i3 = 0;
        while (true) {
            if (i3 >= length) {
                return true;
            }
            if (!(androidx.core.content.a.a(getBaseContext(), strArr[i3]) == 0)) {
                return false;
            }
            i3++;
        }
    }

    public static final void S(CameraXActivity this$0, View view) {
        k.f(this$0, "this$0");
        this$0.onBackPressed();
    }

    public static final void T(CameraXActivity this$0, View view) {
        k.f(this$0, "this$0");
        this$0.f0();
    }

    public static final void U(CameraXActivity this$0, View view) {
        k.f(this$0, "this$0");
        this$0.e0();
    }

    public static final void W(Bundle bundle, int i3, CameraXActivity this$0) {
        k.f(bundle, "$bundle");
        k.f(this$0, "this$0");
        String string = bundle.getString("path");
        if (i3 != -1 || string == null) {
            p<Integer, String, x> b3 = u0.a.b();
            if (b3 != null) {
                Integer valueOf = Integer.valueOf(bundle.getInt("code"));
                String string2 = bundle.getString("msg");
                if (string2 == null) {
                    string2 = "Unknown error";
                }
                b3.invoke(valueOf, string2);
            }
        } else {
            p<String, String, x> c3 = u0.a.c();
            if (c3 != null) {
                c3.invoke(string, "");
            }
        }
        this$0.setResult(i3, new Intent().putExtras(bundle));
        this$0.finish();
    }

    private final void a0(Bundle bundle) {
        Intent intent = getIntent();
        g gVar = g.f6864j;
        int intExtra = intent.getIntExtra("camerax_model", gVar.ordinal());
        g[] values = g.values();
        if (intExtra >= 0 && intExtra <= m.u(values)) {
            gVar = values[intExtra];
        }
        c0(gVar);
        if (bundle == null) {
            H(Y().b() ? 1 : 0);
        }
        setRequestedOrientation(!Y().e() ? 1 : 0);
        X().f6888f.setVisibility(Y().g() ? 0 : 8);
        X().f6885c.setVisibility(Y().f() ? 0 : 8);
        LinearLayoutCompat linearLayoutCompat = X().f6886d;
        if (linearLayoutCompat != null) {
            linearLayoutCompat.setVisibility(Y().f() ? 0 : 8);
        }
        TextView textView = X().f6890h;
        if (textView == null) {
            return;
        }
        textView.setVisibility(Y().f() ? 0 : 8);
    }

    public static final boolean g0(Message it) {
        k.f(it, "it");
        return true;
    }

    @Override
    protected Size B() {
        return 1 == getRequestedOrientation() ? new Size(1080, 1920) : new Size(1920, 1080);
    }

    @Override
    public void D(j2 j2Var) {
        super.D(j2Var);
        j2 x2 = x();
        if (x2 == null) {
            return;
        }
        x2.X(Z().getSurfaceProvider());
    }

    public void R() {
        w0.a c3 = w0.a.c(getLayoutInflater());
        k.e(c3, "inflate(layoutInflater)");
        b0(c3);
        setContentView(X().b());
        PreviewView previewView = X().f6887e;
        k.e(previewView, "binding.previewView");
        d0(previewView);
        X().f6884b.setOnClickListener(new e(this));
        X().f6889g.setOnClickListener(new c(this));
        X().f6888f.setOnClickListener(new d(this));
    }

    public final void V(int i3, Bundle bundle) {
        k.f(bundle, "bundle");
        this.f4626u.postAtFrontOfQueue(new f(bundle, i3, this));
    }

    protected final w0.a X() {
        w0.a aVar = this.f4623r;
        if (aVar != null) {
            return aVar;
        }
        k.s("binding");
        throw null;
    }

    protected final g Y() {
        g gVar = this.f4624s;
        if (gVar != null) {
            return gVar;
        }
        k.s("cameraXOption");
        throw null;
    }

    protected final PreviewView Z() {
        PreviewView previewView = this.f4625t;
        if (previewView != null) {
            return previewView;
        }
        k.s("previewView");
        throw null;
    }

    protected final void b0(w0.a aVar) {
        k.f(aVar, "<set-?>");
        this.f4623r = aVar;
    }

    protected final void c0(g gVar) {
        k.f(gVar, "<set-?>");
        this.f4624s = gVar;
    }

    protected final void d0(PreviewView previewView) {
        k.f(previewView, "<set-?>");
        this.f4625t = previewView;
    }

    protected final void e0() {
        H(w() == 1 ? 0 : 1);
        u b3 = new u.a().d(w()).b();
        k.e(b3, "Builder().requireLensFacing(lensFacing).build()");
        G(b3);
        p();
    }

    protected final void f0() {
        File file = new File(y(), k.l(new SimpleDateFormat("yyyyMMdd-HHmmssSSS", Locale.US).format(Long.valueOf(System.currentTimeMillis())), ".jpg"));
        j1.l lVar = new j1.l();
        lVar.d(w() == 0);
        j1.o a3 = new j1.o.a(file).b(lVar).a();
        k.e(a3, "Builder(photoFile)\n            .setMetadata(metadata)\n            .build()");
        j1 v2 = v();
        if (v2 == null) {
            return;
        }
        v2.z0(a3, s(), new b(file));
    }

    @Override
    public void onBackPressed() {
        Bundle bundle = new Bundle();
        bundle.putInt("code", 510);
        bundle.putString("err", "Cancel by user");
        x xVar = x.f6657a;
        V(0, bundle);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        R();
        Log.d("CameraXBasic", k.l("onCreate ", Integer.valueOf(getRequestedOrientation())));
        a0(bundle);
        if (Q()) {
            J();
        } else {
            androidx.core.app.b.q(this, f4622v, 10);
        }
    }

    @Override
    public void onRequestPermissionsResult(int i3, String[] permissions, int[] grantResults) {
        k.f(permissions, "permissions");
        k.f(grantResults, "grantResults");
        if (i3 == 10) {
            if (Q()) {
                J();
            } else {
                Toast.makeText(this, "Permissions not granted by the user.", 0).show();
                onBackPressed();
            }
        }
    }
}