mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 06:17:59 +01:00
request ACCESS_MEDIA_LOCATION permission
- the app has declared the MANAGE_MEDIA permission in the AndroidManifest - also requesting the ACCESS_MEDIA_LOCATION permission will make the system not to show the user the prompts from MediaStore.createWriteRequest and MediaStore.createDeleteRequest
This commit is contained in:
parent
6185a59a99
commit
86dce4e48d
1 changed files with 12 additions and 3 deletions
|
@ -145,7 +145,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
|
||||
// just request the permission, tryLoadGallery will then trigger in onResume
|
||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||
handleMediaPermissions {
|
||||
if (!it) {
|
||||
toast(R.string.no_storage_permissions)
|
||||
finish()
|
||||
|
@ -153,6 +153,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleMediaPermissions(callback: (granted: Boolean) -> Unit) {
|
||||
handlePermission(PERMISSION_WRITE_STORAGE) { granted ->
|
||||
callback(granted)
|
||||
if (granted && isSPlus()) {
|
||||
handlePermission(PERMISSION_MEDIA_LOCATION) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
|
||||
|
@ -435,9 +444,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
private fun tryLoadGallery() {
|
||||
// avoid calling anything right after granting the permission, it will be called from onResume()
|
||||
val wasMissingPermission = config.appRunCount == 1 && !hasPermission(PERMISSION_WRITE_STORAGE)
|
||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||
handleMediaPermissions {
|
||||
if (wasMissingPermission) {
|
||||
return@handlePermission
|
||||
return@handleMediaPermissions
|
||||
}
|
||||
|
||||
if (it) {
|
||||
|
|
Loading…
Reference in a new issue