mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
parent
ce66ed0389
commit
47a2d06682
14 changed files with 92 additions and 105 deletions
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.presentation.track
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
|
@ -125,7 +126,7 @@ fun TrackInfoDialogHome(
|
|||
private fun TrackInfoItem(
|
||||
title: String,
|
||||
service: TrackService,
|
||||
status: String,
|
||||
@StringRes status: Int?,
|
||||
onStatusClick: () -> Unit,
|
||||
chapters: String,
|
||||
onChaptersClick: () -> Unit,
|
||||
|
@ -187,7 +188,7 @@ private fun TrackInfoItem(
|
|||
Row(modifier = Modifier.height(IntrinsicSize.Min)) {
|
||||
TrackDetailsItem(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = status,
|
||||
text = status?.let { stringResource(it) } ?: "",
|
||||
onClick = onStatusClick,
|
||||
)
|
||||
VerticalDivider()
|
||||
|
|
|
@ -41,7 +41,7 @@ import tachiyomi.presentation.core.util.isScrolledToStart
|
|||
fun TrackStatusSelector(
|
||||
selection: Int,
|
||||
onSelectionChange: (Int) -> Unit,
|
||||
selections: Map<Int, String>,
|
||||
selections: Map<Int, Int?>,
|
||||
onConfirm: () -> Unit,
|
||||
onDismissRequest: () -> Unit,
|
||||
) {
|
||||
|
@ -69,7 +69,7 @@ fun TrackStatusSelector(
|
|||
onClick = null,
|
||||
)
|
||||
Text(
|
||||
text = value,
|
||||
text = value?.let { stringResource(it) } ?: "",
|
||||
style = MaterialTheme.typography.bodyLarge.merge(),
|
||||
modifier = Modifier.padding(start = 24.dp),
|
||||
)
|
||||
|
|
|
@ -25,15 +25,15 @@ class TrackManager(context: Context) {
|
|||
const val SUWAYOMI = 9L
|
||||
}
|
||||
|
||||
val myAnimeList = MyAnimeList(context, MYANIMELIST)
|
||||
val aniList = Anilist(context, ANILIST)
|
||||
val kitsu = Kitsu(context, KITSU)
|
||||
val shikimori = Shikimori(context, SHIKIMORI)
|
||||
val bangumi = Bangumi(context, BANGUMI)
|
||||
val myAnimeList = MyAnimeList(MYANIMELIST)
|
||||
val aniList = Anilist(ANILIST)
|
||||
val kitsu = Kitsu(KITSU)
|
||||
val shikimori = Shikimori(SHIKIMORI)
|
||||
val bangumi = Bangumi(BANGUMI)
|
||||
val komga = Komga(context, KOMGA)
|
||||
val mangaUpdates = MangaUpdates(context, MANGA_UPDATES)
|
||||
val mangaUpdates = MangaUpdates(MANGA_UPDATES)
|
||||
val kavita = Kavita(context, KAVITA)
|
||||
val suwayomi = Suwayomi(context, SUWAYOMI)
|
||||
val suwayomi = Suwayomi(SUWAYOMI)
|
||||
|
||||
val services = listOf(myAnimeList, aniList, kitsu, shikimori, bangumi, komga, mangaUpdates, kavita, suwayomi)
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ abstract class TrackService(val id: Long) {
|
|||
|
||||
abstract fun getStatusList(): List<Int>
|
||||
|
||||
abstract fun getStatus(status: Int): String
|
||||
@StringRes
|
||||
abstract fun getStatus(status: Int): Int?
|
||||
|
||||
abstract fun getReadingStatus(): Int
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.anilist
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -13,7 +12,7 @@ import kotlinx.serialization.json.Json
|
|||
import uy.kohesive.injekt.injectLazy
|
||||
import tachiyomi.domain.track.model.Track as DomainTrack
|
||||
|
||||
class Anilist(private val context: Context, id: Long) : TrackService(id) {
|
||||
class Anilist(id: Long) : TrackService(id) {
|
||||
|
||||
companion object {
|
||||
const val READING = 1
|
||||
|
@ -61,16 +60,15 @@ class Anilist(private val context: Context, id: Long) : TrackService(id) {
|
|||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ, REREADING)
|
||||
}
|
||||
|
||||
override fun getStatus(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)
|
||||
REREADING -> getString(R.string.repeating)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
READING -> R.string.reading
|
||||
PLAN_TO_READ -> R.string.plan_to_read
|
||||
COMPLETED -> R.string.completed
|
||||
ON_HOLD -> R.string.on_hold
|
||||
DROPPED -> R.string.dropped
|
||||
REREADING -> R.string.repeating
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.bangumi
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -12,7 +11,7 @@ import kotlinx.serialization.encodeToString
|
|||
import kotlinx.serialization.json.Json
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class Bangumi(private val context: Context, id: Long) : TrackService(id) {
|
||||
class Bangumi(id: Long) : TrackService(id) {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
|
@ -94,15 +93,14 @@ class Bangumi(private val context: Context, id: Long) : TrackService(id) {
|
|||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ)
|
||||
}
|
||||
|
||||
override fun getStatus(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 -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
READING -> R.string.reading
|
||||
PLAN_TO_READ -> R.string.plan_to_read
|
||||
COMPLETED -> R.string.completed
|
||||
ON_HOLD -> R.string.on_hold
|
||||
DROPPED -> R.string.dropped
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -36,13 +36,12 @@ class Kavita(private val context: Context, id: Long) : TrackService(id), Enhance
|
|||
|
||||
override fun getStatusList() = listOf(UNREAD, READING, COMPLETED)
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
UNREAD -> getString(R.string.unread)
|
||||
READING -> getString(R.string.reading)
|
||||
COMPLETED -> getString(R.string.completed)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
UNREAD -> R.string.unread
|
||||
READING -> R.string.reading
|
||||
COMPLETED -> R.string.completed
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.kitsu
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -13,7 +12,7 @@ import kotlinx.serialization.json.Json
|
|||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class Kitsu(private val context: Context, id: Long) : TrackService(id) {
|
||||
class Kitsu(id: Long) : TrackService(id) {
|
||||
|
||||
companion object {
|
||||
const val READING = 1
|
||||
|
@ -42,15 +41,14 @@ class Kitsu(private val context: Context, id: Long) : TrackService(id) {
|
|||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ)
|
||||
}
|
||||
|
||||
override fun getStatus(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 -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
READING -> R.string.reading
|
||||
PLAN_TO_READ -> R.string.plan_to_read
|
||||
COMPLETED -> R.string.completed
|
||||
ON_HOLD -> R.string.on_hold
|
||||
DROPPED -> R.string.dropped
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -38,13 +38,12 @@ class Komga(private val context: Context, id: Long) : TrackService(id), Enhanced
|
|||
|
||||
override fun getStatusList() = listOf(UNREAD, READING, COMPLETED)
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
UNREAD -> getString(R.string.unread)
|
||||
READING -> getString(R.string.reading)
|
||||
COMPLETED -> getString(R.string.completed)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
UNREAD -> R.string.unread
|
||||
READING -> R.string.reading
|
||||
COMPLETED -> R.string.completed
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.mangaupdates
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -10,7 +9,7 @@ import eu.kanade.tachiyomi.data.track.mangaupdates.dto.copyTo
|
|||
import eu.kanade.tachiyomi.data.track.mangaupdates.dto.toTrackSearch
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
|
||||
class MangaUpdates(private val context: Context, id: Long) : TrackService(id) {
|
||||
class MangaUpdates(id: Long) : TrackService(id) {
|
||||
|
||||
companion object {
|
||||
const val READING_LIST = 0
|
||||
|
@ -35,15 +34,14 @@ class MangaUpdates(private val context: Context, id: Long) : TrackService(id) {
|
|||
return listOf(READING_LIST, COMPLETE_LIST, ON_HOLD_LIST, UNFINISHED_LIST, WISH_LIST)
|
||||
}
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
READING_LIST -> getString(R.string.reading_list)
|
||||
WISH_LIST -> getString(R.string.wish_list)
|
||||
COMPLETE_LIST -> getString(R.string.complete_list)
|
||||
ON_HOLD_LIST -> getString(R.string.on_hold_list)
|
||||
UNFINISHED_LIST -> getString(R.string.unfinished_list)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
READING_LIST -> R.string.reading_list
|
||||
WISH_LIST -> R.string.wish_list
|
||||
COMPLETE_LIST -> R.string.complete_list
|
||||
ON_HOLD_LIST -> R.string.on_hold_list
|
||||
UNFINISHED_LIST -> R.string.unfinished_list
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING_LIST
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.myanimelist
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -12,7 +11,7 @@ import kotlinx.serialization.encodeToString
|
|||
import kotlinx.serialization.json.Json
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class MyAnimeList(private val context: Context, id: Long) : TrackService(id) {
|
||||
class MyAnimeList(id: Long) : TrackService(id) {
|
||||
|
||||
companion object {
|
||||
const val READING = 1
|
||||
|
@ -44,16 +43,15 @@ class MyAnimeList(private val context: Context, id: Long) : TrackService(id) {
|
|||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ, REREADING)
|
||||
}
|
||||
|
||||
override fun getStatus(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)
|
||||
REREADING -> getString(R.string.repeating)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
READING -> R.string.reading
|
||||
PLAN_TO_READ -> R.string.plan_to_read
|
||||
COMPLETED -> R.string.completed
|
||||
ON_HOLD -> R.string.on_hold
|
||||
DROPPED -> R.string.dropped
|
||||
REREADING -> R.string.repeating
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.shikimori
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -12,7 +11,7 @@ import kotlinx.serialization.encodeToString
|
|||
import kotlinx.serialization.json.Json
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class Shikimori(private val context: Context, id: Long) : TrackService(id) {
|
||||
class Shikimori(id: Long) : TrackService(id) {
|
||||
|
||||
companion object {
|
||||
const val READING = 1
|
||||
|
@ -98,16 +97,15 @@ class Shikimori(private val context: Context, id: Long) : TrackService(id) {
|
|||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ, REREADING)
|
||||
}
|
||||
|
||||
override fun getStatus(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)
|
||||
REREADING -> getString(R.string.repeating)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
READING -> R.string.reading
|
||||
PLAN_TO_READ -> R.string.plan_to_read
|
||||
COMPLETED -> R.string.completed
|
||||
ON_HOLD -> R.string.on_hold
|
||||
DROPPED -> R.string.dropped
|
||||
REREADING -> R.string.repeating
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.track.suwayomi
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -12,7 +11,8 @@ import eu.kanade.tachiyomi.source.Source
|
|||
import tachiyomi.domain.manga.model.Manga as DomainManga
|
||||
import tachiyomi.domain.track.model.Track as DomainTrack
|
||||
|
||||
class Suwayomi(private val context: Context, id: Long) : TrackService(id), EnhancedTrackService {
|
||||
class Suwayomi(id: Long) : TrackService(id), EnhancedTrackService {
|
||||
|
||||
val api by lazy { TachideskApi() }
|
||||
|
||||
@StringRes
|
||||
|
@ -30,13 +30,12 @@ class Suwayomi(private val context: Context, id: Long) : TrackService(id), Enhan
|
|||
|
||||
override fun getStatusList() = listOf(UNREAD, READING, COMPLETED)
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
UNREAD -> getString(R.string.unread)
|
||||
READING -> getString(R.string.reading)
|
||||
COMPLETED -> getString(R.string.completed)
|
||||
else -> ""
|
||||
}
|
||||
@StringRes
|
||||
override fun getStatus(status: Int): Int? = when (status) {
|
||||
UNREAD -> R.string.unread
|
||||
READING -> R.string.reading
|
||||
COMPLETED -> R.string.completed
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getReadingStatus(): Int = READING
|
||||
|
|
|
@ -293,7 +293,7 @@ private data class TrackStatusSelectorScreen(
|
|||
private val service: TrackService,
|
||||
) : StateScreenModel<Model.State>(State(track.status)) {
|
||||
|
||||
fun getSelections(): Map<Int, String> {
|
||||
fun getSelections(): Map<Int, Int?> {
|
||||
return service.getStatusList().associateWith { service.getStatus(it) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue