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 downloadNew = "download_new"
|
||||||
|
|
||||||
const val downloadNewCategories = "download_new_categories"
|
const val downloadNewCategories = "download_new_categories"
|
||||||
|
const val downloadNewCategoriesExclude = "download_new_categories_exclude"
|
||||||
|
|
||||||
const val libraryLayout = "pref_display_library_layout"
|
const val libraryLayout = "pref_display_library_layout"
|
||||||
|
|
||||||
|
@ -298,6 +298,7 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun downloadNew() = flowPrefs.getBoolean(Keys.downloadNew, false)
|
fun downloadNew() = flowPrefs.getBoolean(Keys.downloadNew, false)
|
||||||
|
|
||||||
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet())
|
fun downloadNewCategories() = flowPrefs.getStringSet(Keys.downloadNewCategories, emptySet())
|
||||||
|
fun downloadNewCategoriesExclude() = flowPrefs.getStringSet(Keys.downloadNewCategoriesExclude, emptySet())
|
||||||
|
|
||||||
fun lang() = flowPrefs.getString(Keys.lang, "")
|
fun lang() = flowPrefs.getString(Keys.lang, "")
|
||||||
|
|
||||||
|
@ -89,9 +89,10 @@ class SettingsDownloadController : SettingsController() {
|
|||||||
titleRes = R.string.download_new_chapters
|
titleRes = R.string.download_new_chapters
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
multiSelectListPreferenceMat(activity) {
|
triStateListPreference(activity) {
|
||||||
key = Keys.downloadNewCategories
|
key = Keys.downloadNewCategories
|
||||||
titleRes = R.string.categories_to_include_in_download
|
excludeKey = Keys.downloadNewCategoriesExclude
|
||||||
|
titleRes = R.string.categories
|
||||||
entries = categories.map { it.name }
|
entries = categories.map { it.name }
|
||||||
entryValues = categories.map { it.id.toString() }
|
entryValues = categories.map { it.id.toString() }
|
||||||
allSelectionRes = R.string.all
|
allSelectionRes = R.string.all
|
||||||
|
@ -43,6 +43,9 @@ fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper
|
|||||||
.mapNotNull { it.id }
|
.mapNotNull { it.id }
|
||||||
.takeUnless { it.isEmpty() } ?: listOf(0)
|
.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()
|
return categoriesForManga.intersect(categoriesToDownload).isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user