diff --git a/new-player/src/main/java/net/newpipe/newplayer/model/NewPlayerViewModelImpl.kt b/new-player/src/main/java/net/newpipe/newplayer/model/NewPlayerViewModelImpl.kt index 021de9d..4ba5fb9 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/model/NewPlayerViewModelImpl.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/model/NewPlayerViewModelImpl.kt @@ -347,7 +347,6 @@ class NewPlayerViewModelImpl @Inject constructor( if (!uiState.value.uiMode.fullscreen && newUiModeState.fullscreen && embeddedUiConfig != null) { this.embeddedUiConfig = embeddedUiConfig } - newUiModeState.fullscreen if ((newUiModeState == UIModeState.EMBEDDED_VIDEO_CONTROLLER_UI || newUiModeState == UIModeState.FULLSCREEN_VIDEO_CONTROLLER_UI) diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/EmbeddedGestureUI.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/EmbeddedGestureUI.kt index ead9462..4aedcab 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/EmbeddedGestureUI.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/EmbeddedGestureUI.kt @@ -89,11 +89,6 @@ internal fun EmbeddedGestureUI( } } - val handleUp = { - downwardMovementMode = false - sumOfMovement = 0f - } - val defaultOnRegularTap = { if (uiState.uiMode.videoControllerUiVisible) { viewModel.changeUiMode(uiState.uiMode.getUiHiddenState(), null) @@ -102,6 +97,11 @@ internal fun EmbeddedGestureUI( } } + val handleUp = { + downwardMovementMode = false + sumOfMovement = 0f + } + Row(modifier = modifier) { GestureSurface( modifier = Modifier.weight(1f), diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/GestureSurface.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/GestureSurface.kt index c3197e0..a1f601b 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/GestureSurface.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/gesture_ui/GestureSurface.kt @@ -26,6 +26,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -54,14 +56,15 @@ internal fun GestureSurface( onMovement: (TouchedPosition) -> Unit = {}, content: @Composable () -> Unit = {} ) { - var moveOccured by remember { - mutableStateOf(false) - } var lastTouchedPosition by remember { mutableStateOf(TouchedPosition(0f, 0f)) } + var yMovementSum by remember { + mutableFloatStateOf(0f) + } + var lastFingerUpTime by remember { mutableStateOf(System.currentTimeMillis()) } @@ -73,12 +76,13 @@ internal fun GestureSurface( val defaultActionDown = { event: MotionEvent -> lastTouchedPosition = TouchedPosition(event.x, event.y) - moveOccured = false + yMovementSum = 0f + true } var multitapAmount:Int by remember { - mutableStateOf(0) + mutableIntStateOf(0) } var cancelMultitapJob: Job? by remember { @@ -87,7 +91,8 @@ internal fun GestureSurface( val defaultActionUp = { onMultiTap: (Int) -> Unit, onRegularTap: () -> Unit -> onUp() - if (!moveOccured) { + + if (yMovementSum < 10) { val currentTime = System.currentTimeMillis() val timeSinceLastTouch = currentTime - lastFingerUpTime if (timeSinceLastTouch <= MULTITAB_MODE_DELAY) { @@ -109,7 +114,7 @@ internal fun GestureSurface( lastFingerUpTime = currentTime } - moveOccured = false + yMovementSum = 0f true } @@ -118,7 +123,8 @@ internal fun GestureSurface( val movement = currentTouchedPosition - lastTouchedPosition lastTouchedPosition = currentTouchedPosition - moveOccured = true + + yMovementSum += abs(movement.y) // filter out left and right movements as these are not important for the app if(abs(movement.x) <= abs(movement.y)) { diff --git a/test-app/src/main/java/net/newpipe/newplayer/testapp/MainActivity.kt b/test-app/src/main/java/net/newpipe/newplayer/testapp/MainActivity.kt index 2867496..f57b907 100644 --- a/test-app/src/main/java/net/newpipe/newplayer/testapp/MainActivity.kt +++ b/test-app/src/main/java/net/newpipe/newplayer/testapp/MainActivity.kt @@ -46,7 +46,7 @@ import javax.inject.Inject @AndroidEntryPoint class MainActivity : AppCompatActivity() { - val newPlayerViewModel: NewPlayerViewModel by viewModels() + private val newPlayerViewModel: NewPlayerViewModel by viewModels() private var currentOrientation = -1 private var reconfigurationPending = false