正在查看: Credmex v3.12.2 应用的 TakeHandWithIdCardPhotoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Credmex v3.12.2 应用的 TakeHandWithIdCardPhotoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.credmex.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.util.Size;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.camera.core.CameraSelector;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.credmex.commom.IUserSession;
import com.credmex.commom.ViewBindingActivity;
import com.credmex.databinding.ActivityTakePictureBinding;
import com.credmex.models.TakePhotoImageInfo;
import com.credmex.models.UserGlobal;
import com.credmex.models.event.HandWithIdCardEvent;
import com.credmex.utils.UploadIdCardImageHelper;
import com.credmex.widght.dialog.HandWithIdCardTipsDialog;
import com.open.mxcamera.views.CameraView;
import com.open.mxcamera.views.CameraViewConfig;
import com.sensorsdata.analytics.android.autotrack.aop.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented;
import com.veda.supertoolkit.customtools.Logger;
import com.veda.supertoolkit.filetools.FilePathUtil;
import com.veda.supertoolkit.imagetools.BitmapUtil;
import com.veda.supertoolkit.lifecycle.LifecycleEvent;
import com.veda.supertoolkit.permissiontools.permission.PermissionCallBack;
import com.veda.supertoolkit.permissiontools.permission.PermissionHelper;
import com.veda.supertoolkit.permissiontools.permission.PermissionResult;
import com.veda.supertoolkit.rxjavatools.RxUtil;
import com.veda.supertoolkit.utils.ImageUtil;
import com.yangqianguan.statistics.AutoTrackHelper;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import io.sentry.Sentry;
import java.io.File;
import org.greenrobot.eventbus.EventBus;
public class TakeHandWithIdCardPhotoActivity extends ViewBindingActivity {
private ActivityTakePictureBinding D;
private final PermissionHelper E = new PermissionHelper();
private boolean F = false;
private Bitmap G;
private Disposable H;
private UploadIdCardImageHelper I;
private HandWithIdCardTipsDialog J;
@SensorsDataInstrumented
public void A0(View view) {
N0();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
@SensorsDataInstrumented
public void B0(View view) {
u0();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
@SensorsDataInstrumented
public void C0(View view) {
s0();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
@SensorsDataInstrumented
public void D0(View view) {
this.D.g.setImageDrawable(null);
t0(true);
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
@SensorsDataInstrumented
public void E0(View view) {
finish();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
@SensorsDataInstrumented
public void F0(View view) {
L0();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
public void G0(PermissionResult permissionResult) {
if (permissionResult.isAllPermissionGranted()) {
M0();
} else {
showErrorToast(getString(2131821073));
finish();
}
}
public void H0(DialogInterface dialogInterface) {
setWindowStatusBarColor(this, 2131099974);
}
public void I0(CameraView.PictureResult pictureResult) throws Exception {
Bitmap r2 = this.D.c.r(pictureResult);
this.G = r2;
this.D.g.setImageBitmap(r2);
t0(false);
}
public static void J0(Throwable th) throws Exception {
Sentry.h(new RuntimeException(th));
Logger.c().b(Log.getStackTraceString(th));
}
public void K0(File file) {
if (file.exists()) {
if (this.I == null) {
this.I = new UploadIdCardImageHelper(this, new UploadIdCardImageHelper.Callback() {
@Override
public void a(String str, String str2) {
TakeHandWithIdCardPhotoActivity.this.dismissLoadingDialog();
EventBus.c().n(new HandWithIdCardEvent(true, 8, str2, str));
TakeHandWithIdCardPhotoActivity.this.finish();
}
@Override
public void b(String str) {
TakeHandWithIdCardPhotoActivity.this.dismissLoadingDialog();
TakeHandWithIdCardPhotoActivity.this.showErrorToast(str);
}
}, 8);
}
showLoadingDialog();
this.I.d(file.getPath());
}
}
private void L0() {
if (this.J == null) {
?? handWithIdCardTipsDialog = new HandWithIdCardTipsDialog(this);
this.J = handWithIdCardTipsDialog;
handWithIdCardTipsDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public final void onDismiss(DialogInterface dialogInterface) {
TakeHandWithIdCardPhotoActivity.this.H0(dialogInterface);
}
});
}
this.J.show();
}
private void M0() {
this.D.c.t(this, v0());
}
private void N0() {
duringActive(this.D.c.w()).W(new Consumer() {
public final void accept(Object obj) {
TakeHandWithIdCardPhotoActivity.this.I0((CameraView.PictureResult) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
TakeHandWithIdCardPhotoActivity.J0((Throwable) obj);
}
});
}
private void q0() {
setWindowStatusBarColor(this, 2131099974);
ViewCompat.setOnApplyWindowInsetsListener(this.D.getRoot(), new OnApplyWindowInsetsListener() {
public final WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) {
WindowInsetsCompat x0;
x0 = TakeHandWithIdCardPhotoActivity.this.x0(view, windowInsetsCompat);
return x0;
}
});
}
private CameraViewConfig.AspectRatio r0(int i2, int i3) {
double max = Math.max(i2, i3) / Math.min(i2, i3);
return Math.abs(max - 1.3333333333333333d) <= Math.abs(max - 1.7777777777777777d) ? CameraViewConfig.AspectRatio.a : CameraViewConfig.AspectRatio.b;
}
private void s0() {
Bitmap bitmap = this.G;
if (bitmap == null) {
t0(true);
} else {
this.H = Flowable.G(bitmap).b0(Schedulers.c()).H(new Function() {
public final Object apply(Object obj) {
File y0;
y0 = TakeHandWithIdCardPhotoActivity.this.y0((Bitmap) obj);
return y0;
}
}).J(AndroidSchedulers.a()).W(new Consumer() {
public final void accept(Object obj) {
TakeHandWithIdCardPhotoActivity.this.K0((File) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
TakeHandWithIdCardPhotoActivity.this.z0((Throwable) obj);
}
});
}
}
public static void startActivity(Activity activity) {
activity.startActivity(new Intent(activity, (Class<?>) TakeHandWithIdCardPhotoActivity.class));
}
private void t0(boolean z) {
this.D.f57k.setVisibility(z ? 0 : 8);
this.D.f56j.setVisibility(z ? 0 : 8);
this.D.d.setVisibility(z ? 8 : 0);
this.D.f55i.setVisibility(z ? 8 : 0);
}
private void u0() {
this.F = !this.F;
M0();
}
private CameraViewConfig v0() {
int i2;
boolean z;
boolean z2;
IUserSession<UserGlobal> iUserSession = this.userSession;
if (iUserSession == null || iUserSession.f() == null || this.userSession.f().appCustomConfig == null || this.userSession.f().appCustomConfig.takePhotoImageInfo == null) {
StringBuilder sb = new StringBuilder();
sb.append("use default image info width : ");
sb.append(720);
sb.append(" height : ");
sb.append(1280);
sb.append(" jpegQuality : ");
i2 = 90;
sb.append(90);
Sentry.e(sb.toString());
z = false;
z2 = false;
} else {
TakePhotoImageInfo takePhotoImageInfo = this.userSession.f().appCustomConfig.takePhotoImageInfo;
Sentry.e(takePhotoImageInfo.toString());
i2 = Math.max(takePhotoImageInfo.getJpegQuality(), 60);
z = takePhotoImageInfo.isUseAspectRatioPreviewMode();
Sentry.e("isUseAspectRatioPreviewMode : " + z);
z2 = takePhotoImageInfo.takePhotoFocus;
}
CameraViewConfig.Builder d = new CameraViewConfig.Builder().h(new Size(720, 1280)).f(i2).c(this.F ? CameraSelector.DEFAULT_FRONT_CAMERA : CameraSelector.DEFAULT_BACK_CAMERA).e(true).d(z2);
if (z) {
d.g(r0(720, 1280));
}
CameraViewConfig a = d.a();
Sentry.e("cameraViewConfig : " + a);
return a;
}
private void w0() {
this.D.f57k.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TakeHandWithIdCardPhotoActivity.this.A0(view);
}
});
this.D.f56j.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TakeHandWithIdCardPhotoActivity.this.B0(view);
}
});
this.D.d.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TakeHandWithIdCardPhotoActivity.this.C0(view);
}
});
this.D.f55i.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TakeHandWithIdCardPhotoActivity.this.D0(view);
}
});
this.D.e.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TakeHandWithIdCardPhotoActivity.this.E0(view);
}
});
this.D.f58l.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TakeHandWithIdCardPhotoActivity.this.F0(view);
}
});
}
public WindowInsetsCompat x0(View view, WindowInsetsCompat windowInsetsCompat) {
Insets insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.systemBars());
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.D.f57k.getLayoutParams();
marginLayoutParams.setMargins(marginLayoutParams.leftMargin, marginLayoutParams.topMargin, marginLayoutParams.rightMargin, getResources().getDimensionPixelOffset(2131165594) + insets.bottom);
this.D.f57k.setLayoutParams(marginLayoutParams);
ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) this.D.d.getLayoutParams();
marginLayoutParams2.setMargins(marginLayoutParams2.leftMargin, marginLayoutParams2.topMargin, marginLayoutParams2.rightMargin, getResources().getDimensionPixelOffset(2131165594) + insets.bottom);
this.D.d.setLayoutParams(marginLayoutParams2);
ViewGroup.MarginLayoutParams marginLayoutParams3 = (ViewGroup.MarginLayoutParams) this.D.e.getLayoutParams();
marginLayoutParams3.setMargins(marginLayoutParams3.leftMargin, getResources().getDimensionPixelOffset(2131165471) + insets.top, marginLayoutParams3.rightMargin, marginLayoutParams3.bottomMargin);
this.D.e.setLayoutParams(marginLayoutParams3);
return WindowInsetsCompat.CONSUMED;
}
public File y0(Bitmap bitmap) throws Exception {
File file = new File(FilePathUtil.f(this), "cardScanImage");
Bitmap e = BitmapUtil.e(bitmap, this.D.g.getWidth() / this.D.g.getHeight(), (this.D.f54h.getMaskLeft() + this.D.f54h.getLeft()) / this.D.f.getWidth(), (this.D.f54h.getMaskTop() + this.D.f54h.getTop()) / this.D.f.getHeight(), this.D.f54h.getContentWidth() / this.D.f.getWidth(), this.D.f54h.getContentHeight() / this.D.f.getHeight());
String k2 = ImageUtil.k(e, file);
if (e != null) {
e.recycle();
}
File file2 = new File(k2);
if (file2.exists()) {
return file2;
}
throw new Exception(getResources().getString(2131821076));
}
public void z0(Throwable th) throws Exception {
Sentry.h(th);
showErrorToast(th.getMessage());
}
@Override
public View getContentView() {
ActivityTakePictureBinding c = ActivityTakePictureBinding.c(getLayoutInflater());
this.D = c;
return c.getRoot();
}
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
w0();
q0();
this.E.requestPermission(this, new PermissionCallBack() {
public final void onResult(PermissionResult permissionResult) {
TakeHandWithIdCardPhotoActivity.this.G0(permissionResult);
}
}, new String[]{"android.permission.CAMERA"});
}
@Override
protected void onDestroy() {
RxUtil.b(this.H);
Bitmap bitmap = this.G;
if (bitmap != null) {
bitmap.recycle();
}
super.onDestroy();
}
@Override
@SuppressLint({"CheckResult"})
public Disposable runOnCreated(@NonNull Runnable runnable) {
return com.veda.supertoolkit.lifecycle.i.a(this, runnable);
}
@Override
@SuppressLint({"CheckResult"})
public Disposable runOnDestroy(@NonNull Runnable runnable) {
return com.veda.supertoolkit.lifecycle.i.b(this, runnable);
}
@Override
@SuppressLint({"CheckResult"})
public Disposable runOnEvent(@NonNull LifecycleEvent lifecycleEvent, @Nullable Runnable runnable) {
return com.veda.supertoolkit.lifecycle.i.c(this, lifecycleEvent, runnable);
}
}