diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index 96ce49d8db..727e7d683b 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -169,6 +169,11 @@ public class AudioNotesLayer extends OsmandMapLayer implements return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List objects, boolean unknownLocation) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java index 09d7e7b7e4..9f80a25201 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java @@ -6,6 +6,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PointF; +import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import com.vividsolutions.jts.geom.Coordinate; @@ -346,6 +347,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + private void getImagesFromPoint(RotatedTileBox tb, PointF point, List images) { Map points = this.visiblePoints; if (points != null) { diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index 7e6a1439ee..4da4e357f5 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -7,6 +7,7 @@ import android.graphics.Paint; import android.graphics.Path; import android.graphics.PointF; +import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.GPXUtilities.TrkSegment; @@ -516,6 +517,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + private Location getLocationFromLL(double lat, double lon) { Location l = new Location(""); l.setLatitude(lat); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 013ba37d5b..23bff39f89 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -7,6 +7,7 @@ import android.view.View; import android.widget.EditText; import android.widget.Toast; +import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.PlatformUtil; @@ -467,6 +468,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res, boolean unknownLocation) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index a0fe1c1af2..3b416ac915 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -194,6 +194,11 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java index 8107943408..45600b8592 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/AidlMapLayer.java @@ -24,13 +24,14 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; +import net.osmand.plus.views.layers.MapTextLayer.MapTextProvider; import net.osmand.plus.widgets.tools.CropCircleTransformation; import java.io.IOException; @@ -46,7 +47,7 @@ import java.util.concurrent.ConcurrentHashMap; import static net.osmand.aidl.ConnectedApp.AIDL_LAYERS_PREFIX; -public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextLayer.MapTextProvider { +public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextProvider { private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f; @@ -281,6 +282,11 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { if (isLayerEnabled()) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java index 4c2a63db9e..1efe5972b8 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ContextMenuLayer.java @@ -609,7 +609,7 @@ public class ContextMenuLayer extends OsmandMapLayer { String title = pointDescription == null ? "" : pointDescription.getName(); mAddGpxPointBottomSheetHelper.setTitle(title); view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true); - } else { + } else if (provider == null || !provider.showMenuAction(object)) { selectedObjectContextMenuProvider = provider; hideVisibleMenues(); activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false); @@ -1106,6 +1106,8 @@ public class ContextMenuLayer extends OsmandMapLayer { boolean isObjectClickable(Object o); boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation); + + boolean showMenuAction(@Nullable Object o); } public interface IMoveObjectProvider { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java index a624b8412c..f170e005cb 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/DownloadedRegionsLayer.java @@ -13,6 +13,7 @@ import android.util.DisplayMetrics; import android.view.WindowManager; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import net.osmand.IndexConstants; import net.osmand.binary.BinaryMapDataObject; @@ -580,6 +581,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List dataObjects) { int zoom = tb.getZoom(); if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION diff --git a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java index 5e4f95f136..656568b425 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/FavouritesLayer.java @@ -227,6 +227,11 @@ public class FavouritesLayer extends OsmandMapLayer implements IContextMenuProvi return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res, boolean unknownLocation) { if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 24a6d244bb..2531b78a51 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -1108,13 +1108,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM @Override public boolean runExclusiveAction(Object object, boolean unknownLocation) { - if (unknownLocation || !(object instanceof SelectedGpxPoint)) { - return false; - } - MapActivity mapActivity = (MapActivity) view.getContext(); - SelectedGpxPoint point = (SelectedGpxPoint) object; - TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false); - return true; + return false; } @Override @@ -1158,14 +1152,24 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM 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); + mapActivity.getContextMenu().show(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint); return true; } } return false; } + @Override + public boolean showMenuAction(@Nullable Object object) { + if (!(object instanceof SelectedGpxPoint)) { + return false; + } + MapActivity mapActivity = (MapActivity) view.getContext(); + SelectedGpxPoint point = (SelectedGpxPoint) object; + TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false); + return true; + } + @Override public LatLon getTextLocation(WptPt o) { return new LatLon(o.lat, o.lon); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java index 09f84ba6e3..e2bd7944e2 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/ImpassableRoadsLayer.java @@ -142,6 +142,11 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { if (tileBox.getZoom() >= START_ZOOM) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java index a8d79b4519..b6496222f8 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapMarkersLayer.java @@ -531,6 +531,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi return true; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS.get()) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java index c264b67b0f..1adeed7671 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/POIMapLayer.java @@ -16,6 +16,7 @@ import android.widget.LinearLayout.LayoutParams; import android.widget.ScrollView; import android.widget.TextView; +import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; @@ -408,6 +409,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public LatLon getTextLocation(Amenity o) { return o.getLocation(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java index 2021f5d32f..29626e602e 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/PointLocationLayer.java @@ -13,6 +13,7 @@ import android.graphics.RectF; import android.graphics.drawable.LayerDrawable; import androidx.annotation.ColorInt; +import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; @@ -22,14 +23,15 @@ import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.profiles.ProfileIconColors; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import org.apache.commons.logging.Log; @@ -38,7 +40,7 @@ import java.util.List; import static android.graphics.Paint.ANTI_ALIAS_FLAG; import static android.graphics.Paint.FILTER_BITMAP_FLAG; -public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider { +public class PointLocationLayer extends OsmandMapLayer implements IContextMenuProvider { private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class); protected final static int RADIUS = 7; @@ -240,6 +242,11 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + private LatLon getMyLocation() { Location location = locationProvider.getLastKnownLocation(); if (location != null) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java index 26899516e3..17ddaf6c6c 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/PointNavigationLayer.java @@ -23,11 +23,13 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; +import net.osmand.plus.views.layers.ContextMenuLayer.IMoveObjectProvider; import java.util.List; public class PointNavigationLayer extends OsmandMapLayer implements - IContextMenuProvider, ContextMenuLayer.IMoveObjectProvider { + IContextMenuProvider, IMoveObjectProvider { + protected final static int DIST_TO_SHOW = 80; private Paint mPoint; @@ -186,6 +188,11 @@ public class PointNavigationLayer extends OsmandMapLayer implements return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { if (tileBox.getZoom() >= 3) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index f73a44f0ba..01e6765000 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -46,6 +46,7 @@ import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWayContext; import net.osmand.plus.views.layers.geometry.RouteGeometryWay; @@ -67,7 +68,7 @@ import java.util.Map; import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; -public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider { +public class RouteLayer extends OsmandMapLayer implements IContextMenuProvider { private static final Log log = PlatformUtil.getLog(RouteLayer.class); @@ -815,4 +816,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont public boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation) { return false; } + + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java index 082b8998df..14a8575df0 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/TransportStopsLayer.java @@ -8,6 +8,7 @@ import android.util.DisplayMetrics; import android.view.WindowManager; import androidx.annotation.DrawableRes; +import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import net.osmand.ResultMatcher; @@ -21,16 +22,17 @@ import net.osmand.data.TransportStop; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Way; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.base.PointImageDrawable; -import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.render.RenderingIcons; +import net.osmand.plus.settings.backend.CommonPreference; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.transport.TransportStopType; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.layers.geometry.GeometryWay; import java.io.IOException; @@ -40,7 +42,7 @@ import java.util.Comparator; import java.util.List; import java.util.TreeSet; -public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider { +public class TransportStopsLayer extends OsmandMapLayer implements IContextMenuProvider { public static final String TRANSPORT_STOPS_OVER_MAP = "transportStops"; @@ -308,6 +310,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa return false; } + @Override + public boolean showMenuAction(@Nullable Object o) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res, boolean unknownLocation) { if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) {