From 9bb97c72a136657a7567f9814c20184457a94d82 Mon Sep 17 00:00:00 2001 From: Mac135135 Date: Tue, 18 Feb 2025 00:46:03 +0300 Subject: [PATCH 1/2] "Check mark" fix on cover if the manga has been read in full, the "check mark" will be displayed correctly on the cover --- .../koitharu/kotatsu/history/data/HistoryRepository.kt | 5 +++-- .../org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt index 13aaf137b..cb319e58d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt @@ -145,10 +145,11 @@ class HistoryRepository @Inject constructor( suspend fun getProgress(mangaId: Long, mode: ProgressIndicatorMode): ReadingProgress? { val entity = db.getHistoryDao().find(mangaId) ?: return null + val fixedPercent = if (entity.percent >= 0.999999f) 1f else entity.percent return ReadingProgress( - percent = entity.percent, + percent = fixedPercent, totalChapters = entity.chaptersCount, - mode = mode, + mode = mode ).takeIf { it.isValid() } } 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 bdce762ed..f4ddacbd6 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,9 +473,15 @@ class ReaderViewModel @Inject constructor( if (chaptersCount == 0 || pagesCount == 0) { return PROGRESS_NONE } - val pagePercent = (pageIndex + 1) / pagesCount.toFloat() + val pagePercent = (pageIndex + 1).toFloat() / pagesCount val ppc = 1f / chaptersCount - return ppc * chapterIndex + ppc * pagePercent + var progress = ppc * chapterIndex + ppc * pagePercent + + if (chapterIndex == chaptersCount - 1 && pageIndex + 1 == pagesCount) { + progress = 1.0f + } + + return progress } private fun observeIsWebtoonZoomEnabled() = settings.observeAsFlow( From 52592ba765e5df3bfe500849bce531b967bdd1a9 Mon Sep 17 00:00:00 2001 From: Mac135135 Date: Tue, 18 Feb 2025 01:24:48 +0300 Subject: [PATCH 2/2] 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(