From a01025289de86c59836bb5b55e2467496c581a61 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Thu, 1 Aug 2024 23:50:58 -0400 Subject: [PATCH] Attempt both methods to open documents --- app/build.gradle | 6 ++--- .../hiddenramblings/tagmo/BrowserActivity.kt | 22 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 086b2681b..821e80a79 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { compileSdk 34 minSdk 21 targetSdk 34 - versionName "4.2.2" + versionName "4.2.3" versionCode = versionName.replace(".","").toInteger() * 10 vectorDrawables { @@ -118,7 +118,7 @@ android { } dependencies { - implementation 'androidx.activity:activity-ktx:1.9.0' + implementation 'androidx.activity:activity-ktx:1.9.1' implementation 'androidx.appcompat:appcompat:1.7.0' implementation "androidx.browser:browser:1.8.0" def androidx_camera = '1.3.4' @@ -129,7 +129,7 @@ dependencies { implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.core:core-ktx:1.13.1' implementation 'androidx.core:core-splashscreen:1.0.1' - implementation 'androidx.fragment:fragment-ktx:1.8.1' + implementation 'androidx.fragment:fragment-ktx:1.8.2' implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' diff --git a/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt b/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt index ef4006468..712959fab 100644 --- a/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt +++ b/app/src/main/java/com/hiddenramblings/tagmo/BrowserActivity.kt @@ -1402,21 +1402,25 @@ class BrowserActivity : AppCompatActivity(), BrowserSettingsListener, @Throws(ActivityNotFoundException::class) fun onDocumentRequested() { if (Version.isLollipop) { + val docTreeIntent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) + .putExtra("android.content.extra.SHOW_ADVANCED", true) + .putExtra("android.content.extra.FANCY", true) if (prefs.isDocumentStorage) { - onDocumentTree.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) - .putExtra("android.content.extra.SHOW_ADVANCED", true) - .putExtra("android.content.extra.FANCY", true) - ) + try { + onDocumentTree.launch(docTreeIntent) + } catch (anf: ActivityNotFoundException) { + onDocumentTree.launch(docTreeIntent.setType("*/*")) + } return } FittedSheets.newInstance().apply { setTitleText(this@BrowserActivity.getString(R.string.storage_setup)) setPositiveButton(this@BrowserActivity.getString(R.string.proceed)) { - onDocumentTree.launch( - Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) - .putExtra("android.content.extra.SHOW_ADVANCED", true) - .putExtra("android.content.extra.FANCY", true) - ) + try { + onDocumentTree.launch(docTreeIntent) + } catch (anf: ActivityNotFoundException) { + onDocumentTree.launch(docTreeIntent.setType("*/*")) + } } setNegativeButton(this@BrowserActivity.getString(R.string.close)) { finish()