From 1323925346f0e97bdbbf3735d1fdf143b81a55b3 Mon Sep 17 00:00:00 2001 From: Victor Andreasson Date: Wed, 24 Jul 2024 14:07:30 +0200 Subject: [PATCH] Grant permission when running the relevant API version --- .../com/orgzly/android/espresso/ExternalLinksTest.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 68faff3ca..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,5 +1,6 @@ package com.orgzly.android.espresso +import android.os.Build import android.os.Environment import android.os.SystemClock import androidx.test.core.app.ActivityScenario @@ -28,9 +29,11 @@ class ExternalLinksTest(private val param: Parameter) : OrgzlyTest() { data class Parameter(val link: String, val check: () -> Any) @get:Rule - val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant( - android.Manifest.permission.READ_MEDIA_IMAGES - ) + val grantPermissionRule: GrantPermissionRule = if (Build.VERSION.SDK_INT >= 33) { + GrantPermissionRule.grant(android.Manifest.permission.READ_MEDIA_IMAGES) + } else { + GrantPermissionRule.grant() + } companion object { @JvmStatic