From d8fb3a9ec0c4335f1d9347c226ba900dccc3db5c Mon Sep 17 00:00:00 2001 From: dgis Date: Sat, 13 Jul 2019 16:40:52 +0200 Subject: [PATCH] - Prevent the BACK/ESCAPE key to end the application only from a hardware keyboard (Github Fix: #10). --- ReadMe.txt | 3 ++- .../main/java/org/emulator/calculator/MainScreenView.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index 4dc595c..f8e991b 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -57,7 +57,8 @@ CHANGES Version 1.6 (2019-07-XX) - Add option to prevent the pinch zoom. -- Prevent the white bottom bar when both options "Hide the status/navigations bar" and "Hide the menu button" are set (Github Fix: #6). +- Prevent the white bottom bar when both options "Hide the status/navigations bar" and "Hide the menu button" are set (Github Fix: #9). +- Prevent the BACK/ESCAPE key to end the application only from a hardware keyboard (Github Fix: #10). Version 1.5 (2019-07-11) diff --git a/app/src/main/java/org/emulator/calculator/MainScreenView.java b/app/src/main/java/org/emulator/calculator/MainScreenView.java index 2192358..6bbf5ce 100644 --- a/app/src/main/java/org/emulator/calculator/MainScreenView.java +++ b/app/src/main/java/org/emulator/calculator/MainScreenView.java @@ -209,9 +209,9 @@ public class MainScreenView extends PanAndScaleView { if (windowsKeycode != 0) NativeLib.keyDown(windowsKeycode); else if(debug) Log.e(TAG, String.format("Unknown keyCode: %d", keyCode)); + if(keyCode == KeyEvent.KEYCODE_BACK) + return true; } - if(keyCode == KeyEvent.KEYCODE_BACK) - return true; return super.onKeyDown(keyCode, event); } @@ -226,9 +226,9 @@ public class MainScreenView extends PanAndScaleView { if (windowsKeycode != 0) NativeLib.keyUp(windowsKeycode); else if(debug) Log.e(TAG, String.format("Unknown keyCode: %d", keyCode)); + if(keyCode == KeyEvent.KEYCODE_BACK) + return true; } - if(keyCode == KeyEvent.KEYCODE_BACK) - return true; return super.onKeyUp(keyCode, event); }