Issue #6140 - Saving snapped to route GPX track to new track - reworked
(cherry picked from commit 2165e84816
)
This commit is contained in:
parent
450f005e5b
commit
264a8d3d75
3 changed files with 64 additions and 1 deletions
|
@ -594,6 +594,17 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void overwriteOldTrackOnClick() {
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
if (editingCtx.getPointsCount() > 0) {
|
||||
overwriteGpx(mapActivity);
|
||||
} else {
|
||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllOnClick() {
|
||||
editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer));
|
||||
|
@ -1116,6 +1127,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
saveExistingGpx(gpx, showOnMap, actionType, true);
|
||||
}
|
||||
|
||||
private void overwriteGpx(MapActivity mapActivity) {
|
||||
GPXFile gpx = editingCtx.getNewGpxData().getGpxFile();
|
||||
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpx.path);
|
||||
boolean showOnMap = selectedGpxFile != null;
|
||||
ActionType actionType = ActionType.OVERWRITE_SEGMENT;
|
||||
saveExistingGpx(gpx, showOnMap, actionType, true);
|
||||
}
|
||||
|
||||
private void saveAsGpx(final SaveType saveType) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
@ -1297,6 +1316,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
segment.points.addAll(points);
|
||||
gpx.replaceSegment(editingCtx.getNewGpxData().getTrkSegment(), segment);
|
||||
break;
|
||||
case OVERWRITE_SEGMENT:
|
||||
List<WptPt> snappedPoints = new ArrayList<>();
|
||||
snappedPoints.addAll(before.points);
|
||||
snappedPoints.addAll(after.points);
|
||||
TrkSegment segment1 = new TrkSegment();
|
||||
segment1.points.addAll(snappedPoints);
|
||||
gpx.replaceSegment(editingCtx.getNewGpxData().getTrkSegment(), segment1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
gpx.addRoutePoints(points);
|
||||
|
|
|
@ -8,7 +8,8 @@ public class NewGpxData {
|
|||
public enum ActionType {
|
||||
ADD_SEGMENT,
|
||||
ADD_ROUTE_POINTS,
|
||||
EDIT_SEGMENT
|
||||
EDIT_SEGMENT,
|
||||
OVERWRITE_SEGMENT
|
||||
}
|
||||
|
||||
private GPXUtilities.GPXFile gpxFile;
|
||||
|
|
|
@ -70,6 +70,39 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
})
|
||||
.create();
|
||||
items.add(saveAsNewSegmentItem);
|
||||
} else if (addLineMode) {
|
||||
|
||||
BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
.setTitle(getString(R.string.shared_string_save_as_gpx))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.saveAsNewTrackOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(saveAsNewTrackItem);
|
||||
|
||||
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
.setTitle("Overwrite GPX")
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.overwriteOldTrackOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(saveAsNewSegmentItem);
|
||||
} else {
|
||||
BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
|
@ -138,6 +171,8 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
|
||||
void addToTheTrackOnClick();
|
||||
|
||||
void overwriteOldTrackOnClick();
|
||||
|
||||
void clearAllOnClick();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue