From 8247de2f3ac1fd3981884bc29e42c0815b8e9389 Mon Sep 17 00:00:00 2001 From: fgmitesh Date: Sat, 30 May 2026 09:48:55 +0530 Subject: [PATCH 1/2] Improve key event handling in FullScreenPlayer Refactor key event handling for play/pause and chapter skipping. --- .../cloudstream3/ui/player/FullScreenPlayer.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index 26706699bcc..4ba933e1347 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -945,12 +945,18 @@ open class FullScreenPlayer : AbstractPlayerFragment( player.handleEvent(CSPlayerEvent.SkipCurrentChapter) } - KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, KeyEvent.KEYCODE_P, KeyEvent.KEYCODE_SPACE, KeyEvent.KEYCODE_NUMPAD_ENTER, KeyEvent.KEYCODE_ENTER -> { // space is not captured due to navigation + KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, KeyEvent.KEYCODE_P, KeyEvent.KEYCODE_SPACE, KeyEvent.KEYCODE_NUMPAD_ENTER -> { // space is not captured due to navigation player.handleEvent(CSPlayerEvent.PlayPauseToggle) } - KeyEvent.KEYCODE_DPAD_CENTER -> { - if (isShowing) { + // KEYCODE_DPAD_CENTER and KEYCODE_ENTER both act as a "select/confirm" button. + // Some remotes (e.g. LG Magic Remote) send KEYCODE_ENTER instead of KEYCODE_DPAD_CENTER. + // When the player UI or a dialog is visible, we let the event pass through (return null) + // so the focused button/item can handle the click normally, rather than always toggling + // play/pause. Only when the UI is hidden do we treat it as a play/pause toggle. + KeyEvent.KEYCODE_DPAD_CENTER, + KeyEvent.KEYCODE_ENTER -> { + if (isShowing || isDialogOpen()) { return null } // If UI is not shown make click instantly skip to next chapter even if locked From ac399aac2f4b35943d04ec92ae19b359f94840c4 Mon Sep 17 00:00:00 2001 From: fgmitesh Date: Sat, 30 May 2026 09:55:18 +0530 Subject: [PATCH 2/2] Handle KEYCODE_ENTER for SearchView focus --- .../main/java/com/lagradost/cloudstream3/CommonActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt index ed0aaf9b761..4ce09bd44ae 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt @@ -579,8 +579,10 @@ object CommonActivity { // TODO: Figure out why removing the check for SearchAutoComplete seems // to break focus on TV as it shouldn't need to be used. + // Also handle KEYCODE_ENTER here because some remotes (e.g. LG Magic Remote) + // send KEYCODE_ENTER instead of KEYCODE_DPAD_CENTER when clicking the OK button. @SuppressLint("RestrictedApi") - if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && + if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) && (act.currentFocus is SearchView || act.currentFocus is SearchView.SearchAutoComplete) ) { showInputMethod(act.currentFocus?.findFocus()) @@ -601,4 +603,4 @@ object CommonActivity { } return null } -} \ No newline at end of file +}