Revert partial media permission handling

This commit is contained in:
Ensar Sarajčić 2023-08-30 09:04:52 +02:00
parent 3f67830d60
commit 2c82c1bee8
5 changed files with 12 additions and 9 deletions

View File

@ -100,7 +100,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} }
setupOptionsMenu() setupOptionsMenu()
handlePartialMediaPermissions(getPermissionsToRequest()) { handlePermission(getPermissionToRequest()) {
if (!it) { if (!it) {
toast(com.simplemobiletools.commons.R.string.no_storage_permissions) toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
finish() finish()

View File

@ -168,16 +168,19 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
private fun handleMediaPermissions(callback: (granted: Boolean) -> Unit) { private fun handleMediaPermissions(callback: (granted: Boolean) -> Unit) {
if (!hasAllPermissions(getPermissionsToRequest())) { handlePermission(getPermissionToRequest()) { granted ->
handlePartialMediaPermissions(getPermissionsToRequest(), true) { callback(granted)
callback(it) if (granted && isRPlus()) {
handlePermission(PERMISSION_MEDIA_LOCATION) {}
if (isTiramisuPlus()) {
handlePermission(PERMISSION_READ_MEDIA_VIDEO) {}
}
if (!mWasMediaManagementPromptShown) { if (!mWasMediaManagementPromptShown) {
mWasMediaManagementPromptShown = true mWasMediaManagementPromptShown = true
handleMediaManagementPrompt { } handleMediaManagementPrompt { }
} }
} }
} else {
callback(true)
} }
} }

View File

@ -381,7 +381,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
} }
private fun tryLoadGallery() { private fun tryLoadGallery() {
handlePartialMediaPermissions(getPermissionsToRequest()) { handlePermission(getPermissionToRequest()) {
if (it) { if (it) {
val dirName = when { val dirName = when {
mPath == FAVORITES -> getString(com.simplemobiletools.commons.R.string.favorites) mPath == FAVORITES -> getString(com.simplemobiletools.commons.R.string.favorites)

View File

@ -47,7 +47,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
setupOptionsMenu() setupOptionsMenu()
refreshMenuItems() refreshMenuItems()
handlePartialMediaPermissions(getPermissionsToRequest()) { handlePermission(getPermissionToRequest()) {
if (it) { if (it) {
checkIntent(savedInstanceState) checkIntent(savedInstanceState)
} else { } else {

View File

@ -96,7 +96,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
checkNotchSupport() checkNotchSupport()
(MediaActivity.mMedia.clone() as ArrayList<ThumbnailItem>).filterIsInstanceTo(mMediaFiles, Medium::class.java) (MediaActivity.mMedia.clone() as ArrayList<ThumbnailItem>).filterIsInstanceTo(mMediaFiles, Medium::class.java)
handlePartialMediaPermissions(getPermissionsToRequest()) { handlePermission(getPermissionToRequest()) {
if (it) { if (it) {
initViewPager() initViewPager()
} else { } else {