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 b0b5feecc..fa1c11de6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -573,7 +573,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun gotDirectories(newDirs: ArrayList, isFromCache: Boolean) { if (!isFromCache) { - setupLatestMediaId() + Thread { + checkFolderContentChange(newDirs) + }.start() } val dirs = getSortedDirectories(newDirs) @@ -600,6 +602,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } + private fun checkFolderContentChange(newDirs: ArrayList) { + newDirs.forEach { + val storedShortDirValue = config.loadFolderMediaShort(it.path) + if (storedShortDirValue != it.toString()) { + config.saveFolderMediaShort(it.path, it.toString()) + if (storedShortDirValue.isNotEmpty()) { + updateStoredFolderItems(it.path) + } + } + } + } + private fun storeDirectories() { if (!config.temporarilyShowHidden && config.tempFolderPath.isEmpty()) { val subList = mDirs.subList(0, Math.min(SAVE_DIRS_CNT, mDirs.size)) 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 8a8e8b646..27aa99116 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -124,6 +124,12 @@ class Config(context: Context) : BaseConfig(context) { fun loadFolderMedia(path: String) = prefs.getString(SAVE_FOLDER_PREFIX + path, "") + fun saveFolderMediaShort(path: String, value: String) { + prefs.edit().putString(SAVE_FOLDER_SHORT_PREFIX + path, value).apply() + } + + fun loadFolderMediaShort(path: String) = prefs.getString(SAVE_FOLDER_SHORT_PREFIX + path, "") + var autoplayVideos: Boolean get() = prefs.getBoolean(AUTOPLAY_VIDEOS, false) set(autoplay) = prefs.edit().putBoolean(AUTOPLAY_VIDEOS, autoplay).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 535d6f4bf..cf49ee2f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -26,6 +26,7 @@ const val MEDIA_HORIZONTAL_COLUMN_CNT = "media_horizontal_column_cnt" const val MEDIA_LANDSCAPE_HORIZONTAL_COLUMN_CNT = "media_landscape_horizontal_column_cnt" const val SHOW_ALL = "show_all" // display images and videos from all folders together const val SAVE_FOLDER_PREFIX = "folder2_" +const val SAVE_FOLDER_SHORT_PREFIX = "folder_short_" const val HIDE_FOLDER_TOOLTIP_SHOWN = "hide_folder_tooltip_shown" const val EXCLUDED_FOLDERS = "excluded_folders" const val INCLUDED_FOLDERS = "included_folders"