Fix track name and select app mode from gpx in follow track
This commit is contained in:
parent
a833524875
commit
bd10c798f8
3 changed files with 24 additions and 12 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<WptPt> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue