fix #2580, add an option to search all files by default
This commit is contained in:
parent
e9d7d6bf26
commit
d1c9f1d4c4
5 changed files with 41 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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<String>
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -199,6 +199,21 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_search_all_files_holder"
|
||||
style="@style/SettingsHolderCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/settings_search_all_files"
|
||||
style="@style/SettingsCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_all_files" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/settings_general_settings_divider"
|
||||
layout="@layout/divider" />
|
||||
|
|
Loading…
Reference in a new issue