diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt index e6a47be16..a37f6d452 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt @@ -56,7 +56,7 @@ class ExcludedFoldersActivity : SimpleActivity() { } private fun addExcludedFolder() { - FilePickerDialog(this, pickFile = false, showHidden = config.showHiddenFolders) { + FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) { config.addExcludedFolder(it) updateExcludedFolders() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt index 9f7158c88..f69f4f987 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt @@ -57,7 +57,7 @@ class IncludedFoldersActivity : SimpleActivity() { } private fun addIncludedFolder() { - FilePickerDialog(this, pickFile = false, showHidden = config.showHiddenFolders) { + FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) { config.addIncludedFolder(it) updateIncludedFolders() scanPath(it) {} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 713a23aed..f8eff8659 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -113,6 +113,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mStoredAnimateGifs = config.animateGifs } + override fun onStop() { + super.onStop() + config.temporarilyShowHidden = false + } + override fun onDestroy() { super.onDestroy() config.isFirstRun = false @@ -158,7 +163,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) { - config.temporarilyShowHidden = false gotDirectories(it) } mCurrAsyncTask!!.execute() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 879c26d3a..bc6c601e9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -177,7 +177,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun hideFolder() { addNoMedia(mPath) { runOnUiThread { - if (!config.showHiddenFolders) + if (!config.shouldShowHidden) finish() else invalidateOptionsMenu() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 302998bdf..57587da1b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -149,11 +149,11 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList() selections.forEach { paths.add(dirs[it].path) } - PropertiesDialog(activity, paths, config.showHiddenFolders) + PropertiesDialog(activity, paths, config.shouldShowHidden) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 02199bfcf..6bd1638bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -108,11 +108,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, private fun showProperties() { val selections = multiSelector.selectedPositions if (selections.size <= 1) { - PropertiesDialog(activity, media[selections[0]].path, config.showHiddenFolders) + PropertiesDialog(activity, media[selections[0]].path, config.shouldShowHidden) } else { val paths = ArrayList() selections.forEach { paths.add(media[it].path) } - PropertiesDialog(activity, paths, config.showHiddenFolders) + PropertiesDialog(activity, paths, config.shouldShowHidden) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 6ca074485..818a47cb0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -71,7 +71,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va private fun groupDirectories(media: ArrayList): Map { val hidden = context.resources.getString(R.string.hidden) val directories = LinkedHashMap() - val showHidden = config.showHiddenFolders || config.temporarilyShowHidden + val showHidden = config.shouldShowHidden for ((name, path, isVideo, dateModified, dateTaken, size) in media) { if (shouldStop) cancel(true) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt index 92d40365b..94f2e5162 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt @@ -43,7 +43,7 @@ class PickAlbumDialog(val activity: SimpleActivity, val sourcePath: String, val } fun showOtherFolder() { - val showHidden = activity.config.showHiddenFolders + val showHidden = activity.config.shouldShowHidden FilePickerDialog(activity, sourcePath, false, showHidden, true) { callback.invoke(it) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index 2af019bfd..c25fff7d1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -70,7 +70,7 @@ fun Context.getParents(): ArrayList { val noMediaFolders = getNoMediaFolders() val parents = ArrayList() - if (config.showHiddenFolders || config.temporarilyShowHidden) { + if (config.shouldShowHidden) { parentsSet.addAll(noMediaFolders) } @@ -79,7 +79,7 @@ fun Context.getParents(): ArrayList { parentsSet.filterTo(parents, { val file = File(it) if (file.isDirectory && file.canonicalFile == file.absoluteFile) { // filter out symbolic links too - if (!config.showHiddenFolders && !config.temporarilyShowHidden) { + if (!config.shouldShowHidden) { isFolderVisible(it, noMediaFolders) } else true diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index 93891608e..bf2532563 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -40,6 +40,8 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(HIDE_FOLDER_TOOLTIP_SHOWN, false) set(wasShown) = prefs.edit().putBoolean(HIDE_FOLDER_TOOLTIP_SHOWN, wasShown).apply() + var shouldShowHidden = showHiddenFolders || temporarilyShowHidden + var showHiddenFolders: Boolean get() = prefs.getBoolean(SHOW_HIDDEN_FOLDERS, false) set(showHiddenFolders) = prefs.edit().putBoolean(SHOW_HIDDEN_FOLDERS, showHiddenFolders).apply()