Hide speed indicator after 2 second to remove visual clutter

This commit is contained in:
AdityasahuX07 2026-04-20 22:02:03 +05:30 committed by GitHub
parent 77c9879583
commit c5c0a6f16d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,10 +79,10 @@ private val PlayerActionRowHeight = 50.dp
private fun sliderOverlayBottomPadding(metrics: PlayerLayoutMetrics) = private fun sliderOverlayBottomPadding(metrics: PlayerLayoutMetrics) =
metrics.sliderBottomOffset + metrics.sliderBottomOffset +
metrics.sliderTouchHeight + metrics.sliderTouchHeight +
PlayerTimeRowHeight + PlayerTimeRowHeight +
PlayerActionRowHeight + PlayerActionRowHeight +
PlayerSliderOverlayGap PlayerSliderOverlayGap
private enum class PlayerSideGesture { private enum class PlayerSideGesture {
Brightness, Brightness,
@ -195,6 +195,7 @@ fun PlayerScreen(
var gestureMessageJob by remember { mutableStateOf<Job?>(null) } var gestureMessageJob by remember { mutableStateOf<Job?>(null) }
var accumulatedSeekResetJob by remember { mutableStateOf<Job?>(null) } var accumulatedSeekResetJob by remember { mutableStateOf<Job?>(null) }
var accumulatedSeekState by remember { mutableStateOf<PlayerAccumulatedSeekState?>(null) } var accumulatedSeekState by remember { mutableStateOf<PlayerAccumulatedSeekState?>(null) }
var speedIndicatorJob by remember { mutableStateOf<Job?>(null) }
var initialLoadCompleted by remember(activeSourceUrl) { mutableStateOf(false) } var initialLoadCompleted by remember(activeSourceUrl) { mutableStateOf(false) }
var speedBoostRestoreSpeed by remember(activeSourceUrl) { mutableStateOf<Float?>(null) } var speedBoostRestoreSpeed by remember(activeSourceUrl) { mutableStateOf<Float?>(null) }
var isHoldToSpeedGestureActive by remember(activeSourceUrl) { mutableStateOf(false) } var isHoldToSpeedGestureActive by remember(activeSourceUrl) { mutableStateOf(false) }
@ -202,7 +203,7 @@ fun PlayerScreen(
val initialProgressFraction = activeInitialProgressFraction val initialProgressFraction = activeInitialProgressFraction
mutableStateOf( mutableStateOf(
activeInitialPositionMs <= 0L && activeInitialPositionMs <= 0L &&
(initialProgressFraction == null || initialProgressFraction <= 0f), (initialProgressFraction == null || initialProgressFraction <= 0f),
) )
} }
var lastProgressPersistEpochMs by remember(activeSourceUrl) { mutableStateOf(0L) } var lastProgressPersistEpochMs by remember(activeSourceUrl) { mutableStateOf(0L) }
@ -680,9 +681,18 @@ fun PlayerScreen(
icon = GestureFeedbackIcon.Speed, icon = GestureFeedbackIcon.Speed,
) )
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
// Hide the speed indicator after 2 seconds, but keep speed active
speedIndicatorJob?.cancel()
speedIndicatorJob = scope.launch {
delay(2_000L)
liveGestureFeedback = null
}
} }
fun deactivateHoldToSpeed() { fun deactivateHoldToSpeed() {
speedIndicatorJob?.cancel()
speedIndicatorJob = null
isHoldToSpeedGestureActive = false isHoldToSpeedGestureActive = false
val restoreSpeed = speedBoostRestoreSpeed ?: return val restoreSpeed = speedBoostRestoreSpeed ?: return
playerController?.setPlaybackSpeed(restoreSpeed) playerController?.setPlaybackSpeed(restoreSpeed)
@ -910,10 +920,10 @@ fun PlayerScreen(
val settings = playerSettingsUiState val settings = playerSettingsUiState
val shouldAutoSelectInManualMode = val shouldAutoSelectInManualMode =
settings.streamAutoPlayMode == StreamAutoPlayMode.MANUAL && settings.streamAutoPlayMode == StreamAutoPlayMode.MANUAL &&
( (
settings.streamAutoPlayNextEpisodeEnabled || settings.streamAutoPlayNextEpisodeEnabled ||
settings.streamAutoPlayPreferBingeGroup settings.streamAutoPlayPreferBingeGroup
) )
// Determine auto-play mode for next episode // Determine auto-play mode for next episode
val effectiveMode = if (shouldAutoSelectInManualMode) { val effectiveMode = if (shouldAutoSelectInManualMode) {
@ -1387,8 +1397,8 @@ fun PlayerScreen(
if (gestureMode == null) { if (gestureMode == null) {
val horizontalDominant = val horizontalDominant =
!isHoldToSpeedGestureActiveState.value && !isHoldToSpeedGestureActiveState.value &&
abs(totalDx) > viewConfiguration.touchSlop && abs(totalDx) > viewConfiguration.touchSlop &&
abs(totalDx) > abs(totalDy) abs(totalDx) > abs(totalDy)
val verticalDominant = val verticalDominant =
abs(totalDy) > viewConfiguration.touchSlop && abs(totalDy) > abs(totalDx) abs(totalDy) > viewConfiguration.touchSlop && abs(totalDy) > abs(totalDx)