Skip to content

Commit 48f521b

Browse files
author
Karim Mreisi
committed
game menu: clean-up open on back navigation
1 parent e195957 commit 48f521b

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

app/src/main/java/com/limelight/Game.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,16 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
12721272

12731273
@Override
12741274
public boolean handleKeyDown(KeyEvent event) {
1275-
// Pass-through virtual navigation keys
1275+
// Handle (virtual) Navigation Keys
12761276
if ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0) {
1277+
// Show Game Menu on back action instead of finishing the activity, the user has to
1278+
// select "Disconnect" within the game menu to actually disconnect
1279+
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
1280+
showGameMenu(null);
1281+
return true;
1282+
}
1283+
1284+
// Pass-through other navigation keys
12771285
return false;
12781286
}
12791287

@@ -2270,16 +2278,7 @@ public void showGameMenu(GameInputDevice device) {
22702278
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
22712279
switch (keyEvent.getAction()) {
22722280
case KeyEvent.ACTION_DOWN:
2273-
boolean handled = handleKeyDown(keyEvent);
2274-
if (handled)
2275-
return true;
2276-
2277-
// Intercept back key event before android handles it
2278-
// Always handle the request, the user has to select "Disconnect" within the game menu to actually disconnect
2279-
if (keyCode == keyEvent.KEYCODE_BACK) {
2280-
showGameMenu(null);
2281-
return true;
2282-
}
2281+
return handleKeyDown(keyEvent);
22832282
case KeyEvent.ACTION_UP:
22842283
return handleKeyUp(keyEvent);
22852284
default:

0 commit comments

Comments
 (0)