Fix gpx points screen

This commit is contained in:
Alexey Kulish 2017-03-02 17:01:44 +03:00
parent 89c6a62756
commit 77396ec27c
5 changed files with 49 additions and 5 deletions

View file

@ -763,6 +763,16 @@ public class GPXUtilities {
return points.remove(pt); return points.remove(pt);
} }
public boolean deleteRtePt(WptPt pt) {
modifiedTime = System.currentTimeMillis();
for (Route route : routes) {
if (route.points.remove(pt)) {
return true;
}
}
return false;
}
public List<TrkSegment> processRoutePoints() { public List<TrkSegment> processRoutePoints() {
List<TrkSegment> tpoints = new ArrayList<TrkSegment>(); List<TrkSegment> tpoints = new ArrayList<TrkSegment>();
if (routes.size() > 0) { if (routes.size() > 0) {

View file

@ -1622,6 +1622,7 @@ public class OsmandSettings {
} }
private Object objectToShow; private Object objectToShow;
private boolean editObjectToShow;
public Object getAndClearObjectToShow() { public Object getAndClearObjectToShow() {
Object objectToShow = this.objectToShow; Object objectToShow = this.objectToShow;
@ -1629,6 +1630,12 @@ public class OsmandSettings {
return objectToShow; return objectToShow;
} }
public boolean getAndClearEditObjectToShow() {
boolean res = this.editObjectToShow;
this.editObjectToShow = false;
return res;
}
public int getMapZoomToShow() { public int getMapZoomToShow() {
return settingsAPI.getInt(globalPreferences, MAP_ZOOM_TO_SHOW, 5); return settingsAPI.getInt(globalPreferences, MAP_ZOOM_TO_SHOW, 5);
} }
@ -1651,6 +1658,10 @@ public class OsmandSettings {
} }
} }
public void setEditObjectToShow() {
this.editObjectToShow = true;
}
public void setMapLocationToShow(double latitude, double longitude, int zoom) { public void setMapLocationToShow(double latitude, double longitude, int zoom) {
setMapLocationToShow(latitude, longitude, zoom, null, false, null); setMapLocationToShow(latitude, longitude, zoom, null, false, null);
} }

View file

@ -742,6 +742,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
LatLon latLonToShow = settings.getAndClearMapLocationToShow(); LatLon latLonToShow = settings.getAndClearMapLocationToShow();
PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow); PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow);
Object toShow = settings.getAndClearObjectToShow(); Object toShow = settings.getAndClearObjectToShow();
boolean editToShow = settings.getAndClearEditObjectToShow();
int status = settings.isRouteToPointNavigateAndClear(); int status = settings.isRouteToPointNavigateAndClear();
if (status != 0) { if (status != 0) {
// always enable and follow and let calculate it (i.e.GPS is not accessible in a garage) // always enable and follow and let calculate it (i.e.GPS is not accessible in a garage)
@ -786,6 +787,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} else { } else {
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow); mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
} }
if (editToShow) {
mapContextMenu.openEditor();
}
} else if (!latLonToShow.equals(cur)) { } else if (!latLonToShow.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),
latLonToShow.getLongitude(), settings.getMapZoomToShow(), true); latLonToShow.getLongitude(), settings.getMapZoomToShow(), true);

View file

@ -739,6 +739,19 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return dlg; return dlg;
} }
public boolean openEditor() {
if (object != null) {
if (object instanceof FavouritePoint) {
getFavoritePointEditor().edit((FavouritePoint) object);
return true;
} else if (object instanceof WptPt) {
getWptPtPointEditor().edit((WptPt) object);
return true;
}
}
return false;
}
public void addAsLastIntermediate() { public void addAsLastIntermediate() {
mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(latLon, mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(latLon,
true, mapActivity.getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(), true, mapActivity.getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(),

View file

@ -346,7 +346,6 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
@Override @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (item.getItemId() == DELETE_ACTION_ID) { if (item.getItemId() == DELETE_ACTION_ID) {
mode.finish();
deleteItemsAction(); deleteItemsAction();
} }
return true; return true;
@ -397,10 +396,14 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
if (gpx.showCurrentTrack) { if (gpx.showCurrentTrack) {
savingTrackHelper.deletePointData(item.locationStart); savingTrackHelper.deletePointData(item.locationStart);
} else { } else {
gpx.deleteWptPt(item.locationStart); if (item.group.getType() == GpxDisplayItemType.TRACK_POINTS) {
gpx.deleteWptPt(item.locationStart);
} else if (item.group.getType() == GpxDisplayItemType.TRACK_ROUTE_POINTS) {
gpx.deleteRtePt(item.locationStart);
}
} }
} }
if (gpx.showCurrentTrack) { if (!gpx.showCurrentTrack) {
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app); GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
boolean selected = app.getSelectedGpxHelper().getSelectedFileByPath(gpx.path) != null; boolean selected = app.getSelectedGpxHelper().getSelectedFileByPath(gpx.path) != null;
if (selected) { if (selected) {
@ -522,7 +525,6 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
@Override @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (item.getItemId() == SELECT_FAVORITES_ACTION_MODE_ID) { if (item.getItemId() == SELECT_FAVORITES_ACTION_MODE_ID) {
mode.finish();
selectFavoritesImpl(); selectFavoritesImpl();
} }
return true; return true;
@ -549,6 +551,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (actionMode != null) {
actionMode.finish();
}
FavouritesDbHelper fdb = app.getFavorites(); FavouritesDbHelper fdb = app.getFavorites();
for(GpxDisplayItem i : selectedItems) { for(GpxDisplayItem i : selectedItems) {
if (i.locationStart != null) { if (i.locationStart != null) {
@ -794,7 +799,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name),
false, false,
gpxItem.locationStart); gpxItem.locationStart);
//todo: open edit dialog settings.setEditObjectToShow();
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
return true; return true;
@ -828,6 +833,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
ch.setVisibility(View.VISIBLE); ch.setVisibility(View.VISIBLE);
ch.setChecked(selectedItems.contains(gpxItem)); ch.setChecked(selectedItems.contains(gpxItem));
row.findViewById(R.id.icon).setVisibility(View.GONE); row.findViewById(R.id.icon).setVisibility(View.GONE);
options.setVisibility(View.GONE);
ch.setOnClickListener(new View.OnClickListener() { ch.setOnClickListener(new View.OnClickListener() {
@Override @Override