diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 096d691d91..4616f216ce 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Delete next destination point Inline skates This device doesn\'t have speed cameras. Uninstall and Restart diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java index f34f539539..548ff41055 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.NavRemoveNextDestination; import net.osmand.plus.quickaction.actions.ShowHideMapillaryAction; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -236,6 +237,7 @@ public class QuickActionRegistry { quickActionTypes.add(NavStartStopAction.TYPE); quickActionTypes.add(NavResumePauseAction.TYPE); quickActionTypes.add(SwitchProfileAction.TYPE); + quickActionTypes.add(NavRemoveNextDestination.TYPE); OsmandPlugin.registerQuickActionTypesPlugins(quickActionTypes); Map quickActionTypesInt = new TreeMap<>(); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/NavRemoveNextDestination.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/NavRemoveNextDestination.java new file mode 100644 index 0000000000..3c094abfb4 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/NavRemoveNextDestination.java @@ -0,0 +1,54 @@ +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.R; +import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; + +public class NavRemoveNextDestination extends QuickAction { + + public static final QuickActionType TYPE = new QuickActionType(34, + "nav.destination.remove", NavRemoveNextDestination.class) + .nameRes(R.string.quick_action_remove_next_destination) + .iconRes(R.drawable.ic_action_direction_movement) + .nonEditable() + .category(QuickActionType.NAVIGATION); + + public NavRemoveNextDestination() { + super(TYPE); + } + + public NavRemoveNextDestination(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + TargetPointsHelper targetsHelper = activity.getMyApplication().getTargetPointsHelper(); + if (targetsHelper.getIntermediatePoints().size() > 0) { + targetsHelper.removeWayPoint(true, 0); + } else { + activity.getMapActions().stopNavigationActionConfirm(); + } + } + + @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_remove_next_destination); + parent.addView(view); + } + + @Override + public boolean isActionEnable(OsmandApplication app) { + return app.getRoutingHelper().isRouteCalculated(); + } +}