Skip to content

Commit

Permalink
Merge pull request #14406 from nextcloud/backport/14405/stable-3.30
Browse files Browse the repository at this point in the history
[stable-3.30] Don't Ask ACCESS_MEDIA_LOCATION Permission If App Already Has Full Disk Access
  • Loading branch information
tobiasKaminsky authored Jan 14, 2025
2 parents 7afaea2 + 75b20f8 commit ba6b01c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,22 @@ object PermissionUtil {
*/
@JvmStatic
fun requestMediaLocationPermission(activity: Activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (!checkSelfPermission(activity, Manifest.permission.ACCESS_MEDIA_LOCATION)) {
ActivityCompat.requestPermissions(
activity,
arrayOf(Manifest.permission.ACCESS_MEDIA_LOCATION),
PERMISSIONS_MEDIA_LOCATION
)
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && Environment.isExternalStorageManager()) {
return
}

if (checkSelfPermission(activity, Manifest.permission.ACCESS_MEDIA_LOCATION)) {
return
}

ActivityCompat.requestPermissions(
activity,
arrayOf(Manifest.permission.ACCESS_MEDIA_LOCATION),
PERMISSIONS_MEDIA_LOCATION
)
}
}

0 comments on commit ba6b01c

Please sign in to comment.