From cb34c4349bb35b6e65188a95f95b0d61bb2f0c6b Mon Sep 17 00:00:00 2001 From: Helle <54167962+Helle-Daryd@users.noreply.github.com> Date: Tue, 23 Jul 2024 18:06:33 +0200 Subject: [PATCH 1/3] Fixed the image loading We are now requesting the correct permission on for Android sdk level 33 and above. --- app/src/main/AndroidManifest.xml | 3 ++- app/src/main/java/com/orgzly/android/util/AppPermissions.kt | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 } } From b711871e5852cefbcef831e15cef989ae6f5fc4f Mon Sep 17 00:00:00 2001 From: Victor Andreasson Date: Wed, 24 Jul 2024 01:41:52 +0200 Subject: [PATCH 2/3] Grant the READ_MEDIA_IMAGES permission during ExternalLinksTest --- .../java/com/orgzly/android/espresso/ExternalLinksTest.kt | 7 +++++++ 1 file changed, 7 insertions(+) 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..68faff3ca 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/ExternalLinksTest.kt +++ b/app/src/androidTest/java/com/orgzly/android/espresso/ExternalLinksTest.kt @@ -6,6 +6,7 @@ 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 +16,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 +27,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 + ) + companion object { @JvmStatic @Parameterized.Parameters(name = "{index}: {0}") From 1323925346f0e97bdbbf3735d1fdf143b81a55b3 Mon Sep 17 00:00:00 2001 From: Victor Andreasson Date: Wed, 24 Jul 2024 14:07:30 +0200 Subject: [PATCH 3/3] 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