Fix MapMultiSelectionMenu menu for tracks

This commit is contained in:
Vitaliy 2021-04-11 12:19:49 +03:00
parent 47e08d7338
commit 60b346373f
17 changed files with 114 additions and 20 deletions

View file

@ -169,6 +169,11 @@ public class AudioNotesLayer extends OsmandMapLayer implements
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects, boolean unknownLocation) {
if (tileBox.getZoom() >= startZoom) { if (tileBox.getZoom() >= startZoom) {

View file

@ -6,6 +6,7 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
@ -346,6 +347,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
private void getImagesFromPoint(RotatedTileBox tb, PointF point, List<? super MapillaryImage> images) { private void getImagesFromPoint(RotatedTileBox tb, PointF point, List<? super MapillaryImage> images) {
Map<QuadPointDouble, Map> points = this.visiblePoints; Map<QuadPointDouble, Map> points = this.visiblePoints;
if (points != null) { if (points != null) {

View file

@ -7,6 +7,7 @@ import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.PointF; import android.graphics.PointF;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.TrkSegment;
@ -516,6 +517,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
private Location getLocationFromLL(double lat, double lon) { private Location getLocationFromLL(double lat, double lon) {
Location l = new Location(""); Location l = new Location("");
l.setLatitude(lat); l.setLatitude(lat);

View file

@ -7,6 +7,7 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -467,6 +468,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
if (tileBox.getZoom() >= startZoom) { if (tileBox.getZoom() >= startZoom) {

View file

@ -194,6 +194,11 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (tileBox.getZoom() >= startZoom) { if (tileBox.getZoom() >= startZoom) {

View file

@ -24,13 +24,14 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.layers.MapTextLayer.MapTextProvider;
import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.widgets.tools.CropCircleTransformation;
import java.io.IOException; import java.io.IOException;
@ -46,7 +47,7 @@ import java.util.concurrent.ConcurrentHashMap;
import static net.osmand.aidl.ConnectedApp.AIDL_LAYERS_PREFIX; import static net.osmand.aidl.ConnectedApp.AIDL_LAYERS_PREFIX;
public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextLayer.MapTextProvider<AidlMapPointWrapper> { public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextProvider<AidlMapPointWrapper> {
private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f; private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f;
@ -281,6 +282,11 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (isLayerEnabled()) { if (isLayerEnabled()) {

View file

@ -609,7 +609,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
String title = pointDescription == null ? "" : pointDescription.getName(); String title = pointDescription == null ? "" : pointDescription.getName();
mAddGpxPointBottomSheetHelper.setTitle(title); mAddGpxPointBottomSheetHelper.setTitle(title);
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true); view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
} else { } else if (provider == null || !provider.showMenuAction(object)) {
selectedObjectContextMenuProvider = provider; selectedObjectContextMenuProvider = provider;
hideVisibleMenues(); hideVisibleMenues();
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false); activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
@ -1106,6 +1106,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
boolean isObjectClickable(Object o); boolean isObjectClickable(Object o);
boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation); boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation);
boolean showMenuAction(@Nullable Object o);
} }
public interface IMoveObjectProvider { public interface IMoveObjectProvider {

View file

@ -13,6 +13,7 @@ import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.binary.BinaryMapDataObject; import net.osmand.binary.BinaryMapDataObject;
@ -580,6 +581,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) { private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) {
int zoom = tb.getZoom(); int zoom = tb.getZoom();
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION

View file

@ -227,6 +227,11 @@ public class FavouritesLayer extends OsmandMapLayer implements IContextMenuProvi
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) { if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) {

View file

@ -1108,13 +1108,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
@Override @Override
public boolean runExclusiveAction(Object object, boolean unknownLocation) { public boolean runExclusiveAction(Object object, boolean unknownLocation) {
if (unknownLocation || !(object instanceof SelectedGpxPoint)) { return false;
return false;
}
MapActivity mapActivity = (MapActivity) view.getContext();
SelectedGpxPoint point = (SelectedGpxPoint) object;
TrackMenuFragment.showInstance(mapActivity, point.getSelectedGpxFile(), point, null, null, false);
return true;
} }
@Override @Override
@ -1158,14 +1152,24 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) trackPoints.get(0); SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) trackPoints.get(0);
WptPt wptPt = selectedGpxPoint.getSelectedPoint(); WptPt wptPt = selectedGpxPoint.getSelectedPoint();
PointDescription description = getObjectName(selectedGpxPoint); PointDescription description = getObjectName(selectedGpxPoint);
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer(); mapActivity.getContextMenu().show(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint);
contextMenuLayer.showContextMenu(new LatLon(wptPt.lat, wptPt.lon), description, selectedGpxPoint, this);
return true; return true;
} }
} }
return false; 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 @Override
public LatLon getTextLocation(WptPt o) { public LatLon getTextLocation(WptPt o) {
return new LatLon(o.lat, o.lon); return new LatLon(o.lat, o.lon);

View file

@ -142,6 +142,11 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (tileBox.getZoom() >= START_ZOOM) { if (tileBox.getZoom() >= START_ZOOM) {

View file

@ -531,6 +531,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
return true; return true;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS.get()) { if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS.get()) {

View file

@ -16,6 +16,7 @@ import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
@ -408,6 +409,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public LatLon getTextLocation(Amenity o) { public LatLon getTextLocation(Amenity o) {
return o.getLocation(); return o.getLocation();

View file

@ -13,6 +13,7 @@ import android.graphics.RectF;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
@ -22,14 +23,15 @@ import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
import org.apache.commons.logging.Log; 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.ANTI_ALIAS_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_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); private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class);
protected final static int RADIUS = 7; protected final static int RADIUS = 7;
@ -240,6 +242,11 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
private LatLon getMyLocation() { private LatLon getMyLocation() {
Location location = locationProvider.getLastKnownLocation(); Location location = locationProvider.getLastKnownLocation();
if (location != null) { if (location != null) {

View file

@ -23,11 +23,13 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.layers.ContextMenuLayer.IMoveObjectProvider;
import java.util.List; import java.util.List;
public class PointNavigationLayer extends OsmandMapLayer implements public class PointNavigationLayer extends OsmandMapLayer implements
IContextMenuProvider, ContextMenuLayer.IMoveObjectProvider { IContextMenuProvider, IMoveObjectProvider {
protected final static int DIST_TO_SHOW = 80; protected final static int DIST_TO_SHOW = 80;
private Paint mPoint; private Paint mPoint;
@ -186,6 +188,11 @@ public class PointNavigationLayer extends OsmandMapLayer implements
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (tileBox.getZoom() >= 3) { if (tileBox.getZoom() >= 3) {

View file

@ -46,6 +46,7 @@ import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; 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.PublicTransportGeometryWay;
import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWayContext; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWayContext;
import net.osmand.plus.views.layers.geometry.RouteGeometryWay; 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; 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); 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) { public boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation) {
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
} }

View file

@ -8,6 +8,7 @@ import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import net.osmand.ResultMatcher; import net.osmand.ResultMatcher;
@ -21,16 +22,17 @@ import net.osmand.data.TransportStop;
import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.Way; import net.osmand.osm.edit.Way;
import net.osmand.plus.OsmandApplication; 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.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.render.RenderingIcons; 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.TransportStopRoute;
import net.osmand.plus.transport.TransportStopType; import net.osmand.plus.transport.TransportStopType;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.layers.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.layers.geometry.GeometryWay; import net.osmand.plus.views.layers.geometry.GeometryWay;
import java.io.IOException; import java.io.IOException;
@ -40,7 +42,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.TreeSet; 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"; public static final String TRANSPORT_STOPS_OVER_MAP = "transportStops";
@ -308,6 +310,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
return false; return false;
} }
@Override
public boolean showMenuAction(@Nullable Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) { if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) {