Fix reading progress indication
This commit is contained in:
@@ -7,8 +7,8 @@ import org.koitharu.kotatsu.core.parser.MangaDataRepository
|
|||||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||||
import org.koitharu.kotatsu.details.domain.ProgressUpdateUseCase
|
import org.koitharu.kotatsu.details.domain.ProgressUpdateUseCase
|
||||||
import org.koitharu.kotatsu.history.data.HistoryEntity
|
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.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.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.koitharu.kotatsu.core.model.findChapter
|
|||||||
import org.koitharu.kotatsu.core.model.isLocal
|
import org.koitharu.kotatsu.core.model.isLocal
|
||||||
import org.koitharu.kotatsu.core.os.NetworkState
|
import org.koitharu.kotatsu.core.os.NetworkState
|
||||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
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.local.data.LocalMangaRepository
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.koitharu.kotatsu.download.domain
|
package org.koitharu.kotatsu.download.domain
|
||||||
|
|
||||||
import androidx.work.Data
|
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.local.domain.model.LocalManga
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ import org.koitharu.kotatsu.tracker.domain.CheckNewChaptersUseCase
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Provider
|
import javax.inject.Provider
|
||||||
|
|
||||||
const val PROGRESS_NONE = -1f
|
|
||||||
|
|
||||||
@Reusable
|
@Reusable
|
||||||
class HistoryRepository @Inject constructor(
|
class HistoryRepository @Inject constructor(
|
||||||
private val db: MangaDatabase,
|
private val db: MangaDatabase,
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ import androidx.appcompat.content.res.AppCompatResources
|
|||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.util.ext.scale
|
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(
|
class ReadingProgressDrawable(
|
||||||
context: Context,
|
context: Context,
|
||||||
@@ -111,7 +112,7 @@ class ReadingProgressDrawable(
|
|||||||
paint,
|
paint,
|
||||||
)
|
)
|
||||||
if (hasText) {
|
if (hasText) {
|
||||||
if (checkDrawable != null && percent >= 1f - Math.ulp(percent)) {
|
if (checkDrawable != null && ReadingProgress.isCompleted(percent)) {
|
||||||
tempRect.set(bounds)
|
tempRect.set(bounds)
|
||||||
tempRect.scale(0.6)
|
tempRect.scale(0.6)
|
||||||
checkDrawable.bounds = tempRect
|
checkDrawable.bounds = tempRect
|
||||||
|
|||||||
@@ -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_LEFT
|
||||||
import org.koitharu.kotatsu.core.prefs.ProgressIndicatorMode.PERCENT_READ
|
import org.koitharu.kotatsu.core.prefs.ProgressIndicatorMode.PERCENT_READ
|
||||||
import org.koitharu.kotatsu.core.util.ext.getAnimationDuration
|
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
|
||||||
|
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
|
||||||
|
|
||||||
class ReadingProgressView @JvmOverloads constructor(
|
class ReadingProgressView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ data class ReadingProgress(
|
|||||||
CHAPTERS_LEFT -> totalChapters > 0 && percent in 0f..1f
|
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
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.require
|
||||||
import org.koitharu.kotatsu.core.util.ext.sanitize
|
import org.koitharu.kotatsu.core.util.ext.sanitize
|
||||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
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.MangaListMapper
|
||||||
|
import org.koitharu.kotatsu.list.domain.ReadingProgress.Companion.PROGRESS_NONE
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ import org.koitharu.kotatsu.details.data.MangaDetails
|
|||||||
import org.koitharu.kotatsu.details.domain.DetailsLoadUseCase
|
import org.koitharu.kotatsu.details.domain.DetailsLoadUseCase
|
||||||
import org.koitharu.kotatsu.details.ui.pager.ChaptersPagesSheet.Companion.TAB_PAGES
|
import org.koitharu.kotatsu.details.ui.pager.ChaptersPagesSheet.Companion.TAB_PAGES
|
||||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
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.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.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
import org.koitharu.kotatsu.parsers.util.assertNotNull
|
import org.koitharu.kotatsu.parsers.util.assertNotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user