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 05971e4ac..9fbe9fe03 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 @@ -278,10 +278,10 @@ class PreferencesHelper(val context: Context) { fun pinnedSources() = flowPrefs.getStringSet("pinned_catalogues", emptySet()) - fun downloadNew() = flowPrefs.getBoolean("download_new", false) + fun downloadNewChapter() = flowPrefs.getBoolean("download_new", false) - fun downloadNewCategories() = flowPrefs.getStringSet("download_new_categories", emptySet()) - fun downloadNewCategoriesExclude() = flowPrefs.getStringSet("download_new_categories_exclude", emptySet()) + fun downloadNewChapterCategories() = flowPrefs.getStringSet("download_new_categories", emptySet()) + fun downloadNewChapterCategoriesExclude() = flowPrefs.getStringSet("download_new_categories_exclude", emptySet()) fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 82c7cc839..74fce340b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -125,20 +125,20 @@ class SettingsDownloadController : SettingsController() { titleRes = R.string.pref_category_auto_download switchPreference { - bindTo(preferences.downloadNew()) + bindTo(preferences.downloadNewChapter()) titleRes = R.string.pref_download_new } preference { - bindTo(preferences.downloadNewCategories()) + bindTo(preferences.downloadNewChapterCategories()) titleRes = R.string.categories onClick { DownloadCategoriesDialog().showDialog(router) } - visibleIf(preferences.downloadNew()) { it } + visibleIf(preferences.downloadNewChapter()) { it } fun updateSummary() { - val selectedCategories = preferences.downloadNewCategories().get() + val selectedCategories = preferences.downloadNewChapterCategories().get() .mapNotNull { id -> categories.find { it.id == id.toInt() } } .sortedBy { it.order } val includedItemsText = if (selectedCategories.isEmpty()) { @@ -147,7 +147,7 @@ class SettingsDownloadController : SettingsController() { selectedCategories.joinToString { it.name } } - val excludedCategories = preferences.downloadNewCategoriesExclude().get() + val excludedCategories = preferences.downloadNewChapterCategoriesExclude().get() .mapNotNull { id -> categories.find { it.id == id.toInt() } } .sortedBy { it.order } val excludedItemsText = if (excludedCategories.isEmpty()) { @@ -163,10 +163,10 @@ class SettingsDownloadController : SettingsController() { } } - preferences.downloadNewCategories().asFlow() + preferences.downloadNewChapterCategories().asFlow() .onEach { updateSummary() } .launchIn(viewScope) - preferences.downloadNewCategoriesExclude().asFlow() + preferences.downloadNewChapterCategoriesExclude().asFlow() .onEach { updateSummary() } .launchIn(viewScope) } @@ -254,8 +254,8 @@ class SettingsDownloadController : SettingsController() { var selected = categories .map { when (it.id.toString()) { - in preferences.downloadNewCategories().get() -> QuadStateTextView.State.CHECKED.ordinal - in preferences.downloadNewCategoriesExclude().get() -> QuadStateTextView.State.INVERSED.ordinal + in preferences.downloadNewChapterCategories().get() -> QuadStateTextView.State.CHECKED.ordinal + in preferences.downloadNewChapterCategoriesExclude().get() -> QuadStateTextView.State.INVERSED.ordinal else -> QuadStateTextView.State.UNCHECKED.ordinal } } @@ -282,8 +282,8 @@ class SettingsDownloadController : SettingsController() { .map { categories[it].id.toString() } .toSet() - preferences.downloadNewCategories().set(included) - preferences.downloadNewCategoriesExclude().set(excluded) + preferences.downloadNewChapterCategories().set(included) + preferences.downloadNewChapterCategoriesExclude().set(excluded) } .setNegativeButton(android.R.string.cancel, null) .create() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt index f1a4fb623..adc3b2c7d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt @@ -56,14 +56,14 @@ fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper if (!favorite) return false // Boolean to determine if user wants to automatically download new chapters. - val downloadNew = prefs.downloadNew().get() - if (!downloadNew) return false + val downloadNewChapter = prefs.downloadNewChapter().get() + if (!downloadNewChapter) return false - val categoriesToDownload = prefs.downloadNewCategories().get().map(String::toInt) - val categoriesToExclude = prefs.downloadNewCategoriesExclude().get().map(String::toInt) + val includedCategories = prefs.downloadNewChapterCategories().get().map { it.toInt() } + val excludedCategories = prefs.downloadNewChapterCategoriesExclude().get().map { it.toInt() } - // Default: download from all categories - if (categoriesToDownload.isEmpty() && categoriesToExclude.isEmpty()) return true + // Default: Download from all categories + if (includedCategories.isEmpty() && excludedCategories.isEmpty()) return true // Get all categories, else default category (0) val categoriesForManga = @@ -72,8 +72,11 @@ fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper .takeUnless { it.isEmpty() } ?: listOf(0) // In excluded category - if (categoriesForManga.intersect(categoriesToExclude).isNotEmpty()) return false + if (categoriesForManga.any { it in excludedCategories }) return false + + // Included category not selected + if (includedCategories.isEmpty()) return true // In included category - return categoriesForManga.intersect(categoriesToDownload).isNotEmpty() + return categoriesForManga.any { it in includedCategories } }