diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 130ee592be..f3bf73c81a 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -15,6 +15,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; +import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.OnMapSelectedCallback; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.RasterMapType; import net.osmand.plus.views.GPXLayer; import net.osmand.plus.views.RouteLayer; @@ -67,10 +68,17 @@ public class RasterMapMenu { final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled; - final OsmandRasterMapsPlugin.OnMapSelectedCallback onMapSelectedCallback = - new OsmandRasterMapsPlugin.OnMapSelectedCallback() { + final OnMapSelectedCallback onMapSelectedCallback = + new OnMapSelectedCallback() { @Override - public void onMapSelected() { + public void onMapSelected(boolean canceled) { + if (type == RasterMapType.UNDERLAY && !canceled && !selected) { + hidePolygonsPref.set(true); + refreshMapComplete(mapActivity); + } else if (type == RasterMapType.UNDERLAY && !canceled && mapTypePreference.get() == null) { + hidePolygonsPref.set(false); + refreshMapComplete(mapActivity); + } mapActivity.getDashboard().refreshContent(true); } }; @@ -97,10 +105,6 @@ public class RasterMapMenu { @Override public void run() { plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback); - if (type == RasterMapType.UNDERLAY) { - hidePolygonsPref.set(isChecked); - mapActivity.getDashboard().refreshContent(true); - } refreshMapComplete(mapActivity); } }); diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 2ba9160aab..08be343fef 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -161,7 +161,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { if (!force && exMapPref.get() != null) { mapPref.set(exMapPref.get()); if (callback != null) { - callback.onMapSelected(); + callback.onMapSelected(false); } updateMapLayers(mapView, mapPref, layers); return; @@ -192,7 +192,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { mapPref.set(template.getName()); exMapPref.set(template.getName()); if (callback != null) { - callback.onMapSelected(); + callback.onMapSelected(false); } updateMapLayers(mapView, mapPref, layers); } else { @@ -214,7 +214,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { mapPref.set(keys.get(which)); exMapPref.set(keys.get(which)); if (callback != null) { - callback.onMapSelected(); + callback.onMapSelected(false); } updateMapLayers(mapView, mapPref, layers); } @@ -227,7 +227,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { @Override public void onDismiss(DialogInterface dialog) { if (callback != null) { - callback.onMapSelected(); + callback.onMapSelected(true); } } }); @@ -259,7 +259,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { toggleUnderlayState(mapActivity, RasterMapType.OVERLAY, new OnMapSelectedCallback() { @Override - public void onMapSelected() { + public void onMapSelected(boolean canceled) { ContextMenuItem item = adapter.getItem(pos); String overlayMapDescr = settings.MAP_OVERLAY.get(); @@ -275,10 +275,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { }); return false; case R.string.layer_underlay: - toggleUnderlayState(mapActivity, RasterMapType.UNDERLAY, new - OnMapSelectedCallback() { + toggleUnderlayState(mapActivity, RasterMapType.UNDERLAY, + new OnMapSelectedCallback() { @Override - public void onMapSelected() { + public void onMapSelected(boolean canceled) { ContextMenuItem item = adapter.getItem(pos); String underlayMapDescr = settings.MAP_UNDERLAY.get(); @@ -578,7 +578,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { if (map != null) { mapTypePreference.set(null); if (callback != null) { - callback.onMapSelected(); + callback.onMapSelected(false); } updateMapLayers(mapView, null, mapLayers); } else { @@ -592,6 +592,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { } public interface OnMapSelectedCallback { - void onMapSelected(); + void onMapSelected(boolean canceled); } }