filter series by in progress and read (#7446)

This commit is contained in:
Gauthier 2021-06-04 19:38:57 +08:00 committed by GitHub
parent de7dbfa7e9
commit 380b7594f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 8 deletions

View File

@ -1,3 +1,11 @@
## 1.2.27
Minimum Komga version required: `0.97.0`
### Fix
* filter series by read or in progress
## 1.2.26 ## 1.2.26
Minimum Komga version required: `0.87.4` Minimum Komga version required: `0.87.4`

View File

@ -5,7 +5,7 @@ ext {
extName = 'Komga' extName = 'Komga'
pkgNameSuffix = 'all.komga' pkgNameSuffix = 'all.komga'
extClass = '.KomgaFactory' extClass = '.KomgaFactory'
extVersionCode = 26 extVersionCode = 27
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -69,12 +69,22 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
filters.forEach { filter -> filters.forEach { filter ->
when (filter) { when (filter) {
is UnreadOnly -> { is UnreadFilter -> {
if (filter.state) { if (filter.state) {
url.addQueryParameter("read_status", "UNREAD") url.addQueryParameter("read_status", "UNREAD")
url.addQueryParameter("read_status", "IN_PROGRESS") url.addQueryParameter("read_status", "IN_PROGRESS")
} }
} }
is InProgressFilter -> {
if (filter.state) {
url.addQueryParameter("read_status", "IN_PROGRESS")
}
}
is ReadFilter -> {
if (filter.state) {
url.addQueryParameter("read_status", "READ")
}
}
is LibraryGroup -> { is LibraryGroup -> {
val libraryToInclude = mutableListOf<String>() val libraryToInclude = mutableListOf<String>()
filter.state.forEach { content -> filter.state.forEach { content ->
@ -286,7 +296,9 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
private class SeriesSort : Filter.Sort("Sort", arrayOf("Alphabetically", "Date added", "Date updated"), Selection(0, true)) private class SeriesSort : Filter.Sort("Sort", arrayOf("Alphabetically", "Date added", "Date updated"), Selection(0, true))
private class StatusFilter(name: String) : Filter.CheckBox(name, false) private class StatusFilter(name: String) : Filter.CheckBox(name, false)
private class StatusGroup(filters: List<StatusFilter>) : Filter.Group<StatusFilter>("Status", filters) private class StatusGroup(filters: List<StatusFilter>) : Filter.Group<StatusFilter>("Status", filters)
private class UnreadOnly : Filter.CheckBox("Unread only", false) private class UnreadFilter : Filter.CheckBox("Unread", false)
private class InProgressFilter : Filter.CheckBox("In Progress", false)
private class ReadFilter : Filter.CheckBox("Read", false)
private class GenreFilter(genre: String) : Filter.CheckBox(genre, false) private class GenreFilter(genre: String) : Filter.CheckBox(genre, false)
private class GenreGroup(genres: List<GenreFilter>) : Filter.Group<GenreFilter>("Genres", genres) private class GenreGroup(genres: List<GenreFilter>) : Filter.Group<GenreFilter>("Genres", genres)
private class TagFilter(tag: String) : Filter.CheckBox(tag, false) private class TagFilter(tag: String) : Filter.CheckBox(tag, false)
@ -306,17 +318,19 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
override fun getFilterList(): FilterList { override fun getFilterList(): FilterList {
val filters = try { val filters = try {
mutableListOf<Filter<*>>( mutableListOf<Filter<*>>(
UnreadOnly(), UnreadFilter(),
InProgressFilter(),
ReadFilter(),
TypeSelect(), TypeSelect(),
CollectionSelect(listOf(CollectionFilterEntry("None")) + collections.map { CollectionFilterEntry(it.name, it.id) }), CollectionSelect(listOf(CollectionFilterEntry("None")) + collections.map { CollectionFilterEntry(it.name, it.id) }),
LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase() }), LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase(Locale.ROOT) }),
StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }), StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }),
GenreGroup(genres.map { GenreFilter(it) }), GenreGroup(genres.map { GenreFilter(it) }),
TagGroup(tags.map { TagFilter(it) }), TagGroup(tags.map { TagFilter(it) }),
PublisherGroup(publishers.map { PublisherFilter(it) }) PublisherGroup(publishers.map { PublisherFilter(it) })
).also { ).also { list ->
it.addAll(authors.map { (role, authors) -> AuthorGroup(role, authors.map { AuthorFilter(it) }) }) list.addAll(authors.map { (role, authors) -> AuthorGroup(role, authors.map { AuthorFilter(it) }) })
it.add(SeriesSort()) list.add(SeriesSort())
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.e(LOG_TAG, "error while creating filter list", e) Log.e(LOG_TAG, "error while creating filter list", e)