mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
Merge pull request #2412 from KryptKode/feat/request_access_media_location
request ACCESS_MEDIA_LOCATION permission
This commit is contained in:
@@ -145,7 +145,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// just request the permission, tryLoadGallery will then trigger in onResume
|
// just request the permission, tryLoadGallery will then trigger in onResume
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
handleMediaPermissions {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(R.string.no_storage_permissions)
|
||||||
finish()
|
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() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
|
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
|
||||||
@@ -435,9 +444,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||||||
private fun tryLoadGallery() {
|
private fun tryLoadGallery() {
|
||||||
// avoid calling anything right after granting the permission, it will be called from onResume()
|
// avoid calling anything right after granting the permission, it will be called from onResume()
|
||||||
val wasMissingPermission = config.appRunCount == 1 && !hasPermission(PERMISSION_WRITE_STORAGE)
|
val wasMissingPermission = config.appRunCount == 1 && !hasPermission(PERMISSION_WRITE_STORAGE)
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
handleMediaPermissions {
|
||||||
if (wasMissingPermission) {
|
if (wasMissingPermission) {
|
||||||
return@handlePermission
|
return@handleMediaPermissions
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it) {
|
if (it) {
|
||||||
|
Reference in New Issue
Block a user