正在查看: Rilo v2.0.21 应用的 IntentUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 IntentUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.github.drjacky.imagepicker.util;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import androidx.core.content.FileProvider;
import androidx.documentfile.provider.DocumentFile;
import com.facebook.share.internal.ShareConstants;
import com.github.drjacky.imagepicker.R;
import java.io.File;
import kotlin.Metadata;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u00006\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\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0018\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0007J\u001b\u0010\u000b\u001a\u00020\u00062\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u00040\rH\u0002¢\u0006\u0002\u0010\u000eJ#\u0010\u000f\u001a\u00020\u00062\u0006\u0010\u0010\u001a\u00020\u00112\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u00040\rH\u0007¢\u0006\u0002\u0010\u0012J\u001b\u0010\u0013\u001a\u00020\u00062\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u00040\rH\u0002¢\u0006\u0002\u0010\u000eJ\u0018\u0010\u0014\u001a\u00020\u00062\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0007\u001a\u00020\bH\u0007J\u0010\u0010\u0015\u001a\u00020\n2\u0006\u0010\u0010\u001a\u00020\u0011H\u0007J\u0010\u0010\u0016\u001a\u00020\n2\u0006\u0010\u0010\u001a\u00020\u0011H\u0007J\u001f\u0010\u0017\u001a\u00020\u0006*\u00020\u00062\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u00040\rH\u0002¢\u0006\u0002\u0010\u0018R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u0019"}, d2 = {"Lcom/github/drjacky/imagepicker/util/IntentUtils;", "", "()V", "CAMERA_FACING_EXTRA", "", "getCameraIntent", "Landroid/content/Intent;", ShareConstants.MEDIA_URI, "Landroid/net/Uri;", "tryFrontCamera", "", "getGalleryDocumentIntent", "mimeTypes", "", "([Ljava/lang/String;)Landroid/content/Intent;", "getGalleryIntent", "context", "Landroid/content/Context;", "(Landroid/content/Context;[Ljava/lang/String;)Landroid/content/Intent;", "getLegacyGalleryPickIntent", "getUriViewIntent", "isCameraAppAvailable", "isCameraHardwareAvailable", "applyImageTypes", "(Landroid/content/Intent;[Ljava/lang/String;)Landroid/content/Intent;", "imagepicker_release"}, k = 1, mv = {1, 7, 1}, xi = 48)
public final class IntentUtils {
private static final String CAMERA_FACING_EXTRA = "android.intent.extras.CAMERA_FACING";
public static final IntentUtils INSTANCE = new IntentUtils();
private IntentUtils() {
}
@JvmStatic
public static final Intent getGalleryIntent(Context context, String[] mimeTypes) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(mimeTypes, "mimeTypes");
if (Build.VERSION.SDK_INT >= 19) {
Intent galleryDocumentIntent = INSTANCE.getGalleryDocumentIntent(mimeTypes);
if (galleryDocumentIntent.resolveActivity(context.getPackageManager()) != null) {
return galleryDocumentIntent;
}
}
return INSTANCE.getLegacyGalleryPickIntent(mimeTypes);
}
private final Intent getGalleryDocumentIntent(String[] mimeTypes) {
Intent applyImageTypes = applyImageTypes(new Intent("android.intent.action.GET_CONTENT"), mimeTypes);
applyImageTypes.addCategory("android.intent.category.OPENABLE");
applyImageTypes.addFlags(64);
applyImageTypes.addFlags(1);
applyImageTypes.addFlags(2);
return applyImageTypes;
}
private final Intent getLegacyGalleryPickIntent(String[] mimeTypes) {
return applyImageTypes(new Intent("android.intent.action.PICK"), mimeTypes);
}
private final Intent applyImageTypes(Intent intent, String[] strArr) {
intent.setType("image/*");
if (!(strArr.length == 0)) {
intent.putExtra("android.intent.extra.MIME_TYPES", strArr);
}
return intent;
}
@JvmStatic
public static final Intent getCameraIntent(Uri uri, boolean tryFrontCamera) {
Intrinsics.checkNotNullParameter(uri, ShareConstants.MEDIA_URI);
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (tryFrontCamera) {
if (Build.VERSION.SDK_INT >= 26) {
intent.putExtra(CAMERA_FACING_EXTRA, 0);
intent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true);
intent.putExtra(CAMERA_FACING_EXTRA, 0);
intent.putExtra(CAMERA_FACING_EXTRA, 1);
intent.putExtra("com.google.assistant.extra.USE_FRONT_CAMERA", true);
intent.putExtra("android.intent.extras.LENS_FACING_FRONT", 1);
intent.putExtra("camerafacing", "front");
intent.putExtra("previous_mode", "front");
intent.putExtra("default_camera", "1");
intent.putExtra("default_mode", "com.huawei.camera2.mode.photo.PhotoMode");
} else if (Build.VERSION.SDK_INT >= 22 && Build.VERSION.SDK_INT < 26) {
intent.putExtra(CAMERA_FACING_EXTRA, 0);
} else if (Build.VERSION.SDK_INT < 22) {
intent.putExtra(CAMERA_FACING_EXTRA, 1);
}
}
if (Build.VERSION.SDK_INT >= 24) {
intent.putExtra("output", uri);
} else {
intent.putExtra("output", uri);
}
return intent;
}
@JvmStatic
public static final boolean isCameraHardwareAvailable(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
return context.getPackageManager().hasSystemFeature("android.hardware.camera.any");
}
@JvmStatic
public static final boolean isCameraAppAvailable(Context context) {
Intrinsics.checkNotNullParameter(context, "context");
return new Intent("android.media.action.IMAGE_CAPTURE").resolveActivity(context.getPackageManager()) != null;
}
@JvmStatic
public static final Intent getUriViewIntent(Context context, Uri uri) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(uri, ShareConstants.MEDIA_URI);
Intent intent = new Intent("android.intent.action.VIEW");
String str = context.getPackageName() + context.getString(R.string.image_picker_provider_authority_suffix);
DocumentFile fromSingleUri = DocumentFile.fromSingleUri(context, uri);
boolean z = false;
if (fromSingleUri != null && fromSingleUri.canRead()) {
z = true;
}
if (!z) {
String realPath = FileUriUtils.INSTANCE.getRealPath(context, uri);
Intrinsics.checkNotNull(realPath);
uri = FileProvider.getUriForFile(context, str, new File(realPath));
}
intent.setDataAndType(uri, "image/*");
intent.addFlags(1);
return intent;
}
}