diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5579108fca..c358126c4a 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2528,6 +2528,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Map overlays Tapping the action button will page the map overlay through the list below. Add overlay + The map overlay has been changed to \"%s\". Change map underlay Map underlays Tapping the action button will page the map underlay through the list below. diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java index 962fb5d64e..59d03bbb90 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java @@ -2211,6 +2211,30 @@ public class QuickActionFactory { @Override public void execute(MapActivity activity) { + OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class); + + if (plugin != null) { + + OsmandSettings settings = activity.getMyApplication().getSettings(); + List> sources = loadListFromParams(); + + Pair currentSource = new Pair<>( + settings.MAP_OVERLAY.get(), + settings.MAP_OVERLAY.get()); + + Pair nextSource = sources.get(0); + int index = sources.indexOf(currentSource); + + if (index >= 0 && index + 1 < sources.size()) { + nextSource = sources.get(index + 1); + } + + settings.MAP_OVERLAY.set(nextSource.first); + settings.MAP_OVERLAY_PREVIOUS.set(nextSource.first); + + plugin.updateMapLayers(activity.getMapView(), settings.MAP_OVERLAY, activity.getMapLayers()); + Toast.makeText(activity, activity.getString(R.string.quick_action_map_overlay_switch, nextSource.second), Toast.LENGTH_SHORT).show(); + } } @Override @@ -2550,7 +2574,9 @@ public class QuickActionFactory { @Override public boolean fillParams(View root, MapActivity activity) { - return !getParams().isEmpty() && (getParams().get(getListKey()) != null || !getParams().get(getListKey()).isEmpty()); + return !getParams().isEmpty() && (getParams().get(getListKey()) != null + || !getParams().get(getListKey()).isEmpty() + || !getParams().get(getListKey()).equals("[]")); } protected class Adapter extends RecyclerView.Adapter implements QuickActionItemTouchHelperCallback.OnItemMoveCallback {