From b9d7d6f2d15d63c62b0114b8c6437005690ce3ae Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 8 Oct 2026 12:28:25 +0000 Subject: [PATCH] app: keep dpad focus in content on rail With a navigation rail there is nothing below the page, yet pressing DPAD_DOWN on the last focusable item let the 2D focus search leave the page and land on a rail item to the side. Cancel downward exits from the page in rail mode; moving to the rail is still possible with DPAD_LEFT. The bottom bar keeps its existing focus handling. Assisted-by: Claude Opus 5.5 --- .../src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt index edb4c8d24..a627fe8ee 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt @@ -222,9 +222,12 @@ fun MainScreen( } } onExit = { - if (requestedFocusDirection == FocusDirection.Up || (isBar && - (requestedFocusDirection == FocusDirection.Left || - requestedFocusDirection == FocusDirection.Right)) + // With a rail, nothing is below the page, so don't let DPAD_DOWN + // jump into the rail; leaving to the rail is done with DPAD_LEFT. + val dir = requestedFocusDirection + if (dir == FocusDirection.Up || + (!isBar && dir == FocusDirection.Down) || + (isBar && (dir == FocusDirection.Left || dir == FocusDirection.Right)) ) { cancelFocusChange() }