From d4fe872a3a3f5b03d8a5953acb4583481d23c5c2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 20 Jun 2018 21:49:54 +0200 Subject: [PATCH] make sure the Favorites folder is pinned by default --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 5 +++++ .../kotlin/com/simplemobiletools/gallery/helpers/Config.kt | 4 ++++ .../com/simplemobiletools/gallery/helpers/Constants.kt | 1 + 3 files changed, 10 insertions(+) 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 2399a6aa1..550e97aa4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -109,6 +109,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { if (!config.wasOTGHandled && hasPermission(PERMISSION_WRITE_STORAGE)) { checkOTGInclusion() } + + if (!config.wereFavoritesPinned) { + config.addPinnedFolders(hashSetOf(FAVORITES)) + config.wereFavoritesPinned = true + } } override fun onStart() { 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 73d6db933..59fcde108 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -322,4 +322,8 @@ class Config(context: Context) : BaseConfig(context) { var tempSkipDeleteConfirmation: Boolean get() = prefs.getBoolean(TEMP_SKIP_DELETE_CONFIRMATION, false) set(tempSkipDeleteConfirmation) = prefs.edit().putBoolean(TEMP_SKIP_DELETE_CONFIRMATION, tempSkipDeleteConfirmation).apply() + + var wereFavoritesPinned: Boolean + get() = prefs.getBoolean(WERE_FAVORITES_PINNED, false) + set(wereFavoritesPinned) = prefs.edit().putBoolean(WERE_FAVORITES_PINNED, wereFavoritesPinned).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 e0f3c7085..3fd37fcf0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -49,6 +49,7 @@ const val LAST_FILEPICKER_PATH = "last_filepicker_path" const val WAS_OTG_HANDLED = "was_otg_handled" const val TEMP_SKIP_DELETE_CONFIRMATION = "temp_skip_delete_confirmation" const val BOTTOM_ACTIONS = "bottom_actions" +const val WERE_FAVORITES_PINNED = "were_favorites_pinned" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval"