Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6535267cf4
7 changed files with 60 additions and 18 deletions
|
@ -563,6 +563,21 @@ public class MapActivity extends AccessibleActivity {
|
|||
return super.onTrackballEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
MapActivityActions.DrawerType drawerState = mapActions.getDrawerType();
|
||||
outState.putSerializable("drawer_state",drawerState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
if (savedInstanceState != null){
|
||||
mapActions.setDrawerType((MapActivityActions.DrawerType) savedInstanceState.getSerializable("drawer_state"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
|
|
@ -92,14 +92,14 @@ public class MapActivityActions implements DialogProvider {
|
|||
ListView mDrawerList;
|
||||
private WaypointDialogHelper waypointDialogHelper;
|
||||
|
||||
private enum DrawerType{
|
||||
public enum DrawerType{
|
||||
WAYPOINTS,
|
||||
CONFIGURE_SCREEN,
|
||||
CONFIGURE_MAP,
|
||||
MAIN_MENU
|
||||
}
|
||||
|
||||
private DrawerType currentDrawer;
|
||||
private DrawerType currentDrawer = DrawerType.MAIN_MENU;
|
||||
|
||||
public MapActivityActions(MapActivity mapActivity){
|
||||
this.mapActivity = mapActivity;
|
||||
|
@ -176,8 +176,14 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.showDialog(DIALOG_RELOAD_TITLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DrawerType getDrawerType(){
|
||||
return currentDrawer;
|
||||
}
|
||||
|
||||
public void setDrawerType(DrawerType type){
|
||||
this.currentDrawer = type;
|
||||
prepareStartOptionsMenu();
|
||||
}
|
||||
|
||||
protected String getString(int res){
|
||||
return mapActivity.getString(res);
|
||||
|
@ -581,7 +587,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
if (currentDrawer == DrawerType.WAYPOINTS){
|
||||
showWaypointsInDrawer(false);
|
||||
} else if (currentDrawer == DrawerType.MAIN_MENU){
|
||||
final ContextMenuAdapter cm = createOptionsMenu();
|
||||
final ContextMenuAdapter cm = createMainOptionsMenu();
|
||||
prepareOptionsMenu(cm);
|
||||
} else {
|
||||
mDrawerList.invalidateViews();
|
||||
|
@ -600,8 +606,20 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
});
|
||||
}
|
||||
final ContextMenuAdapter cm = createOptionsMenu();
|
||||
prepareOptionsMenu(cm);
|
||||
switch (currentDrawer){
|
||||
case MAIN_MENU:
|
||||
prepareOptionsMenu(createMainOptionsMenu());
|
||||
break;
|
||||
case CONFIGURE_MAP:
|
||||
prepareConfigureMap();
|
||||
break;
|
||||
case CONFIGURE_SCREEN:
|
||||
prepareConfigureScreen();
|
||||
break;
|
||||
case WAYPOINTS:
|
||||
showWaypointsInDrawer(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void prepareOptionsMenu(final ContextMenuAdapter cm) {
|
||||
|
@ -652,7 +670,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
prepareOptionsMenu(new ConfigureMapMenu().createListAdapter(mapActivity, true));
|
||||
}
|
||||
|
||||
private ContextMenuAdapter createOptionsMenu() {
|
||||
public void onDrawerBack() {
|
||||
currentDrawer = DrawerType.MAIN_MENU;
|
||||
prepareStartOptionsMenu();
|
||||
}
|
||||
|
||||
private ContextMenuAdapter createMainOptionsMenu() {
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||
|
@ -826,9 +849,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
currentDrawer = DrawerType.CONFIGURE_SCREEN;
|
||||
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
||||
prepareOptionsMenu(cm);
|
||||
prepareConfigureScreen();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
@ -885,6 +906,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
return optionsMenuHelper;
|
||||
}
|
||||
|
||||
private void prepareConfigureScreen() {
|
||||
currentDrawer = DrawerType.CONFIGURE_SCREEN;
|
||||
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
||||
prepareOptionsMenu(cm);
|
||||
}
|
||||
|
||||
public void showWaypointsInDrawer(boolean flat) {
|
||||
currentDrawer = DrawerType.WAYPOINTS;
|
||||
final int[] running = new int[] { -1 };
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ConfigureMapMenu {
|
|||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
ma.getMapActions().prepareStartOptionsMenu();
|
||||
ma.getMapActions().onDrawerBack();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
|
|
@ -357,7 +357,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
if (dlg != null) {
|
||||
dlg.dismiss();
|
||||
} else if(a instanceof MapActivity){
|
||||
((MapActivity) a).getMapActions().prepareStartOptionsMenu();
|
||||
((MapActivity) a).getMapActions().onDrawerBack();
|
||||
((MapActivity) a).getMapActions().toggleDrawer();
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
if (dlg != null) {
|
||||
dlg.dismiss();
|
||||
} else if(a instanceof MapActivity){
|
||||
((MapActivity) a).getMapActions().prepareStartOptionsMenu();
|
||||
((MapActivity) a).getMapActions().onDrawerBack();
|
||||
((MapActivity) a).getMapActions().toggleDrawer();
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if (item == 0) {
|
||||
mapActivity.getMapActions().prepareStartOptionsMenu();
|
||||
mapActivity.getMapActions().onDrawerBack();
|
||||
} else if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||
showOnMap(app, ctx, ps.getPoint(), dialog);
|
||||
|
|
|
@ -298,7 +298,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
map.getMapActions().prepareStartOptionsMenu();
|
||||
map.getMapActions().onDrawerBack();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MapMenuControls extends MapControls {
|
|||
// double lat = activity.getMapView().getLatitude();
|
||||
// double lon = activity.getMapView().getLongitude();
|
||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||
mapActivity.getMapActions().prepareStartOptionsMenu();
|
||||
mapActivity.getMapActions().onDrawerBack();
|
||||
mapActivity.getMapActions().toggleDrawer();
|
||||
notifyClicked();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class SmallMapMenuControls extends MapControls {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
notifyClicked();
|
||||
mapActivity.getMapActions().prepareStartOptionsMenu();
|
||||
mapActivity.getMapActions().onDrawerBack();
|
||||
mapActivity.getMapActions().toggleDrawer();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue