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