what-the-bank/sources/io/beid/beidk/services/DocumentService.java

41 lines
1.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package io.beid.beidk.services;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import androidx.core.app.ActivityCompat;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import o.C9257dgM;
/* loaded from: classes5.dex */
public class DocumentService {
public String dispatchTakePictureIntent(Activity activity, int i, String str) throws IOException {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (intent.resolveActivity(activity.getPackageManager()) == null) {
return "";
}
String format = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
StringBuilder sb = new StringBuilder("JPEG_");
sb.append(format);
sb.append("_");
File createTempFile = File.createTempFile(sb.toString(), ".jpg", activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES));
Uri uriForFile = C9257dgM.getUriForFile(activity, str, createTempFile);
String absolutePath = createTempFile.getAbsolutePath();
intent.putExtra("output", uriForFile);
ActivityCompat.lQ_(activity, intent, i, null);
return absolutePath;
}
public void requestCameraPermission(Activity activity, int i) {
ActivityCompat.lM_(activity, new String[]{"android.permission.CAMERA"}, i);
}
public boolean isCameraPermissionGranted(Activity activity) {
return ActivityCompat.checkSelfPermission(activity, "android.permission.CAMERA") == 0;
}
}