From 32d87010bbd053185be8b1c817499df310096c33 Mon Sep 17 00:00:00 2001 From: euxane Date: Wed, 18 Sep 2024 23:41:13 +0200 Subject: browse files intent: remove flaky redundant activity resolver check --- .../tincapp/storageprovider/BrowseFilesIntents.kt | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'app/src/main/java/org') diff --git a/app/src/main/java/org/pacien/tincapp/storageprovider/BrowseFilesIntents.kt b/app/src/main/java/org/pacien/tincapp/storageprovider/BrowseFilesIntents.kt index a4cc5c5..59a4246 100644 --- a/app/src/main/java/org/pacien/tincapp/storageprovider/BrowseFilesIntents.kt +++ b/app/src/main/java/org/pacien/tincapp/storageprovider/BrowseFilesIntents.kt @@ -27,15 +27,11 @@ object BrowseFilesIntents { fun openDocumentTree(context: Context, documentId: String) = openDocumentTree(context, FilesDocumentsProvider.documentUri(documentId)) - private fun openDocumentTree(context: Context, contentUri: Uri) { - val intent = Intent(Intent.ACTION_VIEW).apply { - setDataAndType(contentUri, Document.MIME_TYPE_DIR) - addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION) - } - - if (intent.resolveActivity(context.packageManager) == null) - throw RuntimeException("No opener found for " + Document.MIME_TYPE_DIR) - - context.startActivity(intent) - } -} \ No newline at end of file + private fun openDocumentTree(context: Context, contentUri: Uri) = + context.startActivity( + Intent(Intent.ACTION_VIEW).apply { + setDataAndType(contentUri, Document.MIME_TYPE_DIR) + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION) + } + ) +} -- cgit v1.2.3