From 637f9f957cc673811f2ea031214b4a7b4889cf8f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 8 Apr 2021 14:10:16 +0300 Subject: [PATCH] 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; }