Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ fun PlaybackPageContent(
val nextWithUpDown =
remember {
playlistPager != null &&
playlistPager.filter.dataType == DataType.MARKER &&
playlistPager.size > 1 &&
uiConfig.preferences.interfacePreferences.useUpDownPreviousNext
}
Expand Down Expand Up @@ -1111,10 +1110,34 @@ class PlaybackKeyHandler(
private val controllerViewState: ControllerViewState,
private val updateSkipIndicator: (Long) -> Unit,
) {
private var keyDownKey: Key? = null
private var holdActionTriggered = false

fun onKeyEvent(it: KeyEvent): Boolean {
var result = true
if (!controlsEnabled) {
result = false
} else if (it.type == KeyEventType.KeyDown) {
if (nextWithUpDown && (it.key == Key.DirectionUp || it.key == Key.DirectionDown)) {
val repeatCount = it.nativeKeyEvent.repeatCount
if (keyDownKey == null) {
keyDownKey = it.key
holdActionTriggered = false
} else if (keyDownKey == it.key && !holdActionTriggered && repeatCount >= 2) {
// Each repeat is roughly 250-300ms, so repeatCount==2 is ~500-600ms
holdActionTriggered = true
if (!controllerViewState.controlsVisible) {
if (it.key == Key.DirectionUp) {
player.seekToPreviousMediaItem()
} else if (it.key == Key.DirectionDown) {
player.seekToNextMediaItem()
}
}
}
result = true
} else {
result = false
}
} else if (it.type != KeyEventType.KeyUp) {
result = false
} else if (isDpad(it)) {
Expand All @@ -1125,10 +1148,14 @@ class PlaybackKeyHandler(
} else if (skipWithLeftRight && it.key == Key.DirectionRight) {
player.seekForward()
updateSkipIndicator(player.seekForwardIncrement)
} else if (nextWithUpDown && it.key == Key.DirectionUp) {
player.seekToPreviousMediaItem()
} else if (nextWithUpDown && it.key == Key.DirectionDown) {
player.seekToNextMediaItem()
} else if (nextWithUpDown && (it.key == Key.DirectionUp || it.key == Key.DirectionDown)) {
val wasHeld = keyDownKey == it.key && holdActionTriggered
keyDownKey = null
holdActionTriggered = false
if (!wasHeld) {
// Only show player controls if it was a short press (not a hold)
controllerViewState.showControls()
}
} else {
controllerViewState.showControls()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ sealed interface StashPreference<T> {
setter = { prefs, value ->
prefs.updateInterfacePreferences { useUpDownPreviousNext = value }
},
summaryOn = R.string.enabled_for_markers,
summaryOn = R.string.enabled_for_scenes_and_markers,
summaryOff = R.string.transcode_options_disabled,
)

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<string name="up_down_next_previous_pref_title">Use Up/Down for Previous/Next</string>
<string name="captions_default">Turn captions on by default</string>
<string name="captions_default_summary">Whether to turn captions for the device\'s language on by default</string>
<string name="enabled_for_markers">Enabled for marker playlists</string>
<string name="enabled_for_scenes_and_markers">Enabled for scene and marker playlists</string>
<string name="scroll_next_view_all">Scroll to next on View All</string>
<string name="scroll_next_view_all_summary">Automatically scroll down to the \'next\' results when clicking View All on main page</string>
<string name="scroll_to_top_back_summary">Scroll to the top of page when pressing the back button</string>
Expand Down