From a5610b73520e8125ae3f095e0f2432306234d5cc Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 22 Sep 2020 16:13:40 +0300 Subject: [PATCH 1/3] Minor fixes in plan route and follow track --- .../MeasurementToolFragment.java | 20 ++++++++++--------- .../FollowTrackFragment.java | 15 ++++++++++++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 520e8fb424..7d6818a9d6 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -536,7 +536,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route editingCtx.getCommandManager().setMeasurementLayer(mapActivity.getMapLayers().getMeasurementToolLayer()); enterMeasurementMode(); updateSnapToRoadControls(); - if (gpxData != null) { + if (gpxData != null && addPoints) { if (!isUndoMode()) { List points = gpxData.getGpxFile().getRoutePoints(); if (!points.isEmpty()) { @@ -546,13 +546,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route } } } - if (addPoints) { - ActionType actionType = gpxData.getActionType(); - if (actionType == ActionType.ADD_ROUTE_POINTS) { - displayRoutePoints(); - } else if (actionType == ActionType.EDIT_SEGMENT) { - displaySegmentPoints(); - } + ActionType actionType = gpxData.getActionType(); + if (actionType == ActionType.ADD_ROUTE_POINTS) { + displayRoutePoints(); + } else if (actionType == ActionType.EDIT_SEGMENT) { + displaySegmentPoints(); } } setMode(UNDO_MODE, false); @@ -807,7 +805,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route @Override public void saveChangesOnClick() { - saveChanges(FinalSaveAction.SHOW_TOAST, true); + if (isFollowTrackMode()) { + startTrackNavigation(); + } else { + saveChanges(FinalSaveAction.SHOW_TOAST, true); + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 544d073ca7..6507ff8d2d 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -63,6 +63,7 @@ import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.views.layers.MapControlsLayer; +import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -185,8 +186,18 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca setupTracksCard(); } else { - File file = new File(gpxFile.path); - GPXInfo gpxInfo = new GPXInfo(gpxFile.path, file.lastModified(), file.length()); + String fileName = null; + File file = null; + if (!Algorithms.isEmpty(gpxFile.path)) { + file = new File(gpxFile.path); + fileName = file.getName(); + } else if (!Algorithms.isEmpty(gpxFile.tracks)) { + fileName = gpxFile.tracks.get(0).name; + } + if (Algorithms.isEmpty(fileName)) { + fileName = app.getString(R.string.shared_string_gpx_track); + } + GPXInfo gpxInfo = new GPXInfo(fileName, file != null ? file.lastModified() : 0, file != null ? file.length() : 0); TrackEditCard importTrackCard = new TrackEditCard(mapActivity, gpxInfo); importTrackCard.setListener(this); cardsContainer.addView(importTrackCard.build(mapActivity)); From 5acf6e27f7bac41c75ea67a18f71d07b435bf5a3 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 22 Sep 2020 16:55:01 +0300 Subject: [PATCH 2/3] Hide extra description and remove unnecessary changes --- .../net/osmand/plus/activities/MapActivityActions.java | 4 +--- .../plus/routepreparationmenu/MapRouteInfoMenu.java | 9 +++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 5414b9c0f7..dbd0f133fa 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -525,9 +525,7 @@ public class MapActivityActions implements DialogProvider { TargetPointsHelper tg = mapActivity.getMyApplication().getTargetPointsHelper(); tg.clearStartPoint(false); Location finishLoc = ps.get(ps.size() - 1); - PointDescription point = new PointDescription(PointDescription.POINT_TYPE_LOCATION, result.path, ""); - point.setName(PointDescription.getSearchAddressStr(mapActivity)); - tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1, point); + tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1); } } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index f0216f1c9d..69bed394cc 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -1760,8 +1760,13 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener if (routeParams != null) { TargetPoint target = app.getTargetPointsHelper().getPointToNavigate(); if (target != null) { - PointDescription pointDescription = target.getOriginalPointDescription(); - return pointDescription != null && routeParams.getFile().path.equals(pointDescription.getTypeName()); + List points = routeParams.getPoints(app); + if (!Algorithms.isEmpty(points)) { + Location loc = points.get(points.size() - 1); + LatLon latLon = new LatLon(loc.getLatitude(), loc.getLongitude()); + LatLon targetLatLon = new LatLon(target.getLatitude(), target.getLongitude()); + return latLon.equals(targetLatLon); + } } } } From e6a7f5f22857409486a3ef94196050a0547de16c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 22 Sep 2020 17:13:51 +0300 Subject: [PATCH 3/3] Fix check for attach route card --- .../osmand/plus/routepreparationmenu/FollowTrackFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 6507ff8d2d..ee2bf6b38e 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -218,7 +218,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca reverseTrackCard.setListener(this); cardsContainer.addView(reverseTrackCard.build(mapActivity)); } - if (!gpxFile.hasRtePt()) { + if (!gpxFile.hasRtePt() && !gpxFile.hasRoute()) { cardsContainer.addView(buildDividerView(cardsContainer, true)); AttachTrackToRoadsCard attachTrackCard = new AttachTrackToRoadsCard(mapActivity);