diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 42b176201b..8089d3a012 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -1521,8 +1521,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route private String getSuggestedFileName() { GpxData gpxData = editingCtx.getGpxData(); - String displayedName; - if (gpxData == null) { + String displayedName = null; + if (gpxData != null) { + GPXFile gpxFile = gpxData.getGpxFile(); + if (!Algorithms.isEmpty(gpxFile.path)) { + displayedName = Algorithms.getFileNameWithoutExtension(new File(gpxFile.path).getName()); + } else if (!Algorithms.isEmpty(gpxFile.tracks)) { + displayedName = gpxFile.tracks.get(0).name; + } + } + if (gpxData == null || displayedName == null) { String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date()); displayedName = FileUtils.createUniqueFileName(requireMyApplication(), suggestedName, GPX_INDEX_DIR, GPX_FILE_EXT); } else { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 407f65295f..62827e1e67 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -487,7 +487,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date()); fileName = FileUtils.createUniqueFileName(app, suggestedName, IndexConstants.GPX_INDEX_DIR, GPX_FILE_EXT); } else { - fileName = AndroidUtils.trimExtension(new File(paramsBuilder.getFile().path).getName()); + fileName = Algorithms.getFileNameWithoutExtension(new File(paramsBuilder.getFile().path).getName()); } SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), ChooseRouteFragment.this, null, fileName, diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 42ff2f94e6..8937f4ce5d 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -25,6 +25,7 @@ import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.TrkSegment; +import net.osmand.GPXUtilities.WptPt; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.ValueHolder; @@ -433,14 +434,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca if (mapActivity != null) { if (card instanceof ImportTrackCard) { importTrack(); - } else if (card instanceof TrackEditCard) { - openPlanRoute(true); + } else if (card instanceof TrackEditCard || card instanceof AttachTrackToRoadsCard) { + openPlanRoute(); close(); } else if (card instanceof SelectTrackCard) { updateSelectionMode(true); - } else if (card instanceof AttachTrackToRoadsCard) { - openPlanRoute(false); - close(); } else if (card instanceof ReverseTrackCard || card instanceof NavigateTrackOptionsCard) { updateMenu(); @@ -488,6 +486,14 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { this.gpxFile = gpxFile; + List points = gpxFile.getRoutePoints(); + if (!points.isEmpty()) { + ApplicationMode mode = ApplicationMode.valueOfStringKey(points.get(0).getProfileType(), null); + if (mode != null) { + app.getRoutingHelper().setAppMode(mode); + app.initVoiceCommandPlayer(mapActivity, mode, true, null, false, false, true); + } + } mapActivity.getMapActions().setGPXRouteParams(gpxFile); app.getTargetPointsHelper().updateRouteAndRefresh(true); app.getRoutingHelper().recalculateRouteDueToSettingsChange(); @@ -544,7 +550,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } } - public void openPlanRoute(boolean useAppMode) { + public void openPlanRoute() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null && gpxFile != null) { editingTrack = true; @@ -554,9 +560,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment); MeasurementEditingContext editingContext = new MeasurementEditingContext(); editingContext.setGpxData(gpxData); - if (useAppMode) { - editingContext.setAppMode(app.getRoutingHelper().getAppMode()); - } + editingContext.setAppMode(app.getRoutingHelper().getAppMode()); MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true); } }