From 52592ba765e5df3bfe500849bce531b967bdd1a9 Mon Sep 17 00:00:00 2001 From: Mac135135 Date: Tue, 18 Feb 2025 01:24:48 +0300 Subject: [PATCH] correct display of a fully read manga shows 100% in the details menu if the manga has actually been read in full. --- .../org/koitharu/kotatsu/details/ui/DetailsActivity.kt | 4 +++- .../org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt | 10 ++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index 4c774bd0a..1925d1ca8 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -484,8 +484,10 @@ class DetailsActivity : textViewProgress.textAndVisible = if (info.percent <= 0f) { null } else { - getString(R.string.percent_string_pattern, (info.percent * 100f).toInt().toString()) + val displayPercent = if (info.percent >= 0.999999f) 100 else (info.percent * 100f).toInt() + getString(R.string.percent_string_pattern, displayPercent.toString()) } + progress.setProgressCompat( (progress.max * info.percent.coerceIn(0f, 1f)).roundToInt(), true, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt index f4ddacbd6..bdce762ed 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt @@ -473,15 +473,9 @@ class ReaderViewModel @Inject constructor( if (chaptersCount == 0 || pagesCount == 0) { return PROGRESS_NONE } - val pagePercent = (pageIndex + 1).toFloat() / pagesCount + val pagePercent = (pageIndex + 1) / pagesCount.toFloat() val ppc = 1f / chaptersCount - var progress = ppc * chapterIndex + ppc * pagePercent - - if (chapterIndex == chaptersCount - 1 && pageIndex + 1 == pagesCount) { - progress = 1.0f - } - - return progress + return ppc * chapterIndex + ppc * pagePercent } private fun observeIsWebtoonZoomEnabled() = settings.observeAsFlow(