Option to only include pinned sources in global search
This commit is contained in:
parent
8077e421e6
commit
fe65f4d6f8
@ -143,6 +143,8 @@ object PreferenceKeys {
|
||||
|
||||
const val alwaysShowChapterTransition = "always_show_chapter_transition"
|
||||
|
||||
const val searchPinnedSourcesOnly = "search_pinned_sources_only"
|
||||
|
||||
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"
|
||||
|
||||
fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId"
|
||||
|
@ -221,6 +221,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun lastExtCheck() = flowPrefs.getLong("last_ext_check", 0)
|
||||
|
||||
fun searchPinnedSourcesOnly() = prefs.getBoolean(Keys.searchPinnedSourcesOnly, false)
|
||||
|
||||
fun hiddenCatalogues() = flowPrefs.getStringSet("hidden_catalogues", emptySet())
|
||||
|
||||
fun pinnedCatalogues() = flowPrefs.getStringSet("pinned_catalogues", emptySet())
|
||||
|
@ -114,21 +114,25 @@ open class GlobalSearchPresenter(
|
||||
private fun getSourcesToQuery(): List<CatalogueSource> {
|
||||
val filter = extensionFilter
|
||||
val enabledSources = getEnabledSources()
|
||||
if (filter.isNullOrEmpty()) {
|
||||
return enabledSources
|
||||
var filteredSources: List<CatalogueSource>? = null
|
||||
|
||||
if (!filter.isNullOrEmpty()) {
|
||||
filteredSources = extensionManager.installedExtensions
|
||||
.filter { it.pkgName == filter }
|
||||
.flatMap { it.sources }
|
||||
.filter { it in enabledSources }
|
||||
.filterIsInstance<CatalogueSource>()
|
||||
}
|
||||
|
||||
val filterSources = extensionManager.installedExtensions
|
||||
.filter { it.pkgName == filter }
|
||||
.flatMap { it.sources }
|
||||
.filter { it in enabledSources }
|
||||
.filterIsInstance<CatalogueSource>()
|
||||
|
||||
if (filterSources.isEmpty()) {
|
||||
return enabledSources
|
||||
if (filteredSources != null && filteredSources.isNotEmpty()) {
|
||||
return filteredSources
|
||||
}
|
||||
|
||||
return filterSources
|
||||
val onlyPinnedSources = preferences.searchPinnedSourcesOnly()
|
||||
val pinnedCatalogues = preferences.pinnedCatalogues().get()
|
||||
|
||||
return enabledSources
|
||||
.filter { if (onlyPinnedSources) it.id.toString() in pinnedCatalogues else true }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,5 +25,10 @@ class SettingsBrowseController : SettingsController() {
|
||||
true
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.searchPinnedSourcesOnly
|
||||
titleRes = R.string.pref_search_pinned_sources_only
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,6 @@
|
||||
<string name="ext_version_info">Version: %1$s</string>
|
||||
<string name="ext_language_info">Language: %1$s</string>
|
||||
<string name="ext_empty_preferences">No preferences to edit for this extension</string>
|
||||
<string name="pref_enable_automatic_extension_updates">Check for extension updates</string>
|
||||
|
||||
<!-- Reader section -->
|
||||
<string name="pref_fullscreen">Fullscreen</string>
|
||||
@ -300,10 +299,14 @@
|
||||
<string name="pref_download_new">Download new chapters</string>
|
||||
<string name="pref_download_new_categories">Categories to include in download</string>
|
||||
|
||||
<!-- Sync section -->
|
||||
<!-- Tracking section -->
|
||||
<string name="pref_auto_update_manga_sync">Sync chapters after reading</string>
|
||||
<string name="services">Services</string>
|
||||
|
||||
<!-- Browse section -->
|
||||
<string name="pref_enable_automatic_extension_updates">Check for extension updates</string>
|
||||
<string name="pref_search_pinned_sources_only">Only include pinned sources in global search</string>
|
||||
|
||||
<!-- Backup section -->
|
||||
<string name="backup">Backup</string>
|
||||
<string name="pref_create_backup">Create backup</string>
|
||||
|
Loading…
Reference in New Issue
Block a user