diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 63e7ebc46..8ae37d9fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index b9356cd0f..60404bff3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -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()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt index 3be5ee5db..1d77def19 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt @@ -114,21 +114,25 @@ open class GlobalSearchPresenter( private fun getSourcesToQuery(): List { val filter = extensionFilter val enabledSources = getEnabledSources() - if (filter.isNullOrEmpty()) { - return enabledSources + var filteredSources: List? = null + + if (!filter.isNullOrEmpty()) { + filteredSources = extensionManager.installedExtensions + .filter { it.pkgName == filter } + .flatMap { it.sources } + .filter { it in enabledSources } + .filterIsInstance() } - val filterSources = extensionManager.installedExtensions - .filter { it.pkgName == filter } - .flatMap { it.sources } - .filter { it in enabledSources } - .filterIsInstance() - - 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 } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt index 69df8fc02..a6f78c915 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBrowseController.kt @@ -25,5 +25,10 @@ class SettingsBrowseController : SettingsController() { true } } + switchPreference { + key = Keys.searchPinnedSourcesOnly + titleRes = R.string.pref_search_pinned_sources_only + defaultValue = false + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ca52cb56b..063a06176 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -212,7 +212,6 @@ Version: %1$s Language: %1$s No preferences to edit for this extension - Check for extension updates Fullscreen @@ -300,10 +299,14 @@ Download new chapters Categories to include in download - + Sync chapters after reading Services + + Check for extension updates + Only include pinned sources in global search + Backup Create backup