Minor fixes

This commit is contained in:
Vitaliy 2020-08-20 13:15:06 +03:00
parent fde90d40d4
commit f3f7916fbc
8 changed files with 27 additions and 31 deletions

View file

@ -1290,7 +1290,7 @@ public class GPXUtilities {
return pt;
}
public TrkSegment getTrkSegment() {
public TrkSegment getNonEmptyTrkSegment() {
for (GPXUtilities.Track t : tracks) {
for (TrkSegment s : t.segments) {
if (s.points.size() > 0) {

View file

@ -47,7 +47,7 @@ final class MapLayerMenuListener extends OnRowItemClick {
GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
List<SelectedGpxFile> selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles();
List<String> files = GpxUiHelper.getSelectedTrackNames(mapActivity.getMyApplication());
List<String> files = GpxUiHelper.getSelectedTrackPaths(mapActivity.getMyApplication());
if (selectedGpxFiles.isEmpty()) {
Map<GPXFile, Long> fls = selectedGpxHelper.getSelectedGpxFilesBackUp();
for (Map.Entry<GPXFile, Long> f : fls.entrySet()) {

View file

@ -810,7 +810,7 @@ public class GpxUiHelper {
}
}
public static List<String> getSelectedTrackNames(OsmandApplication app) {
public static List<String> getSelectedTrackPaths(OsmandApplication app) {
List<String> trackNames = new ArrayList<>();
for (SelectedGpxFile file : app.getSelectedGpxHelper().getSelectedGPXFiles()) {
trackNames.add(file.getGpxFile().path);

View file

@ -117,7 +117,7 @@ public class ImportHelper {
public interface OnGpxImportCompleteListener {
void onImportComplete(boolean success);
void onSavingComplete(boolean success, GPXFile result);
void onSaveComplete(boolean success, GPXFile result);
}
public ImportHelper(final AppCompatActivity activity, final OsmandApplication app, final OsmandMapTileView mapView) {
@ -1094,7 +1094,7 @@ public class ImportHelper {
boolean success = Algorithms.isEmpty(warning);
if (gpxImportCompleteListener != null) {
gpxImportCompleteListener.onSavingComplete(success, result);
gpxImportCompleteListener.onSaveComplete(success, result);
}
if (success) {
if (showInDetailsActivity) {

View file

@ -131,7 +131,6 @@ 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;
@ -159,10 +158,6 @@ 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,
@ -469,7 +464,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
if (editingCtx.isNewData() && planRouteMode) {
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createStartPlanRouteListener());
} else if (attachToRoads && !(editingCtx.isNewData() || editingCtx.hasRoutePoints() || editingCtx.isInSnapToRoadMode())) {
} else if (!(editingCtx.isNewData() || editingCtx.hasRoutePoints() || editingCtx.isInSnapToRoadMode())) {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
}
}
@ -892,7 +887,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
public void addNewGpxData(GPXFile gpxFile) {
QuadRect rect = gpxFile.getRect();
TrkSegment segment = gpxFile.getTrkSegment();
TrkSegment segment = gpxFile.getNonEmptyTrkSegment();
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
@ -1803,12 +1798,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return showFragment(fragment, fragmentManager);
}
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
boolean planRoute, boolean attachToRoads) {
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx, boolean planRoute) {
MeasurementToolFragment fragment = new MeasurementToolFragment();
fragment.setEditingCtx(editingCtx);
fragment.setPlanRouteMode(planRoute);
fragment.setAttachToRoads(attachToRoads);
return showFragment(fragment, fragmentManager);
}

View file

@ -172,7 +172,7 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
}
@Override
public void onSavingComplete(boolean success, GPXUtilities.GPXFile result) {
public void onSaveComplete(boolean success, GPXUtilities.GPXFile result) {
}
});

View file

@ -136,7 +136,7 @@ public class FavoritesActivity extends TabActivity {
}
@Override
public void onSavingComplete(boolean success, GPXUtilities.GPXFile result) {
public void onSaveComplete(boolean success, GPXUtilities.GPXFile result) {
}
});

View file

@ -21,8 +21,8 @@ import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.data.QuadRect;
@ -226,7 +226,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
List<String> selectedTrackNames = GpxUiHelper.getSelectedTrackNames(app);
List<String> selectedTrackNames = GpxUiHelper.getSelectedTrackPaths(app);
List<GPXInfo> list = GpxUiHelper.getSortedGPXFilesInfo(dir, selectedTrackNames, false);
if (list.size() > 0) {
String defaultCategory = app.getString(R.string.shared_string_all);
@ -346,12 +346,12 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
if (card instanceof ImportTrackCard) {
importTrack();
} else if (card instanceof TrackEditCard) {
openPlanRoute(false);
openPlanRoute(true);
close();
} else if (card instanceof SelectTrackCard) {
updateSelectionMode(true);
} else if (card instanceof AttachTrackToRoadsCard) {
openPlanRoute(true);
openPlanRoute(false);
close();
} else if (card instanceof ReverseTrackCard
|| card instanceof NavigateTrackOptionsCard) {
@ -439,7 +439,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
}
@Override
public void onSavingComplete(boolean success, GPXFile result) {
public void onSaveComplete(boolean success, GPXFile result) {
if (success) {
selectTrackToFollow(result);
updateSelectionMode(false);
@ -456,17 +456,20 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
}
}
public void openPlanRoute(boolean attachToRoads) {
public void openPlanRoute(boolean useAppMode) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && gpxFile != null) {
QuadRect rect = gpxFile.getRect();
GPXUtilities.TrkSegment segment = gpxFile.getTrkSegment();
TrkSegment segment = gpxFile.getNonEmptyTrkSegment();
ActionType actionType = segment == null ? ActionType.ADD_ROUTE_POINTS : ActionType.EDIT_SEGMENT;
NewGpxData newGpxData = new NewGpxData(gpxFile, rect, actionType, segment);
MeasurementEditingContext editingContext = new MeasurementEditingContext();
editingContext.setNewGpxData(newGpxData);
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true, attachToRoads);
if (useAppMode) {
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
}
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
}
}