From 2eafcbd22e21f8f4cfcde7acbbe42b1edfd1246e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 20 Nov 2022 21:37:05 +0100 Subject: [PATCH] always show the hidden item visibility toggles --- app/build.gradle | 2 +- .../gallery/pro/activities/MainActivity.kt | 11 +++++-- .../gallery/pro/activities/MediaActivity.kt | 15 +++++---- .../pro/activities/SettingsActivity.kt | 14 ++++---- .../gallery/pro/extensions/Activity.kt | 32 +++++++++++-------- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e75337767..8106ca3f8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,7 +78,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:ffead928f7' + implementation 'com.github.SimpleMobileTools:Simple-Commons:f5f3f94be6' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24' 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 6552115e7..b592b5c3d 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 @@ -35,6 +35,7 @@ import com.simplemobiletools.gallery.pro.databases.GalleryDatabase import com.simplemobiletools.gallery.pro.dialogs.ChangeSortingDialog import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog +import com.simplemobiletools.gallery.pro.dialogs.GrantAllFilesDialog import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener @@ -317,7 +318,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } directories_toolbar.menu.apply { - findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden + findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden findItem(R.id.temporarily_show_excluded).isVisible = !config.temporarilyShowExcluded @@ -586,8 +587,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (config.temporarilyShowHidden) { toggleTemporarilyShowHidden(false) } else { - handleHiddenFolderPasswordProtection { - toggleTemporarilyShowHidden(true) + if (isRPlus() && !isExternalStorageManager()) { + GrantAllFilesDialog(this) + } else { + handleHiddenFolderPasswordProtection { + toggleTemporarilyShowHidden(true) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index a7887ca24..fd8d6d069 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -31,10 +31,7 @@ import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.MediaAdapter import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask import com.simplemobiletools.gallery.pro.databases.GalleryDatabase -import com.simplemobiletools.gallery.pro.dialogs.ChangeGroupingDialog -import com.simplemobiletools.gallery.pro.dialogs.ChangeSortingDialog -import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog -import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog +import com.simplemobiletools.gallery.pro.dialogs.* import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener @@ -256,7 +253,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { findItem(R.id.about).isVisible = mShowAll findItem(R.id.create_new_folder).isVisible = !mShowAll && mPath != RECYCLE_BIN && mPath != FAVORITES - findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden + findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden findItem(R.id.set_as_default_folder).isVisible = !isDefaultFolder @@ -655,8 +652,12 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (config.temporarilyShowHidden) { toggleTemporarilyShowHidden(false) } else { - handleHiddenFolderPasswordProtection { - toggleTemporarilyShowHidden(true) + if (isRPlus() && !isExternalStorageManager()) { + GrantAllFilesDialog(this) + } else { + handleHiddenFolderPasswordProtection { + toggleTemporarilyShowHidden(true) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 7fa1d10da..3cd0aabac 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -11,10 +11,7 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.pro.R -import com.simplemobiletools.gallery.pro.dialogs.ChangeFileThumbnailStyleDialog -import com.simplemobiletools.gallery.pro.dialogs.ChangeFolderThumbnailStyleDialog -import com.simplemobiletools.gallery.pro.dialogs.ManageBottomActionsDialog -import com.simplemobiletools.gallery.pro.dialogs.ManageExtendedDetailsDialog +import com.simplemobiletools.gallery.pro.dialogs.* import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.AlbumCover @@ -223,13 +220,16 @@ class SettingsActivity : SimpleActivity() { private fun setupShowHiddenItems() { if (isRPlus() && !isExternalStorageManager()) { - settings_show_hidden_items_holder.beGone() - settings_manage_excluded_folders_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme) + settings_show_hidden_items.text = "${getString(R.string.show_hidden_items)} (${getString(R.string.no_permission)})" + } else { + settings_show_hidden_items.setText(R.string.show_hidden_items) } settings_show_hidden_items.isChecked = config.showHiddenMedia settings_show_hidden_items_holder.setOnClickListener { - if (config.showHiddenMedia) { + if (isRPlus() && !isExternalStorageManager()) { + GrantAllFilesDialog(this) + } else if (config.showHiddenMedia) { toggleHiddenItems() } else { handleHiddenFolderPasswordProtection { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 56cf39226..ec55cc5f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -143,20 +143,7 @@ fun BaseSimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) { AllFilesPermissionDialog(this, messagePrompt, callback = { success -> if (success) { - try { - val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) - intent.addCategory("android.intent.category.DEFAULT") - intent.data = Uri.parse("package:$packageName") - startActivity(intent) - } catch (e: Exception) { - val intent = Intent() - intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION - try { - startActivity(intent) - } catch (e: Exception) { - showErrorToast(e) - } - } + launchGrantAllFilesIntent() } }, neutralPressed = { if (isSPlus()) { @@ -171,6 +158,23 @@ fun BaseSimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) { } } +fun BaseSimpleActivity.launchGrantAllFilesIntent() { + try { + val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) + intent.addCategory("android.intent.category.DEFAULT") + intent.data = Uri.parse("package:$packageName") + startActivity(intent) + } catch (e: Exception) { + val intent = Intent() + intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION + try { + startActivity(intent) + } catch (e: Exception) { + showErrorToast(e) + } + } +} + fun AppCompatActivity.showSystemUI(toggleActionBarVisibility: Boolean) { window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or