Skip to content

Commit eef4356

Browse files
Merge pull request #14524 from nextcloud/use-correct-permissions
Check API Level for READ_MEDIA_VISUAL_USER_SELECTED Permission
2 parents ad679da + 9b59ad7 commit eef4356

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class MediaFoldersDetectionWork constructor(
7575

7676
private val randomIdGenerator = Random(clock.currentTime)
7777

78-
@Suppress("LongMethod", "ComplexMethod", "NestedBlockDepth") // legacy code
78+
@Suppress("LongMethod", "ComplexMethod", "NestedBlockDepth", "ReturnCount") // legacy code
7979
override fun doWork(): Result {
8080
val arbitraryDataProvider: ArbitraryDataProvider = ArbitraryDataProviderImpl(context)
8181
val gson = Gson()

app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ object PermissionUtil {
137137
* Request a storage permission
138138
*/
139139
// TODO inject this class to avoid passing ViewThemeUtils around
140+
@Suppress("NestedBlockDepth")
140141
private fun requestStoragePermission(
141142
activity: Activity,
142143
readOnly: Boolean,
@@ -150,11 +151,18 @@ object PermissionUtil {
150151
val permissions = if (readOnly && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
151152
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
152153
// use granular media permissions
153-
arrayOf(
154-
Manifest.permission.READ_MEDIA_IMAGES,
155-
Manifest.permission.READ_MEDIA_VIDEO,
156-
Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
157-
)
154+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
155+
arrayOf(
156+
Manifest.permission.READ_MEDIA_IMAGES,
157+
Manifest.permission.READ_MEDIA_VIDEO,
158+
Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
159+
)
160+
} else {
161+
arrayOf(
162+
Manifest.permission.READ_MEDIA_IMAGES,
163+
Manifest.permission.READ_MEDIA_VIDEO
164+
)
165+
}
158166
} else {
159167
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE)
160168
}
@@ -311,6 +319,7 @@ object PermissionUtil {
311319
*
312320
* @param activity target activity
313321
*/
322+
@Suppress("ReturnCount")
314323
@JvmStatic
315324
fun requestMediaLocationPermission(activity: Activity) {
316325
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {

scripts/analysis/lint-results.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
DO NOT TOUCH; GENERATED BY DRONE
2-
<span class="mdl-layout-title">Lint Report: 3 errors and 55 warnings</span>
2+
<span class="mdl-layout-title">Lint Report: 3 errors and 54 warnings</span>

0 commit comments

Comments
 (0)