Merge pull request #9373 from osmandapp/remove_waypoint
Remove waypoint
This commit is contained in:
commit
de1e43ada8
3 changed files with 59 additions and 0 deletions
|
@ -11,9 +11,11 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="quick_action_remove_next_destination_descr">The current destination point on the route will be deleted. If it will be the Destination, navigation will stop.</string>
|
||||
<string name="please_provide_point_name_error">Please provide a name for the point</string>
|
||||
<string name="use_volume_buttons_as_zoom">Volume buttons as zoom</string>
|
||||
<string name="use_volume_buttons_as_zoom_descr">Enable to control the map zoom level with device volume buttons.</string>
|
||||
<string name="quick_action_remove_next_destination">Delete next destination point</string>
|
||||
<string name="app_mode_inline_skates">Inline skates</string>
|
||||
<string name="speed_cameras_removed_descr">This device doesn\'t have speed cameras.</string>
|
||||
<string name="shared_string_uninstall_and_restart">Uninstall and Restart</string>
|
||||
|
|
|
@ -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<Integer, QuickActionType> quickActionTypesInt = new TreeMap<>();
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
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.mapcontextmenu.other.DestinationReachedMenu;
|
||||
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_navigation_skip_destination)
|
||||
.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 {
|
||||
DestinationReachedMenu.show(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_remove_next_destination_descr);
|
||||
parent.addView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionEnable(OsmandApplication app) {
|
||||
return app.getRoutingHelper().isRouteCalculated();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue