Disable ability to add new points while GPX Approximation menu is using.

This commit is contained in:
Dima-1 2020-09-01 13:49:28 +03:00
parent fe36f0e8d4
commit f232395a71
3 changed files with 22 additions and 4 deletions

View file

@ -60,6 +60,7 @@ public class MeasurementEditingContext {
private WptPt originalPointToMove;
private boolean inAddPointMode;
private boolean inApproximationMode;
private int calculatedPairs;
private int pointsToCalculateSize;
private CalculationMode lastCalculationMode = WHOLE_TRACK;
@ -175,6 +176,15 @@ public class MeasurementEditingContext {
this.inAddPointMode = inAddPointMode;
}
public boolean isInApproximationMode() {
return inApproximationMode;
}
public void setInApproximationMode(boolean inApproximationMode) {
this.inApproximationMode = inApproximationMode;
}
@Nullable
GpxData getGpxData() {
return gpxData;

View file

@ -443,13 +443,18 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createStartPlanRouteListener());
} else if (!editingCtx.isNewData() && !editingCtx.hasRoutePoints() && !editingCtx.hasRoute() && editingCtx.getPointsCount() > 1) {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
showSnapTrackWarning(mapActivity);
}
}
return view;
}
private void showSnapTrackWarning(MapActivity mapActivity) {
editingCtx.setInApproximationMode(true);
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
}
public boolean isInEditMode() {
return !planRouteMode && !editingCtx.isNewData() && !directionMode;
}
@ -596,7 +601,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
: RouteBetweenPointsDialogMode.ALL,
editingCtx.getAppMode());
} else {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
showSnapTrackWarning(mapActivity);
}
}
}
@ -628,6 +633,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
case SnapTrackWarningBottomSheet.CANCEL_RESULT_CODE:
toolBarController.setSaveViewVisible(true);
directionMode = false;
editingCtx.setInApproximationMode(false);
updateToolbar();
break;
case SnapTrackWarningBottomSheet.CONTINUE_RESULT_CODE:
@ -693,7 +699,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
mapActions.enterRoutePlanningModeGivenGpx(gpx, appMode, null, null, true, true, MenuState.HEADER_ONLY);
} else {
directionMode = true;
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
showSnapTrackWarning(mapActivity);
}
}
}
@ -2041,6 +2047,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override
public void onApplyGpxApproximation() {
editingCtx.setInApproximationMode(false);
doAddOrMovePointCommonStuff();
if (directionMode) {
directionMode = false;
@ -2066,6 +2073,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override
public void onCancelGpxApproximation() {
editingCtx.getCommandManager().undo();
editingCtx.setInApproximationMode(false);
directionMode = false;
updateSnapToRoadControls();
updateToolbar();

View file

@ -102,7 +102,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
@Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
if (inMeasurementMode && editingCtx.getSelectedPointPosition() == -1) {
if (inMeasurementMode && !editingCtx.isInApproximationMode() && editingCtx.getSelectedPointPosition() == -1) {
if (!overlapped) {
selectPoint(point.x, point.y, true);
}