From 22c65c06c7bbcec15f6b5c15171a893d19c5d2a8 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 26 Mar 2014 17:41:05 +0100 Subject: [PATCH] Fix small issues (add option to not replace a target but add as a target) --- OsmAnd/res/values/strings.xml | 2 ++ OsmAnd/src/net/osmand/plus/TargetPointsHelper.java | 9 ++++++++- .../osmand/plus/activities/MapActivityActions.java | 14 +++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 46c44062d2..657a054038 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Add as destination point Select GPX … Select Destination Select on map … @@ -406,6 +407,7 @@ Add as first waypoint Add as last waypoint Add as first waypoint + Replace destination point You already have destination point set. Waypoints diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 70e3218e0b..5781ceb18a 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -230,7 +230,14 @@ public class TargetPointsHelper { public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate, String historyName){ if(point != null){ - if(intermediate < 0) { + if(intermediate < 0 || intermediate > intermediatePoints.size()) { + if(intermediate > intermediatePoints.size()) { + LatLon pn = getPointToNavigate(); + if(pn != null) { + settings.insertIntermediatePoint(pn.getLatitude(), pn.getLongitude(), getPointNavigateDescription(), + intermediatePoints.size()); + } + } settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), historyName); } else { settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), historyName, diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index b74b42b59e..7da7364d98 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -369,7 +369,7 @@ public class MapActivityActions implements DialogProvider { public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) { final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter; - if(!mapActivity.getRoutingHelper().isRoutePlanningMode()) { + if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) { adapter.item(R.string.context_menu_item_directions_to).icons( R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg(); } @@ -384,7 +384,7 @@ public class MapActivityActions implements DialogProvider { adapter.item(R.string.context_menu_item_destination_point).icons(R.drawable.ic_action_flag_dark, R.drawable.ic_action_flag_light).reg(); } - if(!mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode()) { + if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) { adapter.item(R.string.context_menu_item_directions_from).icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light).reg(); } adapter.item(R.string.context_menu_item_search).icons(R.drawable.ic_action_search_dark, @@ -626,7 +626,7 @@ public class MapActivityActions implements DialogProvider { } }).reg(); } - if (getTargets().getPointToNavigate() != null && !routingHelper.isRoutePlanningMode()) { + if (getTargets().getPointToNavigate() != null) { optionsMenuHelper.item(R.string.target_points).icons(R.drawable.ic_action_flage_dark, R.drawable.ic_action_flage_light) .listen(new OnContextMenuClick() { @Override @@ -965,16 +965,20 @@ public class MapActivityActions implements DialogProvider { builder.setTitle(R.string.new_destination_point_dialog); builder.setItems( new String[] { act.getString(R.string.replace_destination_point), + act.getString(R.string.keep_and_add_destination_point), act.getString(R.string.add_as_first_destination_point), act.getString(R.string.add_as_last_destination_point) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name); + } else if (which == 1) { + targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, + targetPointsHelper.getIntermediatePoints().size() + 1, name); } else if (which == 2) { - targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, targetPointsHelper.getIntermediatePoints().size(), name); - } else { targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, 0, name); + } else { + targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, targetPointsHelper.getIntermediatePoints().size(), name); } MapActivity.launchMapActivityMoveToTop(act); }