Stop BACK from bypassing the JS menu popup
BACK's isFullscreen()/navigate-away logic ran entirely on the Android side, with no idea whether the website's Menu popup was open - so pressing Back while the popup was showing jumped straight to the room list (or reloaded) instead of closing it, since Android can't observe JS-side modal state. BACK now just relays a real Escape keypress into the page whenever we're on a page this app controls (room list or in-room), and lets the website's own keydown handler - which already knows about the popup, cinema mode, and (now) fullscreen state - decide what Escape should do. Removed the now-dead isFullscreen()/fullscreenView-reading code path (fullscreenView itself stays: WebChromeClient still needs onShowCustomView/onHideCustomView for HTML5 fullscreen to render). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LHgWjmEJXsJEi1EVAoTp4K
This commit is contained in:
@@ -91,7 +91,6 @@ class MainActivity : Activity() {
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun isFullscreen() = fullscreenView != null
|
||||
private fun isRoomList() = currentPath == "/tv"
|
||||
private fun isInRoom() = currentPath.startsWith("/tv/")
|
||||
|
||||
@@ -139,16 +138,16 @@ class MainActivity : Activity() {
|
||||
KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS -> sendKey(KeyEvent.KEYCODE_P)
|
||||
KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT -> sendKey(KeyEvent.KEYCODE_N)
|
||||
KeyEvent.KEYCODE_MENU -> sendKey(KeyEvent.KEYCODE_X)
|
||||
KeyEvent.KEYCODE_BACK -> when {
|
||||
isRoomList() -> { /* verschluckt, keine weitere Aktion */ }
|
||||
isInRoom() && isFullscreen() -> sendKey(KeyEvent.KEYCODE_ESCAPE)
|
||||
isInRoom() -> webView.loadUrl(BuildConfig.WEBSITE_URL)
|
||||
/* Login/Signup/sonstige Seiten: nichts tun, statt zur Raumliste
|
||||
zu reloaden - sonst gehen unfertig ausgefuellte Formulare
|
||||
verloren, und da /tv Login voraussetzt, landete man dort
|
||||
sofort wieder auf der Login-Seite. */
|
||||
else -> { /* verschluckt, keine weitere Aktion */ }
|
||||
}
|
||||
/* BACK entscheidet NICHT mehr selbst zwischen "Popup schliessen",
|
||||
"Vollbild verlassen" und "zur Raumliste zurueck" - das kann nur
|
||||
JS wissen (siehe room.js/tv-rooms.js keydown-Handler), weil nur
|
||||
dort bekannt ist, ob z. B. das Menue-Popup gerade offen ist. Ein
|
||||
fixer Fall genau darauf beruhte der Bug, dass BACK bei offenem
|
||||
Popup direkt zur Raumliste sprang, statt das Popup zu schliessen.
|
||||
Auf Login/Signup/sonstigen Seiten (weder Raumliste noch Raum)
|
||||
bleibt BACK bewusst wirkungslos - sonst gehen unfertig
|
||||
ausgefuellte Formulare verloren. */
|
||||
KeyEvent.KEYCODE_BACK -> if (isRoomList() || isInRoom()) sendKey(KeyEvent.KEYCODE_ESCAPE)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user