mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 03:39:19 +01:00
Allow excluding categories from auto-download
Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
parent
d5a387b056
commit
a3a4edbde0
@ -154,6 +154,7 @@ object PreferenceKeys {
|
||||
const val downloadNew = "download_new"
|
||||
|
||||
const val downloadNewCategories = "download_new_categories"
|
||||
const val downloadNewCategoriesExclude = "download_new_categories_exclude"
|
||||
|
||||
const val libraryLayout = "pref_display_library_layout"
|
||||
|
||||
|
@ -298,6 +298,7 @@ class PreferencesHelper(val context: Context) {
|
||||
fun downloadNew() = flowPrefs.getBoolean(Keys.downloadNew, false)
|
||||
|
||||
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet())
|
||||
fun downloadNewCategoriesExclude() = flowPrefs.getStringSet(Keys.downloadNewCategoriesExclude, emptySet())
|
||||
|
||||
fun lang() = flowPrefs.getString(Keys.lang, "")
|
||||
|
||||
|
@ -89,9 +89,10 @@ class SettingsDownloadController : SettingsController() {
|
||||
titleRes = R.string.download_new_chapters
|
||||
defaultValue = false
|
||||
}
|
||||
multiSelectListPreferenceMat(activity) {
|
||||
triStateListPreference(activity) {
|
||||
key = Keys.downloadNewCategories
|
||||
titleRes = R.string.categories_to_include_in_download
|
||||
excludeKey = Keys.downloadNewCategoriesExclude
|
||||
titleRes = R.string.categories
|
||||
entries = categories.map { it.name }
|
||||
entryValues = categories.map { it.id.toString() }
|
||||
allSelectionRes = R.string.all
|
||||
|
@ -43,6 +43,9 @@ fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper
|
||||
.mapNotNull { it.id }
|
||||
.takeUnless { it.isEmpty() } ?: listOf(0)
|
||||
|
||||
val categoriesToExclude = prefs.downloadNewCategoriesExclude().get().map(String::toInt)
|
||||
if (categoriesForManga.intersect(categoriesToExclude).isNotEmpty()) return false
|
||||
|
||||
return categoriesForManga.intersect(categoriesToDownload).isNotEmpty()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user