quick action remove next destination

This commit is contained in:
veliymolfar 2020-07-02 15:14:09 +03:00
parent 5ed7ba037f
commit 1ffed241dc
3 changed files with 57 additions and 0 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<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>

View file

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

View file

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