正在查看: Biko v2.0.23 应用的 ImagePickerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 ImagePickerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.github.dhaval2404.imagepicker;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import androidx.activity.ComponentActivity;
import com.facebook.share.internal.MessengerShareContentUtility;
import com.facebook.share.internal.ShareConstants;
import com.github.dhaval2404.imagepicker.constant.ImageProvider;
import com.github.dhaval2404.imagepicker.provider.CameraProvider;
import com.github.dhaval2404.imagepicker.provider.CompressionProvider;
import com.github.dhaval2404.imagepicker.provider.CropProvider;
import com.github.dhaval2404.imagepicker.provider.GalleryProvider;
import com.github.dhaval2404.imagepicker.util.FileUriUtils;
import com.github.dhaval2404.imagepicker.util.GalleryFile;
import java.io.File;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Iterator;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
@Metadata(d1 = {"\u0000r\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u0000 02\u00020\u0001:\u00010B\u0005¢\u0006\u0002\u0010\u0002J\u0012\u0010\u000b\u001a\u00020\f2\b\u0010\r\u001a\u0004\u0018\u00010\u000eH\u0002J\"\u0010\u000f\u001a\u00020\f2\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0012\u001a\u00020\u00112\b\u0010\u0013\u001a\u0004\u0018\u00010\u0014H\u0014J\b\u0010\u0015\u001a\u00020\fH\u0016J\u0012\u0010\u0016\u001a\u00020\f2\b\u0010\r\u001a\u0004\u0018\u00010\u000eH\u0014J+\u0010\u0017\u001a\u00020\f2\u0006\u0010\u0010\u001a\u00020\u00112\f\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00192\u0006\u0010\u001b\u001a\u00020\u001cH\u0016¢\u0006\u0002\u0010\u001dJ\u0010\u0010\u001e\u001a\u00020\f2\u0006\u0010\u001f\u001a\u00020\u000eH\u0016J\u000e\u0010 \u001a\u00020\f2\u0006\u0010!\u001a\u00020\"J\u000e\u0010#\u001a\u00020\f2\u0006\u0010!\u001a\u00020\"J\u000e\u0010$\u001a\u00020\f2\u0006\u0010%\u001a\u00020\u001aJ\u0018\u0010&\u001a\u00020\f2\u0006\u0010'\u001a\u00020(2\b\u0010!\u001a\u0004\u0018\u00010\"J\u001e\u0010&\u001a\u00020\f2\u0016\u0010)\u001a\u0012\u0012\u0004\u0012\u00020+0*j\b\u0012\u0004\u0012\u00020+`,J\u001e\u0010-\u001a\u00020\f2\u0016\u0010)\u001a\u0012\u0012\u0004\u0012\u00020+0*j\b\u0012\u0004\u0012\u00020+`,J\u000e\u0010.\u001a\u00020\f2\u0006\u0010!\u001a\u00020\"J\u0006\u0010/\u001a\u00020\fR\u0010\u0010\u0003\u001a\u0004\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\t\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000¨\u00061"}, d2 = {"Lcom/github/dhaval2404/imagepicker/ImagePickerActivity;", "Landroidx/activity/ComponentActivity;", "()V", "mCameraProvider", "Lcom/github/dhaval2404/imagepicker/provider/CameraProvider;", "mCompressionProvider", "Lcom/github/dhaval2404/imagepicker/provider/CompressionProvider;", "mCropProvider", "Lcom/github/dhaval2404/imagepicker/provider/CropProvider;", "mGalleryProvider", "Lcom/github/dhaval2404/imagepicker/provider/GalleryProvider;", "loadBundle", "", "savedInstanceState", "Landroid/os/Bundle;", "onActivityResult", "requestCode", "", "resultCode", ShareConstants.WEB_DIALOG_PARAM_DATA, "Landroid/content/Intent;", "onBackPressed", "onCreate", "onRequestPermissionsResult", "permissions", "", "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onSaveInstanceState", "outState", "setCompressedImage", ShareConstants.MEDIA_URI, "Landroid/net/Uri;", "setCropImage", "setError", ShareConstants.WEB_DIALOG_PARAM_MESSAGE, "setImage", "file", "Ljava/io/File;", "files", "Ljava/util/ArrayList;", "Lcom/github/dhaval2404/imagepicker/util/GalleryFile;", "Lkotlin/collections/ArrayList;", "setMultipleResult", "setResult", "setResultCancel", "Companion", "imagepicker_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class ImagePickerActivity extends ComponentActivity {
public static final Companion INSTANCE = new Companion(null);
private static final String TAG = "image_picker";
private CameraProvider mCameraProvider;
private CompressionProvider mCompressionProvider;
private CropProvider mCropProvider;
private GalleryProvider mGalleryProvider;
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[ImageProvider.values().length];
try {
iArr[ImageProvider.GALLERY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[ImageProvider.CAMERA.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
$EnumSwitchMapping$0 = iArr;
}
}
@Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0015\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0000¢\u0006\u0002\b\tJ\u0010\u0010\n\u001a\u00020\u000b2\b\u0010\f\u001a\u0004\u0018\u00010\u0004J\u0010\u0010\r\u001a\u00020\u000b2\b\u0010\f\u001a\u0004\u0018\u00010\u0004R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lcom/github/dhaval2404/imagepicker/ImagePickerActivity$Companion;", "", "()V", "TAG", "", "getCancelledIntent", "Landroid/content/Intent;", "context", "Landroid/content/Context;", "getCancelledIntent$imagepicker_release", "isAudioFile", "", "path", "isVideoFile", "imagepicker_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final Intent getCancelledIntent$imagepicker_release(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
Intent intent = new Intent();
String string = context.getString(R.string.error_task_cancelled);
Intrinsics.checkNotNullExpressionValue(string, "context.getString(R.string.error_task_cancelled)");
intent.putExtra("extra.error", string);
return intent;
}
public final boolean isVideoFile(String path) {
String guessContentTypeFromName = URLConnection.guessContentTypeFromName(path);
Log.e(ImagePickerActivity.TAG, "isVideoFile: " + guessContentTypeFromName);
return guessContentTypeFromName != null && StringsKt.startsWith$default(guessContentTypeFromName, MessengerShareContentUtility.MEDIA_VIDEO, false, 2, (Object) null);
}
public final boolean isAudioFile(String path) {
String guessContentTypeFromName = URLConnection.guessContentTypeFromName(path);
Log.e("Gallery Provider", "isAudioFile: meme type " + guessContentTypeFromName);
return guessContentTypeFromName != null && StringsKt.startsWith$default(guessContentTypeFromName, "audio", false, 2, (Object) null);
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadBundle(savedInstanceState);
}
public void onSaveInstanceState(Bundle outState) {
Intrinsics.checkNotNullParameter(outState, "outState");
CameraProvider cameraProvider = this.mCameraProvider;
if (cameraProvider != null) {
cameraProvider.onSaveInstanceState(outState);
}
CropProvider cropProvider = this.mCropProvider;
if (cropProvider == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCropProvider");
cropProvider = null;
}
cropProvider.onSaveInstanceState(outState);
super.onSaveInstanceState(outState);
}
private final void loadBundle(Bundle savedInstanceState) {
CameraProvider cameraProvider;
CropProvider cropProvider = new CropProvider(this);
this.mCropProvider = cropProvider;
cropProvider.onRestoreInstanceState(savedInstanceState);
this.mCompressionProvider = new CompressionProvider(this);
Intent intent = getIntent();
ImageProvider imageProvider = (ImageProvider) (intent != null ? intent.getSerializableExtra("extra.image_provider") : null);
int i = imageProvider == null ? -1 : WhenMappings.$EnumSwitchMapping$0[imageProvider.ordinal()];
if (i == 1) {
GalleryProvider galleryProvider = new GalleryProvider(this);
this.mGalleryProvider = galleryProvider;
if (savedInstanceState == null) {
galleryProvider.startIntent();
Unit unit = Unit.INSTANCE;
return;
}
return;
}
if (i == 2) {
CameraProvider cameraProvider2 = new CameraProvider(this);
this.mCameraProvider = cameraProvider2;
cameraProvider2.onRestoreInstanceState(savedInstanceState);
if (savedInstanceState != null || (cameraProvider = this.mCameraProvider) == null) {
return;
}
cameraProvider.startIntent();
Unit unit2 = Unit.INSTANCE;
return;
}
Log.e(TAG, "Image provider can not be null");
String string = getString(R.string.error_task_cancelled);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.error_task_cancelled)");
setError(string);
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
Intrinsics.checkNotNullParameter(permissions, "permissions");
Intrinsics.checkNotNullParameter(grantResults, "grantResults");
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
CameraProvider cameraProvider = this.mCameraProvider;
if (cameraProvider != null) {
cameraProvider.onRequestPermissionsResult(requestCode);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
CameraProvider cameraProvider = this.mCameraProvider;
if (cameraProvider != null) {
cameraProvider.onActivityResult(requestCode, resultCode, data);
}
GalleryProvider galleryProvider = this.mGalleryProvider;
if (galleryProvider != null) {
galleryProvider.onActivityResult(requestCode, resultCode, data);
}
CropProvider cropProvider = this.mCropProvider;
if (cropProvider == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCropProvider");
cropProvider = null;
}
cropProvider.onActivityResult(requestCode, resultCode, data);
}
public void onBackPressed() {
setResultCancel();
}
public final void setImage(File file, Uri uri) {
Intrinsics.checkNotNullParameter(file, "file");
if (INSTANCE.isVideoFile(Uri.fromFile(file).toString())) {
Uri fromFile = Uri.fromFile(file);
Intrinsics.checkNotNullExpressionValue(fromFile, "fromFile(file)");
setResult(fromFile);
return;
}
CropProvider cropProvider = this.mCropProvider;
if (cropProvider == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCropProvider");
cropProvider = null;
}
if (!cropProvider.getMCrop()) {
Uri fromFile2 = Uri.fromFile(file);
Intrinsics.checkNotNullExpressionValue(fromFile2, "fromFile(file)");
setResult(fromFile2);
return;
}
CropProvider cropProvider2 = this.mCropProvider;
if (cropProvider2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCropProvider");
cropProvider2 = null;
}
Uri fromFile3 = Uri.fromFile(file);
Intrinsics.checkNotNullExpressionValue(fromFile3, "fromFile(file)");
CropProvider.startIntent$default(cropProvider2, fromFile3, 0, 2, null);
}
public final void setImage(ArrayList<GalleryFile> files) {
Intrinsics.checkNotNullParameter(files, "files");
if (!files.isEmpty()) {
CropProvider cropProvider = this.mCropProvider;
if (cropProvider == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCropProvider");
cropProvider = null;
}
if (cropProvider.getMCrop() && files.size() == 1 && files.get(0).getType() == GalleryProvider.FILETYPE.IMAGE) {
Uri fromFile = Uri.fromFile(new File(files.get(0).getPath()));
Intrinsics.checkNotNullExpressionValue(fromFile, "fromFile(File(files[0].path))");
setResult(fromFile);
return;
}
}
setMultipleResult(files);
}
public final void setMultipleResult(ArrayList<GalleryFile> files) {
Intrinsics.checkNotNullParameter(files, "files");
Log.e(TAG, "setResult: Called " + files);
Intent intent = new Intent();
Iterator<GalleryFile> it = files.iterator();
while (it.hasNext()) {
Log.e(TAG, "setMultipleResult: " + it.next().getPath());
}
intent.putParcelableArrayListExtra("extra.file_path", files);
setResult(-1, intent);
finish();
}
public final void setCropImage(Uri uri) {
Intrinsics.checkNotNullParameter(uri, ShareConstants.MEDIA_URI);
CameraProvider cameraProvider = this.mCameraProvider;
if (cameraProvider != null) {
cameraProvider.delete();
}
CompressionProvider compressionProvider = this.mCompressionProvider;
CompressionProvider compressionProvider2 = null;
if (compressionProvider == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCompressionProvider");
compressionProvider = null;
}
if (compressionProvider.isCompressionRequired(uri)) {
CompressionProvider compressionProvider3 = this.mCompressionProvider;
if (compressionProvider3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCompressionProvider");
} else {
compressionProvider2 = compressionProvider3;
}
compressionProvider2.compress(uri);
return;
}
setResult(uri);
}
public final void setCompressedImage(Uri uri) {
Intrinsics.checkNotNullParameter(uri, ShareConstants.MEDIA_URI);
CameraProvider cameraProvider = this.mCameraProvider;
if (cameraProvider != null) {
cameraProvider.delete();
}
CropProvider cropProvider = this.mCropProvider;
if (cropProvider == null) {
Intrinsics.throwUninitializedPropertyAccessException("mCropProvider");
cropProvider = null;
}
cropProvider.delete();
setResult(uri);
}
public final void setResult(Uri uri) {
Intrinsics.checkNotNullParameter(uri, ShareConstants.MEDIA_URI);
Log.e(TAG, "setResult: Called " + uri);
Intent intent = new Intent();
intent.setData(uri);
intent.putExtra(ShareConstants.MEDIA_URI, uri.toString());
intent.putExtra("extra.file_path", FileUriUtils.INSTANCE.getRealPath((Context) this, uri));
setResult(-1, intent);
finish();
}
public final void setResultCancel() {
setResult(0, INSTANCE.getCancelledIntent$imagepicker_release((Context) this));
finish();
}
public final void setError(String message) {
Intrinsics.checkNotNullParameter(message, ShareConstants.WEB_DIALOG_PARAM_MESSAGE);
Intent intent = new Intent();
intent.putExtra("extra.error", message);
setResult(64, intent);
finish();
}
}