mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:35:09 +01:00
Tracking status grouping now uses global wording if you have mutliple trackers
ie kitsu's "currently reading" becomes "reading" since most trackers use that Also sorting the tracking groups better
This commit is contained in:
parent
87ab6fa8de
commit
ea1087e3dc
@ -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<String>
|
||||
|
||||
open fun indexToScore(index: Int): Float {
|
||||
|
@ -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<String> {
|
||||
return when (scorePreference.getOrDefault()) {
|
||||
// 10 point
|
||||
|
@ -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 {
|
||||
|
@ -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<String> {
|
||||
val df = DecimalFormat("0.#")
|
||||
return listOf("0") + IntRange(2, 20).map { df.format(it / 2f) }
|
||||
|
@ -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<Int> {
|
||||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ)
|
||||
}
|
||||
|
@ -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<String> {
|
||||
return IntRange(0, 10).map(Int::toString)
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user