Skip to content

Commit

Permalink
Merge pull request #14405 from nextcloud/dont-ask-ACCESS_MEDIA_LOCATI…
Browse files Browse the repository at this point in the history
…ON-permission-if-device-have-full-disk-access

Don't Ask ACCESS_MEDIA_LOCATION Permission If App Already Has Full Disk Access
  • Loading branch information
tobiasKaminsky authored Jan 14, 2025
2 parents 0abff31 + 5c8f4b1 commit cb137eb
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 cb137eb

Please sign in to comment.