diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index 8306b849f6..912873c924 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -31,6 +31,8 @@ abstract class TrackService(val id: Int) { abstract fun getStatus(status: Int): String + abstract fun getGlobalStatus(status: Int): String + abstract fun getScoreList(): List open fun indexToScore(index: Int): Float { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index 717e315d62..843fd3a7e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -52,6 +52,18 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) { } } + override fun getGlobalStatus(status: Int): String = with(context) { + when (status) { + READING -> getString(R.string.reading) + PLANNING -> getString(R.string.plan_to_read) + COMPLETED -> getString(R.string.completed) + PAUSED -> getString(R.string.on_hold) + DROPPED -> getString(R.string.dropped) + REPEATING -> getString(R.string.rereading) + else -> "" + } + } + override fun getScoreList(): List { return when (scorePreference.getOrDefault()) { // 10 point diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt index 3bc3231ec5..bd68882ee0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt @@ -89,6 +89,17 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) { } } + override fun getGlobalStatus(status: Int): String = with(context) { + when (status) { + READING -> getString(R.string.reading) + PLANNING -> getString(R.string.plan_to_read) + COMPLETED -> getString(R.string.completed) + ON_HOLD -> getString(R.string.on_hold) + DROPPED -> getString(R.string.dropped) + else -> "" + } + } + override suspend fun login(username: String, password: String): Boolean = login(password) suspend fun login(code: String): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index c73999fe96..542e0c2538 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -57,6 +57,17 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) { } } + override fun getGlobalStatus(status: Int): String = with(context) { + when (status) { + READING -> getString(R.string.reading) + PLAN_TO_READ -> getString(R.string.plan_to_read) + COMPLETED -> getString(R.string.completed) + ON_HOLD -> getString(R.string.on_hold) + DROPPED -> getString(R.string.dropped) + else -> "" + } + } + override fun getScoreList(): List { val df = DecimalFormat("0.#") return listOf("0") + IntRange(2, 20).map { df.format(it / 2f) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt index 0fe9b2484a..43066e7830 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt @@ -32,6 +32,17 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { } } + override fun getGlobalStatus(status: Int): String = with(context) { + when (status) { + READING -> getString(R.string.reading) + PLAN_TO_READ -> getString(R.string.plan_to_read) + COMPLETED -> getString(R.string.completed) + ON_HOLD -> getString(R.string.on_hold) + DROPPED -> getString(R.string.dropped) + else -> "" + } + } + override fun getStatusList(): List { return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt index 029f8c8699..2b1321a8e1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt @@ -41,6 +41,18 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) { } } + override fun getGlobalStatus(status: Int): String = with(context) { + when (status) { + READING -> getString(R.string.reading) + PLANNING -> getString(R.string.plan_to_read) + COMPLETED -> getString(R.string.completed) + ON_HOLD -> getString(R.string.on_hold) + DROPPED -> getString(R.string.dropped) + REPEATING -> getString(R.string.rereading) + else -> "" + } + } + override fun getScoreList(): List { return IntRange(0, 10).map(Int::toString) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index fa6f998450..400054092f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -550,9 +550,13 @@ class LibraryPresenter( val track = tracks.find { track -> loggedServices.any { it.id == track?.sync_id } } - if (track != null) { - loggedServices.find { it.id == track.sync_id }?.getStatus(track.status) - ?: context.getString(R.string.unknown) + val service = loggedServices.find { it.id == track?.sync_id } + if (track != null && service != null) { + if (loggedServices.size > 1) { + service.getGlobalStatus(track.status) + } else { + service.getStatus(track.status) + } } else { context.getString(R.string.not_tracked) } @@ -580,7 +584,12 @@ class LibraryPresenter( sourceId = split.last().toLongOrNull() } } - }.sortedBy { it.name } + }.sortedBy { + if (groupType == BY_TRACK_STATUS) { + mapTrackingOrder(it.name) + } else { + it.name + } } headers.forEachIndexed { index, category -> category.order = index } return items to headers } @@ -594,6 +603,20 @@ class LibraryPresenter( }) } + private fun mapTrackingOrder(status: String): String { + with(context) { + return when (status) { + getString(R.string.reading), getString(R.string.currently_reading) -> "1" + getString(R.string.rereading) -> "2" + getString(R.string.plan_to_read), getString(R.string.want_to_read) -> "3" + getString(R.string.on_hold), getString(R.string.paused) -> "4" + getString(R.string.completed) -> "5" + getString(R.string.dropped) -> "6" + else -> "7" + } + } + } + /** Create a default category with the sort set */ private fun createDefaultCategory(): Category { val default = Category.createDefault(context)