Added back button and menu iteraction for drawer
This commit is contained in:
parent
4910f93909
commit
c97524bfe7
2 changed files with 31 additions and 4 deletions
|
@ -272,6 +272,13 @@ public class MapActivity extends AccessibleActivity {
|
||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (!mapActions.onBackPressed()){
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -465,7 +472,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
||||||
mapActions.createOptionsMenuAsDrawer(true);
|
mapActions.onMenuPressed();
|
||||||
return true;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||||
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
||||||
|
|
|
@ -93,6 +93,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private RoutingHelper routingHelper;
|
private RoutingHelper routingHelper;
|
||||||
|
|
||||||
|
DrawerLayout mDrawerLayout;
|
||||||
|
ListView mDrawerList;
|
||||||
|
|
||||||
|
|
||||||
public MapActivityActions(MapActivity mapActivity){
|
public MapActivityActions(MapActivity mapActivity){
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
|
@ -724,10 +727,27 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onBackPressed(){
|
||||||
|
if (mDrawerLayout.isDrawerOpen(mDrawerList)){
|
||||||
|
mDrawerLayout.closeDrawer(mDrawerList);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMenuPressed(){
|
||||||
|
if (mDrawerLayout.isDrawerOpen(mDrawerList)){
|
||||||
|
mDrawerLayout.closeDrawer(mDrawerList);
|
||||||
|
} else {
|
||||||
|
createOptionsMenuAsDrawer(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void createOptionsMenuAsDrawer(boolean show){
|
public void createOptionsMenuAsDrawer(boolean show){
|
||||||
final ContextMenuAdapter cm = createOptionsMenu();
|
final ContextMenuAdapter cm = createOptionsMenu();
|
||||||
final DrawerLayout mDrawerLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
mDrawerLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
||||||
final ListView mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
|
mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
|
||||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
|
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
|
||||||
|
|
Loading…
Reference in a new issue