diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index a7b84c10b9..dd895235a5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -10,6 +10,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import android.opengl.GLSurfaceView; +import android.content.pm.ActivityInfo; +import android.content.res.Configuration; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import com.actionbarsherlock.app.ActionBar; @@ -211,12 +213,34 @@ public class MapActivity extends AccessibleActivity { } gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView()); + + mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light, + R.string.default_buttons_other_actions, R.string.close); } public void addLockView(FrameLayout lockView) { this.lockView = lockView; } + public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + if (item.getItemId() == android.R.id.home && mDrawerToggle.isDrawerIndicatorEnabled()) { + if (mDrawerLayout.isDrawerOpen(findViewById(R.id.left_drawer))) { + mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); + } else { + mapActions.openOptionsMenuAsDrawer(); + } + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + mDrawerToggle.syncState(); + } + private void createProgressBarForRouting() { FrameLayout parent = (FrameLayout) mapViewController.getParentView(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, @@ -246,7 +270,13 @@ public class MapActivity extends AccessibleActivity { }); } - + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + mDrawerToggle.onConfigurationChanged(newConfig); + } + @SuppressWarnings("rawtypes") public Object getLastNonConfigurationInstanceByKey(String key) { Object k = super.getLastNonConfigurationInstance(); @@ -284,10 +314,6 @@ public class MapActivity extends AccessibleActivity { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); - mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); - mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light, - R.string.default_buttons_other_actions, R.string.close); - if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); // can't return from this method we are not sure if activity will be recreated or not