From 3f67830d603a5a63b742aba2bd9b727356312f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 25 Aug 2023 16:08:23 +0200 Subject: [PATCH] Allow using app only when all images are allowed --- .../gallery/pro/activities/MainActivity.kt | 19 ++++++++++--------- app/src/main/res/menu/menu_main.xml | 5 ----- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 26fae8cd9..59b860f18 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -167,13 +167,17 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } - private fun handleMediaPermissions(force: Boolean = false, callback: (granted: Boolean) -> Unit) { - handlePartialMediaPermissions(getPermissionsToRequest(), force) { - callback(it) - if (!mWasMediaManagementPromptShown) { - mWasMediaManagementPromptShown = true - handleMediaManagementPrompt { } + private fun handleMediaPermissions(callback: (granted: Boolean) -> Unit) { + if (!hasAllPermissions(getPermissionsToRequest())) { + handlePartialMediaPermissions(getPermissionsToRequest(), true) { + callback(it) + if (!mWasMediaManagementPromptShown) { + mWasMediaManagementPromptShown = true + handleMediaManagementPrompt { } + } } + } else { + callback(true) } } @@ -360,8 +364,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { findItem(R.id.temporarily_show_excluded).isVisible = !config.temporarilyShowExcluded findItem(R.id.stop_showing_excluded).isVisible = config.temporarilyShowExcluded - - findItem(R.id.access_more_media).isVisible = isUpsideDownCakePlus() } } @@ -399,7 +401,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded() R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded() - R.id.access_more_media -> handleMediaPermissions(force = true) { } R.id.create_new_folder -> createNewFolder() R.id.open_recycle_bin -> openRecycleBin() R.id.column_count -> changeColumnCount() diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 6d43aaa0c..ca2d66031 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -58,11 +58,6 @@ android:showAsAction="never" android:title="@string/create_new_folder" app:showAsAction="never" /> -