Bug 1229967 - Handle onKeyDown() for the menu key in GeckoMenu. r=sebastian
authorJan Henning <jh+bugzilla@buttercookie.de>
Mon, 11 Apr 2016 12:42:21 +0200
changeset 292962 d7ccace9b11cc71f14bbe5313ad6536849d68daf
parent 292961 d6a124bce6703f44b28e538510202c42a117d9b2
child 292963 3d003731a97bdb6b4dce8e8e0319cd64b292b2f2
push id18671
push usercbook@mozilla.com
push dateWed, 13 Apr 2016 10:26:19 +0000
treeherderfx-team@d7ccace9b11c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1229967
milestone48.0a1
Bug 1229967 - Handle onKeyDown() for the menu key in GeckoMenu. r=sebastian This restores the functionality to close the menu by pressing the hardware menu key. MozReview-Commit-ID: EKCeALPvFoB
mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenu.java
--- a/mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenu.java
+++ b/mobile/android/base/java/org/mozilla/gecko/menu/GeckoMenu.java
@@ -457,16 +457,27 @@ public class GeckoMenu extends ListView
                 !mQuickShareActionItems.containsKey(menuItem))
                 return true;
         }
 
         return false;
     }
 
     @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        // Close the menu if it is open and the hardware menu key is pressed.
+        if (keyCode == KeyEvent.KEYCODE_MENU && isShown()) {
+            close();
+            return true;
+        }
+
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @Override
     public boolean isShortcutKey(int keyCode, KeyEvent event) {
         return true;
     }
 
     @Override
     public boolean performIdentifierAction(int id, int flags) {
         return false;
     }