Handle other languages and fallback 'resume'
This commit is contained in:
parent
f4fb2c5f68
commit
69b43a88e0
@ -73,8 +73,6 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.getNameForMangaInfo
|
||||
import eu.kanade.tachiyomi.ui.manga.ChapterItem
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaScreenState
|
||||
import java.text.DecimalFormat
|
||||
import java.text.DecimalFormatSymbols
|
||||
|
||||
@Composable
|
||||
fun MangaScreen(
|
||||
@ -92,7 +90,7 @@ fun MangaScreen(
|
||||
onRefresh: () -> Unit,
|
||||
onContinueReading: () -> Unit,
|
||||
onSearch: (query: String, global: Boolean) -> Unit,
|
||||
nextUnreadChapterNumber: () -> Float?,
|
||||
nextUnreadChapterNumber: () -> String?,
|
||||
|
||||
// For cover dialog
|
||||
onCoverClicked: () -> Unit,
|
||||
@ -191,7 +189,7 @@ private fun MangaScreenSmallImpl(
|
||||
onRefresh: () -> Unit,
|
||||
onContinueReading: () -> Unit,
|
||||
onSearch: (query: String, global: Boolean) -> Unit,
|
||||
nextUnreadChapterNumber: () -> Float?,
|
||||
nextUnreadChapterNumber: () -> String?,
|
||||
|
||||
// For cover dialog
|
||||
onCoverClicked: () -> Unit,
|
||||
@ -280,12 +278,15 @@ private fun MangaScreenSmallImpl(
|
||||
) {
|
||||
ExtendedFloatingActionButton(
|
||||
text = {
|
||||
val id = if (chapters.any { it.chapter.read }) {
|
||||
R.string.action_resume
|
||||
val chapterNumber = nextUnreadChapterNumber.invoke()
|
||||
val fabText = if (chapters.any { it.chapter.read } && chapterNumber != null) {
|
||||
stringResource(R.string.action_resume_chapter, chapterNumber) // valid next chapter number
|
||||
} else if (chapters.any { it.chapter.read }) {
|
||||
stringResource(R.string.action_resume) // invalid next chapter number
|
||||
} else {
|
||||
R.string.action_start
|
||||
stringResource(R.string.action_start) // no chapters read yet
|
||||
}
|
||||
Text(text = (stringResource(id) + " " + chapterFormatter.format(nextUnreadChapterNumber.invoke())))
|
||||
Text(text = fabText)
|
||||
},
|
||||
icon = { Icon(imageVector = Icons.Default.PlayArrow, contentDescription = null) },
|
||||
onClick = onContinueReading,
|
||||
@ -409,7 +410,7 @@ fun MangaScreenLargeImpl(
|
||||
onRefresh: () -> Unit,
|
||||
onContinueReading: () -> Unit,
|
||||
onSearch: (query: String, global: Boolean) -> Unit,
|
||||
nextUnreadChapterNumber: () -> Float?,
|
||||
nextUnreadChapterNumber: () -> String?,
|
||||
|
||||
// For cover dialog
|
||||
onCoverClicked: () -> Unit,
|
||||
@ -511,12 +512,15 @@ fun MangaScreenLargeImpl(
|
||||
) {
|
||||
ExtendedFloatingActionButton(
|
||||
text = {
|
||||
val id = if (chapters.any { it.chapter.read }) {
|
||||
R.string.action_resume
|
||||
val chapterNumber = nextUnreadChapterNumber.invoke()
|
||||
val fabText = if (chapters.any { it.chapter.read } && chapterNumber != null) {
|
||||
stringResource(R.string.action_resume_chapter, chapterNumber) // valid next chapter number
|
||||
} else if (chapters.any { it.chapter.read }) {
|
||||
stringResource(R.string.action_resume) // invalid next chapter number
|
||||
} else {
|
||||
R.string.action_start
|
||||
stringResource(R.string.action_start) // no chapters read yet
|
||||
}
|
||||
Text(text = (stringResource(id) + " " + chapterFormatter.format(nextUnreadChapterNumber.invoke())))
|
||||
Text(text = fabText)
|
||||
},
|
||||
icon = { Icon(imageVector = Icons.Default.PlayArrow, contentDescription = null) },
|
||||
onClick = onContinueReading,
|
||||
@ -700,8 +704,3 @@ private fun onChapterItemClick(
|
||||
else -> onChapterClicked(chapterItem.chapter)
|
||||
}
|
||||
}
|
||||
|
||||
private val chapterFormatter = DecimalFormat(
|
||||
"#.###",
|
||||
DecimalFormatSymbols().apply { decimalSeparator = '.' },
|
||||
)
|
||||
|
@ -63,6 +63,8 @@ import eu.kanade.tachiyomi.widget.materialdialogs.await
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import logcat.LogPriority
|
||||
import java.text.DecimalFormat
|
||||
import java.text.DecimalFormatSymbols
|
||||
import eu.kanade.domain.chapter.model.Chapter as DomainChapter
|
||||
|
||||
class MangaController :
|
||||
@ -131,6 +133,7 @@ class MangaController :
|
||||
onContinueReading = this::continueReading,
|
||||
onSearch = this::performSearch,
|
||||
nextUnreadChapterNumber = this::nextUnreadChapterNumber,
|
||||
onHoldContinueReading = this::holdContinueReading.takeIf { nextUnreadChapterNumber() != null },
|
||||
onCoverClicked = this::openCoverDialog,
|
||||
onShareClicked = this::shareManga.takeIf { isHttpSource },
|
||||
onDownloadActionClicked = this::runDownloadChapterAction.takeIf { !successState.source.isLocalOrStub() },
|
||||
@ -370,10 +373,10 @@ class MangaController :
|
||||
if (chapter != null) openChapter(chapter)
|
||||
}
|
||||
|
||||
private fun nextUnreadChapterNumber(): Float? {
|
||||
private fun nextUnreadChapterNumber(): String? {
|
||||
val chapter = presenter.getNextUnreadChapter()
|
||||
if (chapter != null) {
|
||||
return chapter.chapterNumber
|
||||
if (chapter != null && chapter.chapterNumber > 0) {
|
||||
return chapterFormatter.format(chapter.chapterNumber)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
@ -84,7 +84,8 @@
|
||||
<string name="action_remove">Remove</string>
|
||||
<string name="action_remove_everything">Remove everything</string>
|
||||
<string name="action_start">Start</string>
|
||||
<string name="action_resume">Resume chapter</string>
|
||||
<string name="action_resume">Resume</string>
|
||||
<string name="action_resume_chapter">Resume ch. %s</string>
|
||||
<string name="action_open_in_browser">Open in browser</string>
|
||||
<string name="action_show_manga">Show manga</string>
|
||||
<!-- Do not translate "WebView" -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user