diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index e9b8674f7d..e44689eb47 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -623,6 +623,10 @@ public class MapActivityActions implements DialogProvider { } }); } + refreshDrawer(); + } + + public void refreshDrawer(){ switch (currentDrawer){ case MAIN_MENU: prepareOptionsMenu(createMainOptionsMenu()); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index 71d9144c5e..32e73e40bf 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -217,7 +217,7 @@ public class MapActivityLayers { - public void showGPXFileLayer(List files, final OsmandMapTileView mapView) { + public AlertDialog showGPXFileLayer(List files, final OsmandMapTileView mapView) { final OsmandSettings settings = getApplication().getSettings(); CallbackWithObject callbackWithObject = new CallbackWithObject() { @Override @@ -243,14 +243,15 @@ public class MapActivityLayers { mapView.getZoom(), true); } mapView.refreshMap(); + activity.getMapActions().refreshDrawer(); return true; } }; if (files == null) { - GpxUiHelper.selectGPXFile(activity, true, true, callbackWithObject); + return GpxUiHelper.selectGPXFile(activity, true, true, callbackWithObject); } else { - GpxUiHelper.selectGPXFile(files, activity, true, true, callbackWithObject); + return GpxUiHelper.selectGPXFile(files, activity, true, true, callbackWithObject); } } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index de621f0b3c..ba8b3ae6f6 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -115,7 +115,7 @@ public class ConfigureMapMenu { } @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) { OsmandSettings settings = ma.getMyApplication().getSettings(); if (itemId == R.string.layer_poi) { if (isChecked) { @@ -130,7 +130,14 @@ public class ConfigureMapMenu { if (ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()) { ma.getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow(); } else { - ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView()); + AlertDialog dialog = ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView()); + dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + cm.setSelection(pos, 0); + adapter.notifyDataSetChanged(); + } + }); } // TODO: tick mark of "Show GPX" needs to be synced after return form sub-selection screen (user may or may not have selected files!) } else if (itemId == R.string.layer_transport_route) {