This commit is contained in:
Nazar-Kutz 2020-06-13 13:48:43 +03:00
parent 25e7cd4a57
commit 4e913d7f37
3 changed files with 75 additions and 0 deletions

View file

@ -11,6 +11,10 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="quick_action_showhide_mapillary_descr">A toggle to show or hide the Mapillary layer on the map.</string>
<string name="quick_action_mapillary_show">Show Mapillary</string>
<string name="quick_action_mapillary_hide">Hide Mapillary</string>
<string name="quick_action_showhide_mapillary_title">Show/hide Mapillary</string>
<string name="vessel_width_limit_description">Set vessel width to avoid narrow bridges</string> <string name="vessel_width_limit_description">Set vessel width to avoid narrow bridges</string>
<string name="vessel_height_limit_description">Set vessel height to avoid low bridges. Keep in mind, if the bridge is movable, we will use its height in the open state.</string> <string name="vessel_height_limit_description">Set vessel height to avoid low bridges. Keep in mind, if the bridge is movable, we will use its height in the open state.</string>
<string name="vessel_height_warning">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.</string> <string name="vessel_height_warning">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.</string>

View file

@ -15,6 +15,7 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.quickaction.actions.ShowHideMapillaryAction;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.quickaction.actions.DayNightModeAction; import net.osmand.plus.quickaction.actions.DayNightModeAction;
@ -226,6 +227,7 @@ public class QuickActionRegistry {
quickActionTypes.add(MapStyleAction.TYPE); quickActionTypes.add(MapStyleAction.TYPE);
quickActionTypes.add(DayNightModeAction.TYPE); quickActionTypes.add(DayNightModeAction.TYPE);
quickActionTypes.add(ShowHideTransportLinesAction.TYPE); quickActionTypes.add(ShowHideTransportLinesAction.TYPE);
quickActionTypes.add(ShowHideMapillaryAction.TYPE);
// navigation // navigation
quickActionTypes.add(NavVoiceAction.TYPE); quickActionTypes.add(NavVoiceAction.TYPE);
quickActionTypes.add(NavDirectionsFromAction.TYPE); quickActionTypes.add(NavDirectionsFromAction.TYPE);

View file

@ -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();
}
}