diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/ExternalLinksTest.kt b/app/src/androidTest/java/com/orgzly/android/espresso/ExternalLinksTest.kt index a356f22a8..1e0218971 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/ExternalLinksTest.kt +++ b/app/src/androidTest/java/com/orgzly/android/espresso/ExternalLinksTest.kt @@ -1,11 +1,13 @@ package com.orgzly.android.espresso +import android.os.Build import android.os.Environment import android.os.SystemClock import androidx.test.core.app.ActivityScenario import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.rule.GrantPermissionRule import com.orgzly.R import com.orgzly.android.App import com.orgzly.android.OrgzlyTest @@ -15,6 +17,7 @@ import com.orgzly.android.espresso.util.EspressoUtils.onNoteInBook import com.orgzly.android.espresso.util.EspressoUtils.onSnackbar import com.orgzly.android.ui.main.MainActivity import org.hamcrest.Matchers.startsWith +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized @@ -25,6 +28,13 @@ class ExternalLinksTest(private val param: Parameter) : OrgzlyTest() { data class Parameter(val link: String, val check: () -> Any) + @get:Rule + val grantPermissionRule: GrantPermissionRule = if (Build.VERSION.SDK_INT >= 33) { + GrantPermissionRule.grant(android.Manifest.permission.READ_MEDIA_IMAGES) + } else { + GrantPermissionRule.grant() + } + companion object { @JvmStatic @Parameterized.Parameters(name = "{index}: {0}") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4242e8453..1f46ad192 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,7 +12,8 @@ - + + diff --git a/app/src/main/java/com/orgzly/android/util/AppPermissions.kt b/app/src/main/java/com/orgzly/android/util/AppPermissions.kt index 426fa497e..0e7d05da5 100644 --- a/app/src/main/java/com/orgzly/android/util/AppPermissions.kt +++ b/app/src/main/java/com/orgzly/android/util/AppPermissions.kt @@ -70,7 +70,10 @@ object AppPermissions { Usage.BOOK_EXPORT -> Manifest.permission.WRITE_EXTERNAL_STORAGE Usage.SYNC_START -> Manifest.permission.WRITE_EXTERNAL_STORAGE Usage.SAVED_SEARCHES_EXPORT_IMPORT -> Manifest.permission.WRITE_EXTERNAL_STORAGE - Usage.EXTERNAL_FILES_ACCESS -> Manifest.permission.READ_EXTERNAL_STORAGE + Usage.EXTERNAL_FILES_ACCESS -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) + Manifest.permission.READ_MEDIA_IMAGES + else + Manifest.permission.READ_EXTERNAL_STORAGE Usage.POST_NOTIFICATIONS -> Manifest.permission.POST_NOTIFICATIONS } }