mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-17 21:05:43 +00:00
feat: Refactor watch progress thresholds and improve UpNextBadge styling for better clarity
This commit is contained in:
parent
d8187652cd
commit
3b796018f7
2 changed files with 11 additions and 9 deletions
|
|
@ -23,6 +23,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.contentColorFor
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -434,10 +435,13 @@ private fun UpNextBadge(
|
|||
compact: Boolean,
|
||||
textSize: androidx.compose.ui.unit.TextUnit,
|
||||
) {
|
||||
val chipColor = MaterialTheme.colorScheme.primary
|
||||
val chipTextColor = contentColorFor(chipColor)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(if (compact) 4.dp else 12.dp))
|
||||
.background(MaterialTheme.colorScheme.primary)
|
||||
.background(chipColor)
|
||||
.padding(
|
||||
horizontal = if (compact) 6.dp else 8.dp,
|
||||
vertical = if (compact) 3.dp else 4.dp,
|
||||
|
|
@ -449,7 +453,7 @@ private fun UpNextBadge(
|
|||
fontSize = textSize,
|
||||
fontWeight = FontWeight.Bold,
|
||||
),
|
||||
color = Color.White,
|
||||
color = chipTextColor,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@ import kotlinx.serialization.Serializable
|
|||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.math.max
|
||||
|
||||
internal const val ContinueWatchingLimit = 20
|
||||
private const val MinResumePositionMs = 30_000L
|
||||
private const val CompletionThresholdMs = 180_000L
|
||||
private const val InProgressStartThresholdFraction = 0.02f
|
||||
private const val CompletionThresholdFraction = 0.85
|
||||
|
||||
@Serializable
|
||||
private data class StoredWatchProgressPayload(
|
||||
|
|
@ -39,9 +38,9 @@ internal fun shouldStoreWatchProgress(
|
|||
durationMs: Long,
|
||||
): Boolean {
|
||||
val thresholdMs = if (durationMs > 0L) {
|
||||
max(MinResumePositionMs, (durationMs * 0.02f).toLong())
|
||||
(durationMs * InProgressStartThresholdFraction).toLong()
|
||||
} else {
|
||||
MinResumePositionMs
|
||||
1L
|
||||
}
|
||||
return positionMs >= thresholdMs
|
||||
}
|
||||
|
|
@ -54,9 +53,8 @@ internal fun isWatchProgressComplete(
|
|||
if (isEnded) return true
|
||||
if (durationMs <= 0L) return false
|
||||
|
||||
val remainingMs = (durationMs - positionMs).coerceAtLeast(0L)
|
||||
val watchedFraction = positionMs.toDouble() / durationMs.toDouble()
|
||||
return watchedFraction >= 0.92 || remainingMs <= CompletionThresholdMs
|
||||
return watchedFraction >= CompletionThresholdFraction
|
||||
}
|
||||
|
||||
internal fun List<WatchProgressEntry>.resumeEntryForSeries(metaId: String): WatchProgressEntry? =
|
||||
|
|
|
|||
Loading…
Reference in a new issue