正在查看: TruCred v1.1.3 应用的 CameraActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: TruCred v1.1.3 应用的 CameraActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.wildma.idcardcamera.camera;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.hardware.Camera;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import androidx.core.app.ActivityCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import com.hjq.permissions.Permission;
import com.wildma.idcardcamera.R$id;
import com.wildma.idcardcamera.R$layout;
import com.wildma.idcardcamera.R$mipmap;
import com.wildma.idcardcamera.camera.CameraActivity;
import com.wildma.idcardcamera.utils.CommonUtils;
import com.wildma.idcardcamera.utils.FileUtils;
import com.wildma.idcardcamera.utils.ImageUtils;
import com.wildma.idcardcamera.utils.PermissionUtils;
import com.wildma.idcardcamera.utils.ScreenUtils;
import java.io.File;
public class CameraActivity extends Activity implements View.OnClickListener {
public CameraPreview a;
public View b;
public int c;
public boolean d = true;
public final void e() {
setContentView(R$layout.activity_camera);
this.c = getIntent().getIntExtra("take_type", 0);
g();
f();
}
public final void f() {
this.a.setOnClickListener(this);
findViewById(R$id.btn_back).setOnClickListener(this);
findViewById(R$id.capture_button).setOnClickListener(this);
}
public final void g() {
this.a = (CameraPreview) findViewById(R$id.camera_preview);
this.b = findViewById(R$id.floor_mask);
Math.min(ScreenUtils.b(this), ScreenUtils.a(this));
Math.max(ScreenUtils.b(this), ScreenUtils.a(this));
int i = this.c;
if (i == 1) {
this.b.setBackground(getDrawable(R$mipmap.bg_camera_floor_mask));
} else if (i == 2) {
this.b.setBackground(getDrawable(R$mipmap.bg_camera_floor_mask_back));
}
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
CameraActivity.this.i();
}
}, 500L);
}
public final void h() {
this.a.setVisibility(0);
this.a.b();
}
public final void i() {
runOnUiThread(new Runnable() {
@Override
public final void run() {
CameraActivity.this.h();
}
});
}
public final void j(Camera.Size size, byte[] bArr) {
Bitmap a = ImageUtils.a(bArr, size.width, size.height);
String str = FileUtils.e(this) + File.separator + System.currentTimeMillis() + ".jpg";
if (ImageUtils.d(a, str, Bitmap.CompressFormat.JPEG)) {
Intent intent = new Intent();
intent.putExtra("image_path", str);
setResult(17, intent);
finish();
}
}
public final void k(final byte[] bArr, Camera camera) {
final Camera.Size previewSize = camera.getParameters().getPreviewSize();
camera.stopPreview();
new Thread(new Runnable() {
@Override
public final void run() {
CameraActivity.this.j(previewSize, bArr);
}
}).start();
}
public final void l() {
this.a.setEnabled(false);
CameraUtils.a().setOneShotPreviewCallback(new Camera.PreviewCallback() {
@Override
public final void onPreviewFrame(byte[] bArr, Camera camera) {
CameraActivity.this.k(bArr, camera);
}
});
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R$id.camera_preview) {
this.a.b();
return;
}
if (id == R$id.btn_back) {
finish();
} else {
if (id != R$id.capture_button || CommonUtils.a()) {
return;
}
l();
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView()).hide(WindowInsetsCompat.Type.systemBars());
if (PermissionUtils.a(this, 18, new String[]{Permission.CAMERA})) {
e();
}
}
@Override
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
super.onRequestPermissionsResult(i, strArr, iArr);
boolean z2 = true;
for (int i2 = 0; i2 < strArr.length; i2++) {
if (iArr[i2] == -1) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, strArr[i2]) && this.d) {
this.d = false;
}
z2 = false;
}
}
this.d = true;
if (z2) {
e();
} else {
finish();
}
}
@Override
public void onStart() {
super.onStart();
CameraPreview cameraPreview = this.a;
if (cameraPreview != null) {
cameraPreview.f();
}
}
@Override
public void onStop() {
super.onStop();
CameraPreview cameraPreview = this.a;
if (cameraPreview != null) {
cameraPreview.g();
}
}
}