Allow exclusion on Delete After Read per category (#5857)

* Added the exclude category from delete after being read

* Stopped it from adding a wildcard to the import

* Placed the remove after read to the download manager
This commit is contained in:
tobinstultiens
2021-09-12 00:09:24 +02:00
committed by GitHub
parent 7b3c18bb97
commit a051079c6a
6 changed files with 50 additions and 8 deletions
@@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.entriesRes
import eu.kanade.tachiyomi.util.preference.intListPreference
import eu.kanade.tachiyomi.util.preference.multiSelectListPreference
import eu.kanade.tachiyomi.util.preference.onClick
import eu.kanade.tachiyomi.util.preference.preference
import eu.kanade.tachiyomi.util.preference.preferenceCategory
@@ -44,6 +45,9 @@ class SettingsDownloadController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
titleRes = R.string.pref_category_downloads
val dbCategories = db.getCategories().executeAsBlocking()
val categories = listOf(Category.createDefault(context)) + dbCategories
preference {
key = Keys.downloadsDirectory
titleRes = R.string.pref_download_directory
@@ -93,10 +97,26 @@ class SettingsDownloadController : SettingsController() {
titleRes = R.string.pref_remove_bookmarked_chapters
defaultValue = false
}
}
multiSelectListPreference {
key = Keys.removeExcludeCategories
titleRes = R.string.pref_remove_exclude_categories
entries = categories.map { it.name }.toTypedArray()
entryValues = categories.map { it.id.toString() }.toTypedArray()
val dbCategories = db.getCategories().executeAsBlocking()
val categories = listOf(Category.createDefault(context)) + dbCategories
preferences.removeExcludeCategories().asFlow()
.onEach { mutable ->
val selected = mutable
.mapNotNull { id -> categories.find { it.id == id.toInt() } }
.sortedBy { it.order }
summary = if (selected.isEmpty()) {
resources?.getString(R.string.none)
} else {
selected.joinToString { it.name }
}
}.launchIn(viewScope)
}
}
preferenceCategory {
titleRes = R.string.pref_category_auto_download