Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check API Level for READ_MEDIA_VISUAL_USER_SELECTED Permission #14524

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MediaFoldersDetectionWork constructor(

private val randomIdGenerator = Random(clock.currentTime)

@Suppress("LongMethod", "ComplexMethod", "NestedBlockDepth") // legacy code
@Suppress("LongMethod", "ComplexMethod", "NestedBlockDepth", "ReturnCount") // legacy code
override fun doWork(): Result {
val arbitraryDataProvider: ArbitraryDataProvider = ArbitraryDataProviderImpl(context)
val gson = Gson()
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ object PermissionUtil {
* Request a storage permission
*/
// TODO inject this class to avoid passing ViewThemeUtils around
@Suppress("NestedBlockDepth")
private fun requestStoragePermission(
activity: Activity,
readOnly: Boolean,
Expand All @@ -150,11 +151,18 @@ object PermissionUtil {
val permissions = if (readOnly && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// use granular media permissions
arrayOf(
Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.READ_MEDIA_VIDEO,
Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
arrayOf(
Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.READ_MEDIA_VIDEO,
Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
)
} else {
arrayOf(
Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.READ_MEDIA_VIDEO
)
}
} else {
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE)
}
Expand Down Expand Up @@ -311,6 +319,7 @@ object PermissionUtil {
*
* @param activity target activity
*/
@Suppress("ReturnCount")
@JvmStatic
fun requestMediaLocationPermission(activity: Activity) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 3 errors and 55 warnings</span>
<span class="mdl-layout-title">Lint Report: 3 errors and 54 warnings</span>
Loading