Merge pull request #10851 from osmandapp/dont_overwrite_unchanged_gpx

Don't overwrite GPX file if it's there were no changes
This commit is contained in:
Vitaliy 2021-02-14 00:57:44 +02:00 committed by GitHub
commit c7a4624faa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -231,7 +231,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
final MapActivity mapActivity = (MapActivity) getActivity(); MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity == null) { if (mapActivity == null) {
return null; return null;
} }
@ -375,6 +375,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
mainView.findViewById(R.id.options_button).setOnClickListener(new OnClickListener() { mainView.findViewById(R.id.options_button).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
boolean trackSnappedToRoad = !editingCtx.isApproximationNeeded(); boolean trackSnappedToRoad = !editingCtx.isApproximationNeeded();
boolean addNewSegmentAllowed = editingCtx.isAddNewSegmentAllowed(); boolean addNewSegmentAllowed = editingCtx.isAddNewSegmentAllowed();
OptionsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), OptionsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
@ -383,6 +385,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
editingCtx.getAppMode().getStringKey() editingCtx.getAppMode().getStringKey()
); );
} }
}
}); });
undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button)); undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button));
@ -431,7 +434,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onSelectPoint(int selectedPointPos) { public void onSelectPoint(int selectedPointPos) {
if (selectedPointPos != -1) { MapActivity mapActivity = getMapActivity();
if (mapActivity != null && selectedPointPos != -1) {
openSelectedPointMenu(mapActivity); openSelectedPointMenu(mapActivity);
} }
} }
@ -440,7 +444,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
measurementLayer.setOnMeasureDistanceToCenterListener(new MeasurementToolLayer.OnMeasureDistanceToCenter() { measurementLayer.setOnMeasureDistanceToCenterListener(new MeasurementToolLayer.OnMeasureDistanceToCenter() {
@Override @Override
public void onMeasure(float distance, float bearing) { public void onMeasure(float distance, float bearing) {
String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication()); String distStr = OsmAndFormatter.getFormattedDistance(distance, app);
String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, app); String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, app);
distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr)); distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr));
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
@ -496,8 +500,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
public void onClick(View v) { public void onClick(View v) {
if (isFollowTrackMode()) { if (isFollowTrackMode()) {
startTrackNavigation(); startTrackNavigation();
} else { } else if (editingCtx.isNewData() || editingCtx.hasChanges()) {
saveChanges(FinalSaveAction.SHOW_SNACK_BAR_AND_CLOSE, false); saveChanges(FinalSaveAction.SHOW_SNACK_BAR_AND_CLOSE, false);
} else {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
dismiss(mapActivity, false);
}
} }
} }
}); });
@ -535,10 +544,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
configBtn.setOnClickListener(new OnClickListener() { configBtn.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
RouteOptionsBottomSheet.showInstance( RouteOptionsBottomSheet.showInstance(
mapActivity, MeasurementToolFragment.this, DialogMode.PLAN_ROUTE, mapActivity, MeasurementToolFragment.this, DialogMode.PLAN_ROUTE,
editingCtx.getAppMode().getStringKey()); editingCtx.getAppMode().getStringKey());
} }
}
}); });
initMeasurementMode(gpxData, savedInstanceState == null); initMeasurementMode(gpxData, savedInstanceState == null);
@ -931,7 +943,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
app.getTargetPointsHelper().updateRouteAndRefresh(true); app.getTargetPointsHelper().updateRouteAndRefresh(true);
app.getRoutingHelper().onSettingsChanged(true); app.getRoutingHelper().onSettingsChanged(true);
} else { } else {
mapActivity.getMapActions().stopNavigationActionConfirm(null , new Runnable() { mapActivity.getMapActions().stopNavigationActionConfirm(null, new Runnable() {
@Override @Override
public void run() { public void run() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();