Fix reading progress indication

This commit is contained in:
Koitharu
2024-08-15 14:46:06 +03:00
parent 20f357cb12
commit a61e406c91
9 changed files with 20 additions and 11 deletions

View File

@@ -7,8 +7,8 @@ import org.koitharu.kotatsu.core.parser.MangaDataRepository
import org.koitharu.kotatsu.core.parser.MangaRepository
import org.koitharu.kotatsu.details.domain.ProgressUpdateUseCase
import org.koitharu.kotatsu.history.data.HistoryEntity
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.history.data.toMangaHistory
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable

View File

@@ -5,7 +5,7 @@ import org.koitharu.kotatsu.core.model.findChapter
import org.koitharu.kotatsu.core.model.isLocal
import org.koitharu.kotatsu.core.os.NetworkState
import org.koitharu.kotatsu.core.parser.MangaRepository
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
import org.koitharu.kotatsu.local.data.LocalMangaRepository
import org.koitharu.kotatsu.parsers.model.Manga
import javax.inject.Inject

View File

@@ -1,7 +1,7 @@
package org.koitharu.kotatsu.download.domain
import androidx.work.Data
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
import org.koitharu.kotatsu.local.domain.model.LocalManga
import org.koitharu.kotatsu.parsers.model.Manga
import java.time.Instant

View File

@@ -33,8 +33,6 @@ import org.koitharu.kotatsu.tracker.domain.CheckNewChaptersUseCase
import javax.inject.Inject
import javax.inject.Provider
const val PROGRESS_NONE = -1f
@Reusable
class HistoryRepository @Inject constructor(
private val db: MangaDatabase,

View File

@@ -13,7 +13,8 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.core.graphics.ColorUtils
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.util.ext.scale
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.list.domain.ReadingProgress
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
class ReadingProgressDrawable(
context: Context,
@@ -111,7 +112,7 @@ class ReadingProgressDrawable(
paint,
)
if (hasText) {
if (checkDrawable != null && percent >= 1f - Math.ulp(percent)) {
if (checkDrawable != null && ReadingProgress.isCompleted(percent)) {
tempRect.set(bounds)
tempRect.scale(0.6)
checkDrawable.bounds = tempRect

View File

@@ -17,8 +17,8 @@ import org.koitharu.kotatsu.core.prefs.ProgressIndicatorMode.NONE
import org.koitharu.kotatsu.core.prefs.ProgressIndicatorMode.PERCENT_LEFT
import org.koitharu.kotatsu.core.prefs.ProgressIndicatorMode.PERCENT_READ
import org.koitharu.kotatsu.core.util.ext.getAnimationDuration
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.list.domain.ReadingProgress
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
class ReadingProgressView @JvmOverloads constructor(
context: Context,

View File

@@ -31,7 +31,17 @@ data class ReadingProgress(
CHAPTERS_LEFT -> totalChapters > 0 && percent in 0f..1f
}
fun isComplete() = percent >= 1f - Math.ulp(percent)
fun isCompleted() = Companion.isCompleted(percent)
fun isReversed() = mode == PERCENT_LEFT || mode == CHAPTERS_LEFT
companion object {
const val PROGRESS_NONE = -1f
const val PROGRESS_COMPLETED = 0.995f
fun isValid(percent: Float) = percent in 0f..1f
fun isCompleted(percent: Float) = percent >= PROGRESS_COMPLETED
}
}

View File

@@ -28,8 +28,8 @@ import org.koitharu.kotatsu.core.ui.BaseViewModel
import org.koitharu.kotatsu.core.util.ext.require
import org.koitharu.kotatsu.core.util.ext.sanitize
import org.koitharu.kotatsu.history.data.HistoryRepository
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.list.domain.MangaListMapper
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
import javax.inject.Inject
@HiltViewModel

View File

@@ -52,8 +52,8 @@ import org.koitharu.kotatsu.details.data.MangaDetails
import org.koitharu.kotatsu.details.domain.DetailsLoadUseCase
import org.koitharu.kotatsu.details.ui.pager.ChaptersPagesSheet.Companion.TAB_PAGES
import org.koitharu.kotatsu.history.data.HistoryRepository
import org.koitharu.kotatsu.history.data.PROGRESS_NONE
import org.koitharu.kotatsu.history.domain.HistoryUpdateUseCase
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.parsers.model.MangaPage
import org.koitharu.kotatsu.parsers.util.assertNotNull