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() {
|
private String getSuggestedFileName() {
|
||||||
GpxData gpxData = editingCtx.getGpxData();
|
GpxData gpxData = editingCtx.getGpxData();
|
||||||
String displayedName;
|
String displayedName = null;
|
||||||
if (gpxData == 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());
|
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
||||||
displayedName = FileUtils.createUniqueFileName(requireMyApplication(), suggestedName, GPX_INDEX_DIR, GPX_FILE_EXT);
|
displayedName = FileUtils.createUniqueFileName(requireMyApplication(), suggestedName, GPX_INDEX_DIR, GPX_FILE_EXT);
|
||||||
} else {
|
} 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());
|
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);
|
fileName = FileUtils.createUniqueFileName(app, suggestedName, IndexConstants.GPX_INDEX_DIR, GPX_FILE_EXT);
|
||||||
} else {
|
} else {
|
||||||
fileName = AndroidUtils.trimExtension(new File(paramsBuilder.getFile().path).getName());
|
fileName = Algorithms.getFileNameWithoutExtension(new File(paramsBuilder.getFile().path).getName());
|
||||||
}
|
}
|
||||||
SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
ChooseRouteFragment.this, null, fileName,
|
ChooseRouteFragment.this, null, fileName,
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.TrkSegment;
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
|
@ -433,14 +434,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
if (card instanceof ImportTrackCard) {
|
if (card instanceof ImportTrackCard) {
|
||||||
importTrack();
|
importTrack();
|
||||||
} else if (card instanceof TrackEditCard) {
|
} else if (card instanceof TrackEditCard || card instanceof AttachTrackToRoadsCard) {
|
||||||
openPlanRoute(true);
|
openPlanRoute();
|
||||||
close();
|
close();
|
||||||
} else if (card instanceof SelectTrackCard) {
|
} else if (card instanceof SelectTrackCard) {
|
||||||
updateSelectionMode(true);
|
updateSelectionMode(true);
|
||||||
} else if (card instanceof AttachTrackToRoadsCard) {
|
|
||||||
openPlanRoute(false);
|
|
||||||
close();
|
|
||||||
} else if (card instanceof ReverseTrackCard
|
} else if (card instanceof ReverseTrackCard
|
||||||
|| card instanceof NavigateTrackOptionsCard) {
|
|| card instanceof NavigateTrackOptionsCard) {
|
||||||
updateMenu();
|
updateMenu();
|
||||||
|
@ -488,6 +486,14 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
this.gpxFile = gpxFile;
|
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);
|
mapActivity.getMapActions().setGPXRouteParams(gpxFile);
|
||||||
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||||
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
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();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && gpxFile != null) {
|
if (mapActivity != null && gpxFile != null) {
|
||||||
editingTrack = true;
|
editingTrack = true;
|
||||||
|
@ -554,9 +560,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
GpxData gpxData = new GpxData(gpxFile, rect, actionType, segment);
|
||||||
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
MeasurementEditingContext editingContext = new MeasurementEditingContext();
|
||||||
editingContext.setGpxData(gpxData);
|
editingContext.setGpxData(gpxData);
|
||||||
if (useAppMode) {
|
|
||||||
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
||||||
}
|
|
||||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue