From 2838e408a964e16719439c8eadabd767a1a1c534 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 6 Apr 2021 16:30:35 +0300 Subject: [PATCH 1/4] Open track menu on short click --- .../net/osmand/plus/views/layers/GPXLayer.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 69266746a9..ee4f2b5a5a 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -44,10 +44,10 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.PointImageDrawable; +import net.osmand.plus.itinerary.ItineraryGroup; import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.mapmarkers.MapMarker; -import net.osmand.plus.itinerary.ItineraryGroup; import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.render.OsmandRenderer; import net.osmand.plus.render.OsmandRenderer.RenderingContext; @@ -56,6 +56,7 @@ import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.track.GradientScaleType; import net.osmand.plus.track.SaveGpxAsyncTask; import net.osmand.plus.track.TrackDrawInfo; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.Renderable; @@ -1098,8 +1099,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } @Override - public boolean runExclusiveAction(Object o, boolean unknownLocation) { - return false; + public boolean runExclusiveAction(Object object, boolean unknownLocation) { + if (unknownLocation || !(object instanceof SelectedGpxPoint)) { + return false; + } + MapActivity mapActivity = (MapActivity) view.getContext(); + SelectedGpxPoint point = (SelectedGpxPoint) object; + WptPt wptPt = point.getSelectedPoint(); + TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), + new LatLon(wptPt.lat, wptPt.lon), null, null); + return true; } @Override From 637f9f957cc673811f2ea031214b4a7b4889cf8f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 8 Apr 2021 14:10:16 +0300 Subject: [PATCH 2/4] Open track point menu on long click --- .../plus/audionotes/AudioNotesLayer.java | 2 +- .../plus/mapillary/MapillaryVectorLayer.java | 2 +- .../measurementtool/MeasurementToolLayer.java | 2 +- .../net/osmand/plus/osmedit/OsmBugsLayer.java | 2 +- .../osmand/plus/osmedit/OsmEditsLayer.java | 2 +- .../osmand/plus/track/TrackMenuFragment.java | 2 +- .../plus/views/layers/AidlMapLayer.java | 2 +- .../plus/views/layers/ContextMenuLayer.java | 8 +++--- .../views/layers/DownloadedRegionsLayer.java | 2 +- .../plus/views/layers/FavouritesLayer.java | 2 +- .../osmand/plus/views/layers/GPXLayer.java | 26 +++++++++++++++++-- .../views/layers/ImpassableRoadsLayer.java | 2 +- .../plus/views/layers/MapMarkersLayer.java | 2 +- .../osmand/plus/views/layers/POIMapLayer.java | 2 +- .../plus/views/layers/PointLocationLayer.java | 2 +- .../views/layers/PointNavigationLayer.java | 2 +- .../osmand/plus/views/layers/RouteLayer.java | 2 +- .../views/layers/TransportStopsLayer.java | 2 +- 18 files changed, 44 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index ea0694aa8d..96ce49d8db 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -155,7 +155,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java index 51c12f07aa..09d7e7b7e4 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java @@ -316,7 +316,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index 9d3f8812c4..7e6a1439ee 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -502,7 +502,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return isInMeasurementMode(); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index f3865ad467..013ba37d5b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -453,7 +453,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index 59c07afbaa..a0fe1c1af2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -180,7 +180,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index e1a620269d..2d5c26313e 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -750,7 +750,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public int getStatusBarColorId() { - if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) { + if (getView() != null && getViewY() <= getFullScreenTopPosY() || !isPortrait()) { return isNightMode() ? R.color.status_bar_color_dark : R.color.status_bar_color_light; } return -1; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java index df110a14cb..8107943408 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java @@ -267,7 +267,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java index 5acf8999ba..4c2a63db9e 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java @@ -320,7 +320,7 @@ public class ContextMenuLayer extends OsmandMapLayer { @Override @RequiresPermission(Manifest.permission.VIBRATE) public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) { - if (disableLongPressOnMap()) { + if (disableLongPressOnMap(point, tileBox)) { return false; } if (pressedContextMarker(tileBox, point.x, point.y)) { @@ -877,7 +877,7 @@ public class ContextMenuLayer extends OsmandMapLayer { return res; } - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode || activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.waypointsVisible || MapRouteInfoMenu.followTrackVisible) { @@ -886,7 +886,7 @@ public class ContextMenuLayer extends OsmandMapLayer { boolean res = false; for (OsmandMapLayer lt : view.getLayers()) { if (lt instanceof IContextMenuProvider) { - if (((IContextMenuProvider) lt).disableLongPressOnMap()) { + if (((IContextMenuProvider) lt).disableLongPressOnMap(point, tileBox)) { res = true; break; } @@ -1101,7 +1101,7 @@ public class ContextMenuLayer extends OsmandMapLayer { boolean disableSingleTap(); - boolean disableLongPressOnMap(); + boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox); boolean isObjectClickable(Object o); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java index 2993a90fef..a624b8412c 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java @@ -566,7 +566,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java index c2c00bcfe5..5e4f95f136 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java @@ -213,7 +213,7 @@ public class FavouritesLayer extends OsmandMapLayer implements IContextMenuProvi } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index ee4f2b5a5a..203e446c15 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -1089,8 +1089,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } @Override - public boolean disableLongPressOnMap() { - return isInTrackAppearanceMode(); + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { + if (isInTrackAppearanceMode()) { + return true; + } + if (tileBox.getZoom() >= START_ZOOM) { + List res = new ArrayList<>(); + getTracksFromPoint(tileBox, point, res); + return !Algorithms.isEmpty(res); + } + return false; } @Override @@ -1143,6 +1151,20 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM @Override public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) { + if (tileBox.getZoom() >= START_ZOOM) { + List trackPoints = new ArrayList<>(); + getTracksFromPoint(tileBox, point, trackPoints); + + if (!Algorithms.isEmpty(trackPoints)) { + MapActivity mapActivity = (MapActivity) view.getContext(); + SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) trackPoints.get(0); + WptPt wptPt = selectedGpxPoint.getSelectedPoint(); + PointDescription description = getObjectName(selectedGpxPoint); + ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer(); + contextMenuLayer.showContextMenu(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint, this); + return true; + } + } return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java index 98a6bcb0dd..09f84ba6e3 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java @@ -128,7 +128,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java index 5c58dadd0d..a8d79b4519 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java @@ -497,7 +497,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return inPlanRouteMode; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java index 85b538b6c6..c264b67b0f 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java @@ -379,7 +379,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java index 3c60b1af49..2021f5d32f 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java @@ -226,7 +226,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java index e4398eab33..26899516e3 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java @@ -172,7 +172,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 71c74579a3..f73a44f0ba 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -802,7 +802,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return isInRouteLineAppearanceMode(); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java index ba219f26b6..082b8998df 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java @@ -294,7 +294,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } @Override - public boolean disableLongPressOnMap() { + public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) { return false; } From 733d152956f83c2ab8ce35f9b6ea51b326fc1907 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 8 Apr 2021 14:22:55 +0300 Subject: [PATCH 3/4] Fix map adjusting for track menu --- .../src/net/osmand/plus/track/TrackMenuFragment.java | 12 +++++++----- .../src/net/osmand/plus/views/layers/GPXLayer.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 2d5c26313e..dcb907f483 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -165,7 +165,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card private int menuTitleHeight; private int menuHeaderHeight; private int toolbarHeightPx; - private boolean mapPositionAdjusted; + private boolean adjustMapPosition = true; public enum TrackMenuType { @@ -596,7 +596,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card boolean backButtonVisible = !Algorithms.isEmpty(returnScreenName) && currentMenuState == MenuState.HALF_SCREEN; AndroidUiHelper.updateVisibility(backButtonContainer, backButtonVisible); } - if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) { + if (currentMenuState != MenuState.FULL_SCREEN && (changed || adjustMapPosition)) { adjustMapPosition(getMenuStatePosY(currentMenuState)); } } @@ -971,7 +971,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (r.left != 0 && r.right != 0) { mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0); } - mapPositionAdjusted = true; + adjustMapPosition = false; } } @@ -1318,7 +1318,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public boolean processResult(SelectedGpxFile selectedGpxFile) { MapActivity mapActivity = mapActivityRef.get(); if (mapActivity != null && selectedGpxFile != null) { - showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName, callingFragmentTag); + showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName, callingFragmentTag, true); } return true; } @@ -1329,7 +1329,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @NonNull SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon, @Nullable String returnScreenName, - @Nullable String callingFragmentTag) { + @Nullable String callingFragmentTag, + boolean adjustMapPosition) { try { Bundle args = new Bundle(); args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY); @@ -1340,6 +1341,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card fragment.setSelectedGpxFile(selectedGpxFile); fragment.setReturnScreenName(returnScreenName); fragment.setCallingFragmentTag(callingFragmentTag); + fragment.adjustMapPosition = adjustMapPosition; if (latLon != null) { fragment.setLatLon(latLon); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 203e446c15..2171c4fc82 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -1115,7 +1115,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM SelectedGpxPoint point = (SelectedGpxPoint) object; WptPt wptPt = point.getSelectedPoint(); TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), - new LatLon(wptPt.lat, wptPt.lon), null, null); + new LatLon(wptPt.lat, wptPt.lon), null, null, false); return true; } From b1d3ebbaf1cba883e92098cd0eb66070f6073d94 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 8 Apr 2021 17:28:26 +0300 Subject: [PATCH 4/4] Display pin of point on track menu graphs --- .../net/osmand/plus/helpers/IntentHelper.java | 4 +- .../builders/SelectedGpxMenuBuilder.java | 8 +-- .../SelectedGpxMenuController.java | 19 +++++-- .../controllers/WptPtMenuController.java | 5 +- .../other/TrackDetailsMenu.java | 25 +++------- .../plus/myplaces/GPXItemPagerAdapter.java | 49 ++++++++----------- .../plus/search/QuickSearchListFragment.java | 2 +- .../net/osmand/plus/track/SegmentsCard.java | 23 ++++++++- .../osmand/plus/track/TrackMenuFragment.java | 28 ++++++++--- .../osmand/plus/views/layers/GPXLayer.java | 6 +-- 10 files changed, 96 insertions(+), 73 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java index ba48fe6899..6fce7b78a6 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java @@ -18,8 +18,8 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginsFragment; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; -import net.osmand.plus.mapmarkers.MapMarkersDialogFragment; import net.osmand.plus.itinerary.ItineraryGroup; +import net.osmand.plus.mapmarkers.MapMarkersDialogFragment; import net.osmand.plus.mapsource.EditMapSourceDialogFragment; import net.osmand.plus.openplacereviews.OPRConstants; import net.osmand.plus.openplacereviews.OprAuthHelper.OprAuthorizationListener; @@ -259,7 +259,7 @@ public class IntentHelper { String path = intent.getStringExtra(TRACK_FILE_NAME); String name = intent.getStringExtra(RETURN_SCREEN_NAME); boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false); - TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null, name, null); + TrackMenuFragment.showInstance(mapActivity, path, currentRecording, name, null); mapActivity.setIntent(null); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/SelectedGpxMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/SelectedGpxMenuBuilder.java index e4c2bc71ed..a87e35590e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/SelectedGpxMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/SelectedGpxMenuBuilder.java @@ -153,9 +153,11 @@ public class SelectedGpxMenuBuilder extends MenuBuilder { OsmAndFormatter.getFormattedSpeed((float) selectedPoint.speed, app), 0, null, false, null, false, 0, false, false, false, null, false); } - buildRow(view, getThemedIcon(R.drawable.ic_action_relative_bearing), null, app.getString(R.string.shared_string_bearing), - OsmAndFormatter.getFormattedAzimuth(selectedGpxPoint.getBearing(), app), 0, null, - false, null, false, 0, false, false, false, null, false); + if (!Float.isNaN(selectedGpxPoint.getBearing())) { + buildRow(view, getThemedIcon(R.drawable.ic_action_relative_bearing), null, app.getString(R.string.shared_string_bearing), + OsmAndFormatter.getFormattedAzimuth(selectedGpxPoint.getBearing(), app), 0, null, + false, null, false, 0, false, false, false, null, false); + } } private void buildCategoryView(View view, String name) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 80dd39f959..76b8ff1c7b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -43,11 +43,8 @@ public class SelectedGpxMenuController extends MenuController { @Override public void buttonPressed() { mapContextMenu.close(); - WptPt wptPt = selectedGpxPoint.selectedPoint; - LatLon latLon = new LatLon(wptPt.lat, wptPt.lon); SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); - String path = selectedGpxFile.getGpxFile().path; - TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon, null, null); + TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, selectedGpxPoint, null, null, false); } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); @@ -215,11 +212,15 @@ public class SelectedGpxMenuController extends MenuController { public static class SelectedGpxPoint { + private final WptPt prevPoint; + private final WptPt nextPoint; private final WptPt selectedPoint; private final SelectedGpxFile selectedGpxFile; private final float bearing; - public SelectedGpxPoint(SelectedGpxFile selectedGpxFile, WptPt selectedPoint, float bearing) { + public SelectedGpxPoint(SelectedGpxFile selectedGpxFile, WptPt selectedPoint, WptPt prevPoint, WptPt nextPoint, float bearing) { + this.prevPoint = prevPoint; + this.nextPoint = nextPoint; this.selectedPoint = selectedPoint; this.selectedGpxFile = selectedGpxFile; this.bearing = bearing; @@ -236,5 +237,13 @@ public class SelectedGpxMenuController extends MenuController { public float getBearing() { return bearing; } + + public WptPt getPrevPoint() { + return prevPoint; + } + + public WptPt getNextPoint() { + return nextPoint; + } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index d9ad62cad9..95a266563c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -17,6 +17,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; +import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.track.TrackMenuFragment; @@ -49,8 +50,8 @@ public class WptPtMenuController extends MenuController { GpxSelectionHelper selectionHelper = mapActivity.getMyApplication().getSelectedGpxHelper(); SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt); if (selectedGpxFile != null) { - String path = selectedGpxFile.getGpxFile().path; - TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat), null, null); + SelectedGpxPoint gpxPoint = new SelectedGpxPoint(selectedGpxFile, wpt, null, null, Float.NaN); + TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, gpxPoint, null, null, false); } } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index bf86142181..4ee35b6b36 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -23,7 +23,6 @@ import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener; import net.osmand.AndroidUtils; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.TrkSegment; @@ -43,6 +42,7 @@ import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet; +import net.osmand.plus.myplaces.GPXItemPagerAdapter; import net.osmand.plus.views.layers.GPXLayer; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; @@ -299,18 +299,7 @@ public class TrackDetailsMenu { List ds = lineData != null ? lineData.getDataSets() : null; GpxDisplayItem gpxItem = getGpxItem(); if (ds != null && ds.size() > 0 && gpxItem != null) { - for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) { - for (TrkSegment s : t.segments) { - if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) { - segment = s; - break; - } - } - if (segment != null) { - break; - } - } - this.segment = segment; + this.segment = GPXItemPagerAdapter.getSegmentForAnalysis(gpxItem, gpxItem.analysis); } } return segment; @@ -755,21 +744,21 @@ public class TrackDetailsMenu { final List availableTypes = new ArrayList<>(); boolean hasSlopeChart = false; if (analysis.hasElevationData) { - availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE}); + availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE}); if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME && gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) { - availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SLOPE}); + availableTypes.add(new GPXDataSetType[] {GPXDataSetType.SLOPE}); } } if (analysis.hasSpeedData) { - availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SPEED}); + availableTypes.add(new GPXDataSetType[] {GPXDataSetType.SPEED}); } if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME && gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) { - availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE}); + availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE}); } if (analysis.hasElevationData && analysis.hasSpeedData) { - availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED}); + availableTypes.add(new GPXDataSetType[] {GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED}); } for (GPXDataSetType t : gpxItem.chartTypes) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java index 6f5083d8b2..38519a76fe 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/GPXItemPagerAdapter.java @@ -26,7 +26,6 @@ import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener; import net.osmand.AndroidUtils; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.Track; @@ -34,7 +33,6 @@ import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -52,7 +50,6 @@ import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionI import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; -import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -181,17 +178,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid LineData lineData = chart.getLineData(); List ds = lineData != null ? lineData.getDataSets() : null; if (ds != null && ds.size() > 0) { - for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) { - for (TrkSegment s : t.segments) { - if (s.points.size() > 0 && s.points.get(0).equals(analysis.locationStart)) { - segment = s; - break; - } - } - if (segment != null) { - break; - } - } + segment = getSegmentForAnalysis(gpxItem, analysis); } } return segment; @@ -741,6 +728,14 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid } if (gpxItem.chartHighlightPos != -1) { chart.highlightValue(gpxItem.chartHighlightPos, 0); + } else if (gpxItem.locationOnMap != null) { + LineData lineData = chart.getLineData(); + List ds = lineData != null ? lineData.getDataSets() : null; + if (ds != null && ds.size() > 0) { + OrderedLineDataSet dataSet = (OrderedLineDataSet) ds.get(0); + gpxItem.chartHighlightPos = (float) (gpxItem.locationOnMap.distance / dataSet.getDivX()); + chart.highlightValue(gpxItem.chartHighlightPos, 0); + } } } else { chart.highlightValue(null); @@ -818,18 +813,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid gpxItem.chartTypes[i] = orderedDataSet.getDataSetType(); } if (gpxItem.chartHighlightPos != -1) { - TrkSegment segment = null; - for (Track t : gpxItem.group.getGpx().tracks) { - for (TrkSegment s : t.segments) { - if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) { - segment = s; - break; - } - } - if (segment != null) { - break; - } - } + TrkSegment segment = getSegmentForAnalysis(gpxItem, gpxItem.analysis); if (segment != null) { OrderedLineDataSet dataSet = (OrderedLineDataSet) dataSets.get(0); float distance = gpxItem.chartHighlightPos * dataSet.getDivX(); @@ -849,7 +833,16 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid } } - private void openSplitIntervalScreen() { - actionsListener.openSplitInterval(gpxItem, getTrkSegment()); + public static TrkSegment getSegmentForAnalysis(GpxDisplayItem gpxItem, GPXTrackAnalysis analysis) { + for (Track track : gpxItem.group.getGpx().tracks) { + for (TrkSegment segment : track.segments) { + int size = segment.points.size(); + if (size > 0 && segment.points.get(0).equals(analysis.locationStart) + && segment.points.get(size - 1).equals(analysis.locationEnd)) { + return segment; + } + } + } + return null; } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index 89e918284c..410f011154 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -306,7 +306,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo); File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxInfo.getFileName()); String path = file.getAbsolutePath(); - TrackMenuFragment.showInstance(mapActivity, path, false, null, null, QuickSearchDialogFragment.TAG); + TrackMenuFragment.showInstance(mapActivity, path, false, null, QuickSearchDialogFragment.TAG); dialogFragment.dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java index a3ed324543..6cddd3ffec 100644 --- a/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/SegmentsCard.java @@ -4,11 +4,14 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import net.osmand.GPXUtilities.TrkSegment; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; import net.osmand.plus.myplaces.GPXItemPagerAdapter; import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.myplaces.SegmentGPXAdapter; @@ -23,12 +26,14 @@ public class SegmentsCard extends BaseCard { private TrackDisplayHelper displayHelper; private GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}; private SegmentActionsListener listener; + private SelectedGpxPoint gpxPoint; public SegmentsCard(@NonNull MapActivity mapActivity, @NonNull TrackDisplayHelper displayHelper, - @NonNull SegmentActionsListener listener) { + @Nullable SelectedGpxPoint gpxPoint, @NonNull SegmentActionsListener listener) { super(mapActivity); - this.displayHelper = displayHelper; this.listener = listener; + this.displayHelper = displayHelper; + this.gpxPoint = gpxPoint; } @Override @@ -42,6 +47,8 @@ public class SegmentsCard extends BaseCard { container.removeAllViews(); List items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)); for (GpxDisplayItem displayItem : items) { + updateLocationOnMap(displayItem); + View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, container, listener, nightMode); WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager); @@ -53,4 +60,16 @@ public class SegmentsCard extends BaseCard { container.addView(segmentView); } } + + private void updateLocationOnMap(GpxDisplayItem item) { + if (gpxPoint != null) { + TrkSegment segment = GPXItemPagerAdapter.getSegmentForAnalysis(item, item.analysis); + if (segment != null && (segment.points.contains(gpxPoint.getSelectedPoint()) + || segment.points.contains(gpxPoint.getPrevPoint()) + && segment.points.contains(gpxPoint.getNextPoint()))) { + item.locationOnMap = gpxPoint.getSelectedPoint(); + listener.onPointSelected(segment, item.locationOnMap.lat, item.locationOnMap.lon); + } + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index dcb907f483..4e5e6f6e0c 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -39,6 +39,7 @@ import net.osmand.FileUtils; import net.osmand.FileUtils.RenameCallback; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.TrkSegment; +import net.osmand.GPXUtilities.WptPt; import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.data.LatLon; @@ -66,6 +67,7 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.OpenGpxDetailsTask; +import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; import net.osmand.plus.measurementtool.GpxData; @@ -154,6 +156,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card private String gpxTitle; private String returnScreenName; private String callingFragmentTag; + private SelectedGpxPoint gpxPoint; private TrackChartPoints trackChartPoints; private Float heading; @@ -320,6 +323,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card this.callingFragmentTag = callingFragmentTag; } + public void setGpxPoint(SelectedGpxPoint point) { + this.gpxPoint = point; + } + + public void setAdjustMapPosition(boolean adjustMapPosition) { + this.adjustMapPosition = adjustMapPosition; + } + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); @@ -506,7 +517,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } cardsContainer.addView(segmentsCard.getView()); } else { - segmentsCard = new SegmentsCard(mapActivity, displayHelper, this); + segmentsCard = new SegmentsCard(mapActivity, displayHelper, gpxPoint, this); segmentsCard.setListener(this); cardsContainer.addView(segmentsCard.build(mapActivity)); } @@ -1258,7 +1269,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card boolean currentRecording = file == null; String path = file != null ? file.getAbsolutePath() : null; if (context instanceof MapActivity) { - TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null, null); + TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null); } else { Bundle bundle = new Bundle(); bundle.putString(TRACK_FILE_NAME, path); @@ -1309,7 +1320,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public static void showInstance(@NonNull MapActivity mapActivity, @Nullable String path, boolean showCurrentTrack, - @Nullable final LatLon latLon, @Nullable final String returnScreenName, @Nullable final String callingFragmentTag) { final WeakReference mapActivityRef = new WeakReference<>(mapActivity); @@ -1318,7 +1328,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public boolean processResult(SelectedGpxFile selectedGpxFile) { MapActivity mapActivity = mapActivityRef.get(); if (mapActivity != null && selectedGpxFile != null) { - showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName, callingFragmentTag, true); + showInstance(mapActivity, selectedGpxFile, null, returnScreenName, callingFragmentTag, true); } return true; } @@ -1327,7 +1337,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile, - @Nullable LatLon latLon, + @Nullable SelectedGpxPoint gpxPoint, @Nullable String returnScreenName, @Nullable String callingFragmentTag, boolean adjustMapPosition) { @@ -1341,10 +1351,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card fragment.setSelectedGpxFile(selectedGpxFile); fragment.setReturnScreenName(returnScreenName); fragment.setCallingFragmentTag(callingFragmentTag); - fragment.adjustMapPosition = adjustMapPosition; + fragment.setAdjustMapPosition(adjustMapPosition); - if (latLon != null) { - fragment.setLatLon(latLon); + if (gpxPoint != null) { + WptPt wptPt = gpxPoint.getSelectedPoint(); + fragment.setLatLon(new LatLon(wptPt.lat, wptPt.lon)); + fragment.setGpxPoint(gpxPoint); } else { QuadRect rect = selectedGpxFile.getGpxFile().getRect(); LatLon latLonRect = new LatLon(rect.centerY(), rect.centerX()); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 2171c4fc82..24a6d244bb 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -1025,7 +1025,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM float bearing = prevPointLocation.bearingTo(nextPointLocation); - return new SelectedGpxPoint(selectedGpxFile, projectionPoint, bearing); + return new SelectedGpxPoint(selectedGpxFile, projectionPoint, prevPoint, nextPoint, bearing); } public static WptPt createProjectionPoint(WptPt prevPoint, WptPt nextPoint, LatLon latLon) { @@ -1113,9 +1113,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } MapActivity mapActivity = (MapActivity) view.getContext(); SelectedGpxPoint point = (SelectedGpxPoint) object; - WptPt wptPt = point.getSelectedPoint(); - TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), - new LatLon(wptPt.lat, wptPt.lon), null, null, false); + TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false); return true; }