quick action map overlay execute

This commit is contained in:
Rosty 2017-01-10 13:00:40 +02:00
parent 223cd685dc
commit 3724e19a69
2 changed files with 28 additions and 1 deletions

View file

@ -2528,6 +2528,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_map_overlay_title">Map overlays</string> <string name="quick_action_map_overlay_title">Map overlays</string>
<string name="quick_action_map_overlay_descr">Tapping the action button will page the map overlay through the list below.</string> <string name="quick_action_map_overlay_descr">Tapping the action button will page the map overlay through the list below.</string>
<string name="quick_action_map_overlay_action">Add overlay</string> <string name="quick_action_map_overlay_action">Add overlay</string>
<string name="quick_action_map_overlay_switch">The map overlay has been changed to \"%s\".</string>
<string name="quick_action_map_underlay">Change map underlay</string> <string name="quick_action_map_underlay">Change map underlay</string>
<string name="quick_action_map_underlay_title">Map underlays</string> <string name="quick_action_map_underlay_title">Map underlays</string>
<string name="quick_action_map_underlay_descr">Tapping the action button will page the map underlay through the list below.</string> <string name="quick_action_map_underlay_descr">Tapping the action button will page the map underlay through the list below.</string>

View file

@ -2211,6 +2211,30 @@ public class QuickActionFactory {
@Override @Override
public void execute(MapActivity activity) { public void execute(MapActivity activity) {
OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
if (plugin != null) {
OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams();
Pair<String, String> currentSource = new Pair<>(
settings.MAP_OVERLAY.get(),
settings.MAP_OVERLAY.get());
Pair<String, String> 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 @Override
@ -2550,7 +2574,9 @@ public class QuickActionFactory {
@Override @Override
public boolean fillParams(View root, MapActivity activity) { 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<Adapter.ItemHolder> implements QuickActionItemTouchHelperCallback.OnItemMoveCallback { protected class Adapter extends RecyclerView.Adapter<Adapter.ItemHolder> implements QuickActionItemTouchHelperCallback.OnItemMoveCallback {