Open track point menu on long click

This commit is contained in:
Vitaliy 2021-04-08 14:10:16 +03:00
parent bb5302e2cc
commit 637f9f957c
18 changed files with 44 additions and 22 deletions

View file

@ -155,7 +155,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -316,7 +316,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -502,7 +502,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return isInMeasurementMode();
}

View file

@ -453,7 +453,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -267,7 +267,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -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);

View file

@ -566,7 +566,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -213,7 +213,7 @@ public class FavouritesLayer extends OsmandMapLayer implements IContextMenuProvi
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -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<Object> 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<Object> 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;
}

View file

@ -128,7 +128,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -497,7 +497,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return inPlanRouteMode;
}

View file

@ -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;
}

View file

@ -226,7 +226,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -172,7 +172,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}

View file

@ -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();
}

View file

@ -294,7 +294,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
}
@Override
public boolean disableLongPressOnMap() {
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
return false;
}