mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-15 02:05:58 -07:00
fix: Add keyEvent handling for devices that don't use back gestures
This commit is contained in:
parent
d2b8a855f3
commit
666f831053
1 changed files with 21 additions and 3 deletions
|
|
@ -49,8 +49,11 @@ import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.StrokeCap
|
import androidx.compose.ui.graphics.StrokeCap
|
||||||
import androidx.compose.ui.input.key.Key.Companion.Back
|
import androidx.compose.ui.input.key.Key.Companion.Back
|
||||||
|
import androidx.compose.ui.input.key.Key.Companion.Backspace
|
||||||
|
import androidx.compose.ui.input.key.Key.Companion.ButtonB
|
||||||
import androidx.compose.ui.input.key.Key.Companion.DirectionLeft
|
import androidx.compose.ui.input.key.Key.Companion.DirectionLeft
|
||||||
import androidx.compose.ui.input.key.Key.Companion.DirectionRight
|
import androidx.compose.ui.input.key.Key.Companion.DirectionRight
|
||||||
|
import androidx.compose.ui.input.key.Key.Companion.Escape
|
||||||
import androidx.compose.ui.input.key.KeyEvent
|
import androidx.compose.ui.input.key.KeyEvent
|
||||||
import androidx.compose.ui.input.key.KeyEventType
|
import androidx.compose.ui.input.key.KeyEventType
|
||||||
import androidx.compose.ui.input.key.key
|
import androidx.compose.ui.input.key.key
|
||||||
|
|
@ -120,9 +123,13 @@ fun CustomVideoControls(
|
||||||
}
|
}
|
||||||
|
|
||||||
BackHandler(
|
BackHandler(
|
||||||
enabled = showControls
|
enabled = true
|
||||||
) {
|
) {
|
||||||
hideControls()
|
if (showControls) {
|
||||||
|
hideControls()
|
||||||
|
} else {
|
||||||
|
activity?.finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart the hide timer whenever `lastInteraction` changes.
|
// Restart the hide timer whenever `lastInteraction` changes.
|
||||||
|
|
@ -169,9 +176,20 @@ fun CustomVideoControls(
|
||||||
.onKeyEvent { keyEvent: KeyEvent ->
|
.onKeyEvent { keyEvent: KeyEvent ->
|
||||||
if (keyEvent.type != KeyEventType.KeyDown) return@onKeyEvent false
|
if (keyEvent.type != KeyEventType.KeyDown) return@onKeyEvent false
|
||||||
|
|
||||||
|
when (keyEvent.key) {
|
||||||
|
Back, Escape, ButtonB, Backspace -> {
|
||||||
|
if (showControls) {
|
||||||
|
hideControls()
|
||||||
|
return@onKeyEvent true
|
||||||
|
} else {
|
||||||
|
activity?.finish()
|
||||||
|
return@onKeyEvent true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!showControls) {
|
if (!showControls) {
|
||||||
when (keyEvent.key) {
|
when (keyEvent.key) {
|
||||||
Back -> return@onKeyEvent true
|
|
||||||
DirectionLeft -> {
|
DirectionLeft -> {
|
||||||
currentSkipTime -= backwardSpeed.inWholeMilliseconds
|
currentSkipTime -= backwardSpeed.inWholeMilliseconds
|
||||||
updateSeekInteraction()
|
updateSeekInteraction()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue