导航菜单

页面标题

页面副标题

Rilo v2.0.21 - IntentUtils.java 源代码

正在查看: Rilo v2.0.21 应用的 IntentUtils.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.github.dhaval2404.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.dhaval2404.imagepicker.R;
import java.io.File;
import kotlin.Metadata;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.Intrinsics;

@Metadata(d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001a\u0010\u0003\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0007J#\u0010\t\u001a\u00020\u00042\f\u0010\n\u001a\b\u0012\u0004\u0012\u00020\f0\u000b2\u0006\u0010\r\u001a\u00020\u000eH\u0002¢\u0006\u0002\u0010\u000fJ+\u0010\u0010\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\f\u0010\n\u001a\b\u0012\u0004\u0012\u00020\f0\u000b2\u0006\u0010\r\u001a\u00020\u000eH\u0007¢\u0006\u0002\u0010\u0011J#\u0010\u0012\u001a\u00020\u00042\f\u0010\n\u001a\b\u0012\u0004\u0012\u00020\f0\u000b2\u0006\u0010\r\u001a\u00020\u000eH\u0002¢\u0006\u0002\u0010\u000fJ\u0018\u0010\u0013\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0014\u001a\u00020\u0015H\u0007J\u0010\u0010\u0016\u001a\u00020\u000e2\u0006\u0010\u0005\u001a\u00020\u0006H\u0007J'\u0010\u0017\u001a\u00020\u0004*\u00020\u00042\f\u0010\n\u001a\b\u0012\u0004\u0012\u00020\f0\u000b2\u0006\u0010\r\u001a\u00020\u000eH\u0002¢\u0006\u0002\u0010\u0018¨\u0006\u0019"}, d2 = {"Lcom/github/dhaval2404/imagepicker/util/IntentUtils;", "", "()V", "getCameraIntent", "Landroid/content/Intent;", "context", "Landroid/content/Context;", "file", "Ljava/io/File;", "getGalleryDocumentIntent", "mimeTypes", "", "", "allowMultipleFiles", "", "([Ljava/lang/String;Z)Landroid/content/Intent;", "getGalleryIntent", "(Landroid/content/Context;[Ljava/lang/String;Z)Landroid/content/Intent;", "getLegacyGalleryPickIntent", "getUriViewIntent", ShareConstants.MEDIA_URI, "Landroid/net/Uri;", "isCameraAppAvailable", "applyImageTypes", "(Landroid/content/Intent;[Ljava/lang/String;Z)Landroid/content/Intent;", "imagepicker_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class IntentUtils {
    public static final IntentUtils INSTANCE = new IntentUtils();

    private IntentUtils() {
    }

    @JvmStatic
    public static final Intent getGalleryIntent(Context context, String[] mimeTypes, boolean allowMultipleFiles) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(mimeTypes, "mimeTypes");
        if (Build.VERSION.SDK_INT >= 19) {
            Intent galleryDocumentIntent = INSTANCE.getGalleryDocumentIntent(mimeTypes, allowMultipleFiles);
            if (galleryDocumentIntent.resolveActivity(context.getPackageManager()) != null) {
                return galleryDocumentIntent;
            }
        }
        return INSTANCE.getLegacyGalleryPickIntent(mimeTypes, allowMultipleFiles);
    }

    private final Intent getGalleryDocumentIntent(String[] mimeTypes, boolean allowMultipleFiles) {
        Intent applyImageTypes = applyImageTypes(new Intent("android.intent.action.GET_CONTENT"), mimeTypes, allowMultipleFiles);
        applyImageTypes.addCategory("android.intent.category.OPENABLE");
        applyImageTypes.addFlags(64);
        applyImageTypes.addFlags(1);
        applyImageTypes.addFlags(2);
        return applyImageTypes;
    }

    private final Intent getLegacyGalleryPickIntent(String[] mimeTypes, boolean allowMultipleFiles) {
        return applyImageTypes(new Intent("android.intent.action.PICK"), mimeTypes, allowMultipleFiles);
    }

    private final Intent applyImageTypes(Intent intent, String[] strArr, boolean z) {
        intent.setType("image/*");
        if (!(strArr.length == 0)) {
            intent.putExtra("android.intent.extra.MIME_TYPES", strArr);
            intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", z);
        }
        return intent;
    }

    @JvmStatic
    public static final Intent getCameraIntent(Context context, File file) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(file, "file");
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        if (Build.VERSION.SDK_INT >= 24) {
            intent.putExtra("output", FileProvider.getUriForFile(context, context.getPackageName() + context.getString(R.string.image_picker_provider_authority_suffix), file));
        } else {
            intent.putExtra("output", Uri.fromFile(file));
        }
        return intent;
    }

    @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;
    }
}