From df19ce0edaf8cefa2a9175a534564eb4cd0259af Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 1 Sep 2015 17:16:30 +0300 Subject: [PATCH] Hardware menu and search hardware button support. --- .../net/osmand/plus/activities/MapActivity.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f151430342..6c881012e3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -621,10 +621,10 @@ public class MapActivity extends AccessibleActivity { uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY); } return true; - } else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) { - openDrawer(); + } else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 1) { + toggleDrawer(); return true; - } else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { + } else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 1) { Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization() .getSearchActivity()); // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); @@ -982,4 +982,12 @@ public class MapActivity extends AccessibleActivity { public void closeDrawer() { drawerLayout.closeDrawer(Gravity.LEFT); } + + public void toggleDrawer() { + if (drawerLayout.isDrawerOpen(Gravity.LEFT)) { + closeDrawer(); + } else { + openDrawer(); + } + } }