fix doubletab seek starts after tabing after finger movement
This commit is contained in:
parent
c35f9d4992
commit
2ca274423e
|
@ -83,22 +83,19 @@ fun VideoPlayerControllerUI(
|
||||||
.union(WindowInsets.displayCutout)
|
.union(WindowInsets.displayCutout)
|
||||||
.union(WindowInsets.waterfall)
|
.union(WindowInsets.waterfall)
|
||||||
|
|
||||||
if (!uiState.uiVissible) {
|
|
||||||
GestureUI(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize(),
|
|
||||||
// .windowInsetsPadding(WindowInsets.systemGestures),
|
|
||||||
viewModel = viewModel,
|
|
||||||
uiState = uiState
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
AnimatedVisibility(uiState.uiVissible) {
|
AnimatedVisibility(uiState.uiVissible) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxSize(), color = Color(0x75000000)
|
modifier = Modifier.fillMaxSize(), color = Color(0x75000000)
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GestureUI(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize(),
|
||||||
|
viewModel = viewModel,
|
||||||
|
uiState = uiState
|
||||||
|
)
|
||||||
|
|
||||||
if (uiState.isLoading) {
|
if (uiState.isLoading) {
|
||||||
Box(modifier = Modifier.fillMaxSize()) {
|
Box(modifier = Modifier.fillMaxSize()) {
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
|
@ -112,14 +109,6 @@ fun VideoPlayerControllerUI(
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatedVisibility(uiState.uiVissible) {
|
AnimatedVisibility(uiState.uiVissible) {
|
||||||
GestureUI(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.windowInsetsPadding(WindowInsets.systemGestures),
|
|
||||||
viewModel = viewModel,
|
|
||||||
uiState = uiState
|
|
||||||
)
|
|
||||||
|
|
||||||
Box(modifier = Modifier.fillMaxSize()) {
|
Box(modifier = Modifier.fillMaxSize()) {
|
||||||
CenterUI(
|
CenterUI(
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
|
|
|
@ -30,13 +30,6 @@ import net.newpipe.newplayer.ui.videoplayer.gesture_ui.FullscreenGestureUI
|
||||||
|
|
||||||
private const val TAG = "TouchUi"
|
private const val TAG = "TouchUi"
|
||||||
|
|
||||||
|
|
||||||
const val DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS: Long = 200
|
|
||||||
const val SEEK_ANIMATION_DURATION_IN_MS = 300
|
|
||||||
const val FAST_SEEK_MODE_DURATION = 500L
|
|
||||||
const val SEEK_ANIMATION_FADE_IN = 200
|
|
||||||
const val SEEK_ANIMATION_FADE_OUT = 500
|
|
||||||
|
|
||||||
val INDICATOR_BACKGROUND_COLOR = Color.Black.copy(alpha = 0.3f)
|
val INDICATOR_BACKGROUND_COLOR = Color.Black.copy(alpha = 0.3f)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -36,7 +36,6 @@ import net.newpipe.newplayer.model.VideoPlayerUIState
|
||||||
import net.newpipe.newplayer.model.VideoPlayerViewModel
|
import net.newpipe.newplayer.model.VideoPlayerViewModel
|
||||||
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
|
import net.newpipe.newplayer.model.VideoPlayerViewModelDummy
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
import net.newpipe.newplayer.ui.videoplayer.FAST_SEEK_MODE_DURATION
|
|
||||||
|
|
||||||
private const val TAG = "EmbeddedGestureUI"
|
private const val TAG = "EmbeddedGestureUI"
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,12 @@ import com.google.android.material.color.MaterialColors
|
||||||
import net.newpipe.newplayer.R
|
import net.newpipe.newplayer.R
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
import net.newpipe.newplayer.ui.videoplayer.INDICATOR_BACKGROUND_COLOR
|
import net.newpipe.newplayer.ui.videoplayer.INDICATOR_BACKGROUND_COLOR
|
||||||
import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_DURATION_IN_MS
|
|
||||||
import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_IN
|
const val SEEK_ANIMATION_DURATION_IN_MS = 300
|
||||||
import net.newpipe.newplayer.ui.videoplayer.SEEK_ANIMATION_FADE_OUT
|
const val FAST_SEEK_MODE_DURATION = 500L
|
||||||
|
const val SEEK_ANIMATION_FADE_IN = 200
|
||||||
|
const val SEEK_ANIMATION_FADE_OUT = 500
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FastSeekVisualFeedback(modifier: Modifier = Modifier, seconds: Int, backwards: Boolean) {
|
fun FastSeekVisualFeedback(modifier: Modifier = Modifier, seconds: Int, backwards: Boolean) {
|
||||||
|
|
|
@ -72,7 +72,6 @@ fun FullscreenGestureUI(
|
||||||
}
|
}
|
||||||
|
|
||||||
val defaultOnRegularTap = {
|
val defaultOnRegularTap = {
|
||||||
|
|
||||||
if (uiState.uiVisible) {
|
if (uiState.uiVisible) {
|
||||||
viewModel.hideUi()
|
viewModel.hideUi()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,7 +37,9 @@ import androidx.compose.ui.input.pointer.pointerInteropFilter
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import net.newpipe.newplayer.ui.videoplayer.DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS
|
|
||||||
|
private const val MULTITAB_MODE_DELAY: Long = 300
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalComposeUiApi::class)
|
@OptIn(ExperimentalComposeUiApi::class)
|
||||||
|
@ -84,28 +86,29 @@ fun GestureSurface(
|
||||||
|
|
||||||
val defaultActionUp = { onMultiTap: (Int) -> Unit, onRegularTap: () -> Unit ->
|
val defaultActionUp = { onMultiTap: (Int) -> Unit, onRegularTap: () -> Unit ->
|
||||||
onUp()
|
onUp()
|
||||||
val currentTime = System.currentTimeMillis()
|
|
||||||
if (!moveOccured) {
|
if (!moveOccured) {
|
||||||
|
val currentTime = System.currentTimeMillis()
|
||||||
val timeSinceLastTouch = currentTime - lastFingerUpTime
|
val timeSinceLastTouch = currentTime - lastFingerUpTime
|
||||||
if (timeSinceLastTouch <= DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS) {
|
if (timeSinceLastTouch <= MULTITAB_MODE_DELAY) {
|
||||||
regularTabJob?.cancel()
|
regularTabJob?.cancel()
|
||||||
cancelMultitapJob?.cancel()
|
cancelMultitapJob?.cancel()
|
||||||
multitapAmount++
|
multitapAmount++
|
||||||
onMultiTap(multitapAmount)
|
onMultiTap(multitapAmount)
|
||||||
cancelMultitapJob = composableScope.launch {
|
cancelMultitapJob = composableScope.launch {
|
||||||
delay(DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS)
|
delay(MULTITAB_MODE_DELAY)
|
||||||
multitapAmount = 0
|
multitapAmount = 0
|
||||||
onMultiTapFinished()
|
onMultiTapFinished()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
regularTabJob = composableScope.launch {
|
regularTabJob = composableScope.launch {
|
||||||
delay(DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS)
|
delay(MULTITAB_MODE_DELAY)
|
||||||
onRegularTap()
|
onRegularTap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastFingerUpTime = currentTime
|
||||||
}
|
}
|
||||||
moveOccured = false
|
moveOccured = false
|
||||||
lastFingerUpTime = currentTime
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue