Allow using app only when all images are allowed

This commit is contained in:
Ensar Sarajčić 2023-08-25 16:08:23 +02:00
parent 584b3f52e3
commit 3f67830d60
2 changed files with 10 additions and 14 deletions

View file

@ -167,13 +167,17 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
} }
private fun handleMediaPermissions(force: Boolean = false, callback: (granted: Boolean) -> Unit) { private fun handleMediaPermissions(callback: (granted: Boolean) -> Unit) {
handlePartialMediaPermissions(getPermissionsToRequest(), force) { if (!hasAllPermissions(getPermissionsToRequest())) {
callback(it) handlePartialMediaPermissions(getPermissionsToRequest(), true) {
if (!mWasMediaManagementPromptShown) { callback(it)
mWasMediaManagementPromptShown = true if (!mWasMediaManagementPromptShown) {
handleMediaManagementPrompt { } 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.temporarily_show_excluded).isVisible = !config.temporarilyShowExcluded
findItem(R.id.stop_showing_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.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded() R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded()
R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded() R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded()
R.id.access_more_media -> handleMediaPermissions(force = true) { }
R.id.create_new_folder -> createNewFolder() R.id.create_new_folder -> createNewFolder()
R.id.open_recycle_bin -> openRecycleBin() R.id.open_recycle_bin -> openRecycleBin()
R.id.column_count -> changeColumnCount() R.id.column_count -> changeColumnCount()

View file

@ -58,11 +58,6 @@
android:showAsAction="never" android:showAsAction="never"
android:title="@string/create_new_folder" android:title="@string/create_new_folder"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/access_more_media"
android:showAsAction="never"
android:title="@string/allow_access_more_media"
app:showAsAction="never" />
<item <item
android:id="@+id/open_recycle_bin" android:id="@+id/open_recycle_bin"
android:showAsAction="never" android:showAsAction="never"