[Komga] unread only filter, prefix book titles (#3418)
* unread only filter, prefix book titles closes gotson/komga#169, gotson/komga#180 * fix linting issues
This commit is contained in:
parent
1b6dbeb873
commit
af8fd27c25
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Komga'
|
||||
pkgNameSuffix = 'all.komga'
|
||||
extClass = '.KomgaFactory'
|
||||
extVersionCode = 9
|
||||
extVersionCode = 10
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl
|
||||
|
@ -36,6 +33,10 @@ import rx.android.schedulers.AndroidSchedulers
|
|||
import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.DecimalFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
||||
override fun popularMangaRequest(page: Int): Request =
|
||||
|
@ -55,6 +56,11 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
|
||||
filters.forEach { filter ->
|
||||
when (filter) {
|
||||
is UnreadOnly -> {
|
||||
if (filter.state) {
|
||||
url.addQueryParameter("read_status", "UNREAD")
|
||||
}
|
||||
}
|
||||
is LibraryGroup -> {
|
||||
val libraryToInclude = mutableListOf<Long>()
|
||||
filter.state.forEach { content ->
|
||||
|
@ -115,7 +121,7 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
return page.content.map { book ->
|
||||
SChapter.create().apply {
|
||||
chapter_number = book.metadata.numberSort
|
||||
name = "${book.metadata.title} (${book.size})"
|
||||
name = "${decimalFormat.format(book.metadata.numberSort)} - ${book.metadata.title} (${book.size})"
|
||||
url = "$baseUrl/api/v1/books/${book.id}"
|
||||
date_upload = parseDate(book.lastModified)
|
||||
}
|
||||
|
@ -183,9 +189,11 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
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 StatusGroup(filters: List<StatusFilter>) : Filter.Group<StatusFilter>("Status", filters)
|
||||
private class UnreadOnly : Filter.CheckBox("Unread only", false)
|
||||
|
||||
override fun getFilterList(): FilterList =
|
||||
FilterList(
|
||||
UnreadOnly(),
|
||||
LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name }),
|
||||
StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }),
|
||||
SeriesSort()
|
||||
|
@ -197,6 +205,8 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
|
|||
override val lang = "en"
|
||||
override val supportsLatest = true
|
||||
|
||||
private val decimalFormat: DecimalFormat by lazy { DecimalFormat("0.#") }
|
||||
|
||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||
private val username by lazy { getPrefUsername() }
|
||||
private val password by lazy { getPrefPassword() }
|
||||
|
|
Loading…
Reference in New Issue