diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index 25b5e993a2..2ea3a7d79b 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -763,6 +763,16 @@ public class GPXUtilities { 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 processRoutePoints() { List tpoints = new ArrayList(); if (routes.size() > 0) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index c6c27f542b..f9deb06a7a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1622,6 +1622,7 @@ public class OsmandSettings { } private Object objectToShow; + private boolean editObjectToShow; public Object getAndClearObjectToShow() { Object objectToShow = this.objectToShow; @@ -1629,6 +1630,12 @@ public class OsmandSettings { return objectToShow; } + public boolean getAndClearEditObjectToShow() { + boolean res = this.editObjectToShow; + this.editObjectToShow = false; + return res; + } + public int getMapZoomToShow() { 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) { setMapLocationToShow(latitude, longitude, zoom, null, false, null); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 3b180bf784..2385510a58 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -742,6 +742,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven LatLon latLonToShow = settings.getAndClearMapLocationToShow(); PointDescription mapLabelToShow = settings.getAndClearMapLabelToShow(latLonToShow); Object toShow = settings.getAndClearObjectToShow(); + boolean editToShow = settings.getAndClearEditObjectToShow(); int status = settings.isRouteToPointNavigateAndClear(); if (status != 0) { // 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 { mapContextMenu.show(latLonToShow, mapLabelToShow, toShow); } + if (editToShow) { + mapContextMenu.openEditor(); + } } else if (!latLonToShow.equals(cur)) { mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(), settings.getMapZoomToShow(), true); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index ca60983ccf..7e8a005fc4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -739,6 +739,19 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL 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() { mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(latLon, true, mapActivity.getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(), diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 404a6cd243..d0fbd3d54d 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -346,7 +346,6 @@ public class TrackPointFragment extends OsmandExpandableListFragment { @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (item.getItemId() == DELETE_ACTION_ID) { - mode.finish(); deleteItemsAction(); } return true; @@ -397,10 +396,14 @@ public class TrackPointFragment extends OsmandExpandableListFragment { if (gpx.showCurrentTrack) { savingTrackHelper.deletePointData(item.locationStart); } 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); boolean selected = app.getSelectedGpxHelper().getSelectedFileByPath(gpx.path) != null; if (selected) { @@ -522,7 +525,6 @@ public class TrackPointFragment extends OsmandExpandableListFragment { @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (item.getItemId() == SELECT_FAVORITES_ACTION_MODE_ID) { - mode.finish(); selectFavoritesImpl(); } return true; @@ -549,6 +551,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment { @Override public void onClick(DialogInterface dialog, int which) { + if (actionMode != null) { + actionMode.finish(); + } FavouritesDbHelper fdb = app.getFavorites(); for(GpxDisplayItem i : selectedItems) { if (i.locationStart != null) { @@ -794,7 +799,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), false, gpxItem.locationStart); - //todo: open edit dialog + settings.setEditObjectToShow(); MapActivity.launchMapActivityMoveToTop(getActivity()); return true; @@ -828,6 +833,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { ch.setVisibility(View.VISIBLE); ch.setChecked(selectedItems.contains(gpxItem)); row.findViewById(R.id.icon).setVisibility(View.GONE); + options.setVisibility(View.GONE); ch.setOnClickListener(new View.OnClickListener() { @Override