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 b1acc459c..534625eb2 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 @@ -332,6 +332,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { main_menu.setupMenu() main_menu.updateHintText(getString(R.string.search_folders)) + if (isPiePlus()) { + main_menu.onSearchOpenListener = { + if (config.searchAllFilesByDefault) { + launchSearchActivity() + } + } + } + main_menu.onSearchTextChangedListener = { text -> setupAdapter(mDirsIgnoringSearch, text) directories_refresh_layout.isEnabled = text.isEmpty() && config.enablePullToRefresh 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 b4c34cc9e..ff5b877ce 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 @@ -49,6 +49,7 @@ class SettingsActivity : SimpleActivity() { setupManageIncludedFolders() setupManageExcludedFolders() setupManageHiddenFolders() + setupSearchAllFiles() setupShowHiddenItems() setupAutoplayVideos() setupRememberLastVideo() @@ -225,6 +226,16 @@ class SettingsActivity : SimpleActivity() { config.showHiddenMedia = settings_show_hidden_items.isChecked } + // show this on Android 9+ only due to a glitch on lower versions where search is automatically open on startup + private fun setupSearchAllFiles() { + settings_search_all_files_holder.beVisibleIf(isPiePlus()) + settings_search_all_files.isChecked = config.searchAllFilesByDefault + settings_search_all_files_holder.setOnClickListener { + settings_search_all_files.toggle() + config.searchAllFilesByDefault = settings_search_all_files.isChecked + } + } + private fun setupAutoplayVideos() { settings_autoplay_videos.isChecked = config.autoplayVideos settings_autoplay_videos_holder.setOnClickListener { @@ -782,6 +793,7 @@ class SettingsActivity : SimpleActivity() { put(LIMIT_FOLDER_TITLE, config.limitFolderTitle) put(THUMBNAIL_SPACING, config.thumbnailSpacing) put(FILE_ROUNDED_CORNERS, config.fileRoundedCorners) + put(SEARCH_ALL_FILES_BY_DEFAULT, config.searchAllFilesByDefault) } exportSettings(configItems) @@ -923,6 +935,7 @@ class SettingsActivity : SimpleActivity() { LIMIT_FOLDER_TITLE -> config.limitFolderTitle = value.toBoolean() THUMBNAIL_SPACING -> config.thumbnailSpacing = value.toInt() FILE_ROUNDED_CORNERS -> config.fileRoundedCorners = value.toBoolean() + SEARCH_ALL_FILES_BY_DEFAULT -> config.searchAllFilesByDefault = value.toBoolean() ALBUM_COVERS -> { val existingCovers = config.parseAlbumCovers() val existingCoverPaths = existingCovers.map { it.path }.toMutableList() as ArrayList 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 9dd3c3ef5..96501c68d 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 @@ -550,4 +550,8 @@ class Config(context: Context) : BaseConfig(context) { var avoidShowingAllFilesPrompt: Boolean get() = prefs.getBoolean(AVOID_SHOWING_ALL_FILES_PROMPT, false) set(avoidShowingAllFilesPrompt) = prefs.edit().putBoolean(AVOID_SHOWING_ALL_FILES_PROMPT, avoidShowingAllFilesPrompt).apply() + + var searchAllFilesByDefault: Boolean + get() = prefs.getBoolean(SEARCH_ALL_FILES_BY_DEFAULT, false) + set(searchAllFilesByDefault) = prefs.edit().putBoolean(SEARCH_ALL_FILES_BY_DEFAULT, searchAllFilesByDefault).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 7ab90af63..9885df89c 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 @@ -97,6 +97,7 @@ const val THUMBNAIL_SPACING = "thumbnail_spacing" const val FILE_ROUNDED_CORNERS = "file_rounded_corners" const val CUSTOM_FOLDERS_ORDER = "custom_folders_order" const val AVOID_SHOWING_ALL_FILES_PROMPT = "avoid_showing_all_files_prompt" +const val SEARCH_ALL_FILES_BY_DEFAULT = "search_all_files_by_default" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 176afb50c..3047844cf 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -199,6 +199,21 @@ + + + + + +