Show attach roads dialog from follow track

This commit is contained in:
Vitaliy 2020-08-17 23:35:51 +03:00
parent 26d88ccef2
commit ba3fe6f35c
2 changed files with 22 additions and 7 deletions

View file

@ -131,6 +131,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private boolean progressBarVisible;
private boolean pointsListOpened;
private boolean planRouteMode = false;
private boolean attachToRoads;
private Boolean saved;
private boolean portrait;
private boolean nightMode;
@ -158,6 +159,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
this.planRouteMode = planRouteMode;
}
public void setAttachToRoads(boolean attachToRoads) {
this.attachToRoads = attachToRoads;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@ -460,10 +465,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
initMeasurementMode(newGpxData);
if (editingCtx.isNewData() && planRouteMode && savedInstanceState == null) {
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createStartPlanRouteListener());
if (savedInstanceState == null) {
if (editingCtx.isNewData() && planRouteMode) {
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createStartPlanRouteListener());
} else if (attachToRoads && !(editingCtx.isNewData() || editingCtx.hasRoutePoints() || editingCtx.isInSnapToRoadMode())) {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
}
}
return view;
}
@ -1793,10 +1803,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return showFragment(fragment, fragmentManager);
}
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx, boolean planRoute) {
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
boolean planRoute, boolean attachToRoads) {
MeasurementToolFragment fragment = new MeasurementToolFragment();
fragment.setEditingCtx(editingCtx);
fragment.setPlanRouteMode(planRoute);
fragment.setAttachToRoads(attachToRoads);
return showFragment(fragment, fragmentManager);
}

View file

@ -345,10 +345,13 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
if (card instanceof ImportTrackCard) {
importTrack();
} else if (card instanceof TrackEditCard) {
editTrack();
openPlanRoute(false);
close();
} else if (card instanceof SelectTrackCard) {
updateSelectionMode(true);
} else if (card instanceof AttachTrackToRoadsCard) {
openPlanRoute(true);
close();
} else if (card instanceof ReverseTrackCard
|| card instanceof NavigateTrackOptionsCard) {
updateMenu();
@ -446,7 +449,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
}
}
public void editTrack() {
public void openPlanRoute(boolean attachToRoads) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && gpxFile != null) {
QuadRect rect = gpxFile.getRect();
@ -456,7 +459,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
MeasurementEditingContext editingContext = new MeasurementEditingContext();
editingContext.setNewGpxData(newGpxData);
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true, attachToRoads);
}
}