Allow excluding categories from auto-download

Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
Jays2Kings 2021-07-03 19:53:28 -04:00
parent d5a387b056
commit a3a4edbde0
4 changed files with 8 additions and 2 deletions

View File

@ -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"

View File

@ -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, "")

View File

@ -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

View File

@ -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()
}