From 4e913d7f377a17081ae0ed79020e89f2156a3199 Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Sat, 13 Jun 2020 13:48:43 +0300 Subject: [PATCH] Fix #9089 --- OsmAnd/res/values/strings.xml | 4 ++ .../plus/quickaction/QuickActionRegistry.java | 2 + .../actions/ShowHideMapillaryAction.java | 69 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5ff7259325..6362a76dc1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,10 @@ Thx - Hardy --> + A toggle to show or hide the Mapillary layer on the map. + Show Mapillary + Hide Mapillary + Show/hide Mapillary Set vessel width to avoid narrow bridges Set vessel height to avoid low bridges. Keep in mind, if the bridge is movable, we will use its height in the open state. You can set vessel height to avoid low bridges. Keep in mind, if the bridge is movable, we will use its height in the open state. diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java index 045501de6b..01c38b7936 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java @@ -15,6 +15,7 @@ import com.google.gson.reflect.TypeToken; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.quickaction.actions.ShowHideMapillaryAction; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.quickaction.actions.DayNightModeAction; @@ -226,6 +227,7 @@ public class QuickActionRegistry { quickActionTypes.add(MapStyleAction.TYPE); quickActionTypes.add(DayNightModeAction.TYPE); quickActionTypes.add(ShowHideTransportLinesAction.TYPE); + quickActionTypes.add(ShowHideMapillaryAction.TYPE); // navigation quickActionTypes.add(NavVoiceAction.TYPE); quickActionTypes.add(NavDirectionsFromAction.TYPE); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java new file mode 100644 index 0000000000..ba6c7d7391 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideMapillaryAction.java @@ -0,0 +1,69 @@ +package net.osmand.plus.quickaction.actions; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.mapillary.MapillaryPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; +import net.osmand.plus.settings.backend.OsmandSettings; + +public class ShowHideMapillaryAction extends QuickAction { + + public static final QuickActionType TYPE = new QuickActionType(33, + "mapillary.showhide", ShowHideMapillaryAction.class) + .nameRes(R.string.quick_action_showhide_mapillary_title) + .iconRes(R.drawable.ic_action_mapillary).nonEditable() + .category(QuickActionType.CONFIGURE_MAP); + + public ShowHideMapillaryAction() { + super(TYPE); + } + + public ShowHideMapillaryAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + OsmandApplication app = activity.getMyApplication(); + OsmandSettings settings = app.getSettings(); + boolean enabled = settings.SHOW_MAPILLARY.get(); + settings.SHOW_MAPILLARY.set(!enabled); + MapillaryPlugin mapillaryPlugin = OsmandPlugin.getPlugin(MapillaryPlugin.class); + if (mapillaryPlugin != null) { + mapillaryPlugin.updateLayers(activity.getMapView(), activity); + } + } + + @Override + public void drawUI(ViewGroup parent, MapActivity activity) { + + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.quick_action_with_text, parent, false); + + ((TextView) view.findViewById(R.id.text)).setText( + R.string.quick_action_showhide_mapillary_descr); + + parent.addView(view); + } + + @Override + public String getActionText(OsmandApplication application) { + + return application.getSettings().SHOW_MAPILLARY.get() + ? application.getString(R.string.quick_action_mapillary_hide) + : application.getString(R.string.quick_action_mapillary_show); + } + + @Override + public boolean isActionWithSlash(OsmandApplication application) { + return application.getSettings().SHOW_MAPILLARY.get(); + } +}