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 c1dfb7454..efa20b264 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 @@ -92,6 +92,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (savedInstanceState == null) { config.temporarilyShowHidden = false + config.temporarilyShowExcluded = false config.tempSkipDeleteConfirmation = false removeTempFolder() checkRecycleBinItems() @@ -247,9 +248,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { override fun onStop() { super.onStop() - if (config.temporarilyShowHidden || config.tempSkipDeleteConfirmation) { + if (config.temporarilyShowHidden || config.tempSkipDeleteConfirmation || config.temporarilyShowExcluded) { mTempShowHiddenHandler.postDelayed({ config.temporarilyShowHidden = false + config.temporarilyShowExcluded = false config.tempSkipDeleteConfirmation = false }, SHOW_TEMP_HIDDEN_DURATION) } else { @@ -261,6 +263,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { super.onDestroy() if (!isChangingConfigurations) { config.temporarilyShowHidden = false + config.temporarilyShowExcluded = false config.tempSkipDeleteConfirmation = false mTempShowHiddenHandler.removeCallbacksAndMessages(null) removeTempFolder() @@ -306,6 +309,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { menu.findItem(R.id.temporarily_show_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && !config.shouldShowHidden menu.findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden + menu.findItem(R.id.temporarily_show_excluded).isVisible = !menu.findItem(R.id.temporarily_show_hidden).isVisible && !config.temporarilyShowExcluded + menu.findItem(R.id.stop_showing_excluded).isVisible = !menu.findItem(R.id.temporarily_show_hidden).isVisible && config.temporarilyShowExcluded + updateMenuItemColors(menu) return true } @@ -319,6 +325,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { R.id.change_view_type -> changeViewType() R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() + R.id.temporarily_show_excluded -> toggleTemporarilyShowExcluded(true) + R.id.stop_showing_excluded -> toggleTemporarilyShowExcluded(false) R.id.create_new_folder -> createNewFolder() R.id.show_the_recycle_bin -> toggleRecycleBin(true) R.id.hide_the_recycle_bin -> toggleRecycleBin(false) @@ -569,6 +577,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { invalidateOptionsMenu() } + private fun toggleTemporarilyShowExcluded(show: Boolean) { + mLoadedInitialPhotos = false + config.temporarilyShowExcluded = show + directories_grid.adapter = null + getDirectories() + invalidateOptionsMenu() + } + override fun deleteFolders(folders: ArrayList) { val fileDirItems = folders.asSequence().filter { it.isDirectory }.map { FileDirItem(it.absolutePath, it.name, true) }.toMutableList() as ArrayList diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index bc9be9e52..37cf10e26 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -656,7 +656,12 @@ fun Context.getCachedDirectories( } val shouldShowHidden = config.shouldShowHidden || forceShowHidden - val excludedPaths = config.excludedFolders + val excludedPaths = if (config.temporarilyShowExcluded) { + HashSet() + } else { + config.excludedFolders + } + val includedPaths = config.includedFolders val folderNoMediaStatuses = HashMap() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 75d7045e4..e82ed3838 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -74,6 +74,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(TEMPORARILY_SHOW_HIDDEN, false) set(temporarilyShowHidden) = prefs.edit().putBoolean(TEMPORARILY_SHOW_HIDDEN, temporarilyShowHidden).apply() + var temporarilyShowExcluded: Boolean + get() = prefs.getBoolean(TEMPORARILY_SHOW_EXCLUDED, false) + set(temporarilyShowExcluded) = prefs.edit().putBoolean(TEMPORARILY_SHOW_EXCLUDED, temporarilyShowExcluded).apply() + var isThirdPartyIntent: Boolean get() = prefs.getBoolean(IS_THIRD_PARTY_INTENT, false) set(isThirdPartyIntent) = prefs.edit().putBoolean(IS_THIRD_PARTY_INTENT, isThirdPartyIntent).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 59c5eb70a..276fe07dc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -9,6 +9,7 @@ const val GROUP_FOLDER_PREFIX = "group_folder_" const val VIEW_TYPE_PREFIX = "view_type_folder_" const val SHOW_HIDDEN_MEDIA = "show_hidden_media" const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden" +const val TEMPORARILY_SHOW_EXCLUDED = "temporarily_show_excluded" const val IS_THIRD_PARTY_INTENT = "is_third_party_intent" const val AUTOPLAY_VIDEOS = "autoplay_videos" const val REMEMBER_LAST_VIDEO_POSITION = "remember_last_video_position" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index f5eafa428..9c248ae6b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -101,7 +101,12 @@ class MediaFetcher(val context: Context) { val config = context.config val shouldShowHidden = config.shouldShowHidden - val excludedPaths = config.excludedFolders + val excludedPaths = if (config.temporarilyShowExcluded) { + HashSet() + } else { + config.excludedFolders + } + val includedPaths = config.includedFolders val folderNoMediaStatuses = HashMap() diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 6557b1799..25750013f 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -39,6 +39,16 @@ android:showAsAction="never" android:title="@string/stop_showing_hidden" app:showAsAction="never" /> + +