From b6df72c3c9c2e9dcd651c9c0d4a93cd511b4890c Mon Sep 17 00:00:00 2001 From: damontecres <154766448+damontecres@users.noreply.github.com> Date: Wed, 5 Nov 2025 16:35:20 -0500 Subject: [PATCH] Optional setting for one click pause w/ d-pad center (#160) Closes #152 Adds a setting to enable one-click-pausing via the D-Pad center button. It is disabled by default. If enabled, when the video is playing, it will be pause and show the controls which is just like pressing the Pause or Play/Pause button. If enable, when the video is paused and controls is not showing, it will resume playback including using the skip back on resume setting. --- .../wholphin/preferences/AppPreference.kt | 13 +++++++++++++ .../wholphin/ui/playback/PlaybackKeyHandler.kt | 12 +++++++++++- .../wholphin/ui/playback/PlaybackPage.kt | 1 + app/src/main/proto/WholphinDataStore.proto | 1 + app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/preferences/AppPreference.kt b/app/src/main/java/com/github/damontecres/wholphin/preferences/AppPreference.kt index aa609f40..7a92e252 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/preferences/AppPreference.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/preferences/AppPreference.kt @@ -654,6 +654,18 @@ sealed interface AppPreference { summaryOn = R.string.enabled, summaryOff = R.string.disabled, ) + + val OneClickPause = + AppSwitchPreference( + title = R.string.one_click_pause, + defaultValue = false, + getter = { it.playbackPreferences.oneClickPause }, + setter = { prefs, value -> + prefs.updatePlaybackPreferences { oneClickPause = value } + }, + summaryOn = R.string.one_click_pause_summary_on, + summaryOff = R.string.disabled, + ) } } @@ -732,6 +744,7 @@ val advancedPreferences = title = R.string.playback, preferences = listOf( + AppPreference.OneClickPause, AppPreference.SkipIntros, AppPreference.SkipOutros, AppPreference.SkipCommercials, diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackKeyHandler.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackKeyHandler.kt index 7420b038..65e1d57e 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackKeyHandler.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackKeyHandler.kt @@ -23,6 +23,7 @@ class PlaybackKeyHandler( private val controllerViewState: ControllerViewState, private val updateSkipIndicator: (Long) -> Unit, private val skipBackOnResume: Duration?, + private val oneClickPause: Boolean, private val onInteraction: () -> Unit, ) { fun onKeyEvent(it: KeyEvent): Boolean { @@ -33,7 +34,7 @@ class PlaybackKeyHandler( result = false } else if (it.type != KeyEventType.KeyUp) { result = false - } else if (isDpad(it)) { + } else if (isDirectionalDpad(it) || isEnterKey(it)) { if (!controllerViewState.controlsVisible) { if (skipWithLeftRight && it.key == Key.DirectionLeft) { updateSkipIndicator(-seekBack.inWholeMilliseconds) @@ -41,6 +42,15 @@ class PlaybackKeyHandler( } else if (skipWithLeftRight && it.key == Key.DirectionRight) { player.seekForward(seekForward) updateSkipIndicator(seekForward.inWholeMilliseconds) + } else if (oneClickPause && isEnterKey(it)) { + Util.handlePlayPauseButtonAction(player) + if (!player.isPlaying) { + controllerViewState.showControls() + } else { + skipBackOnResume?.let { + player.seekBack(it) + } + } } else { controllerViewState.showControls() } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackPage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackPage.kt index b2c8749f..cb98f1ca 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackPage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/playback/PlaybackPage.kt @@ -208,6 +208,7 @@ fun PlaybackPage( updateSkipIndicator = updateSkipIndicator, skipBackOnResume = preferences.appPreferences.playbackPreferences.skipBackOnResume, onInteraction = viewModel::reportInteraction, + oneClickPause = preferences.appPreferences.playbackPreferences.oneClickPause, ) val showSegment = diff --git a/app/src/main/proto/WholphinDataStore.proto b/app/src/main/proto/WholphinDataStore.proto index bdfd92a4..f56bc4e1 100644 --- a/app/src/main/proto/WholphinDataStore.proto +++ b/app/src/main/proto/WholphinDataStore.proto @@ -58,6 +58,7 @@ message PlaybackPreferences { int64 pass_out_protection_ms = 16; PrefContentScale global_content_scale = 17; ShowNextUpWhen show_next_up_when = 18; + bool one_click_pause = 19; } message HomePagePreferences{ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a6a3287e..cb350af7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -142,6 +142,8 @@ Aired Episode Order Create new playlist Add to playlist + Pause with one click + Press D-Pad center to pause/play %d downloads