Context menu fixes

This commit is contained in:
Alexey Kulish 2016-03-22 19:56:54 +03:00
parent dc562279b9
commit 28df425008
11 changed files with 67 additions and 42 deletions

View file

@ -169,7 +169,9 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects) {
getRecordingsFromPoint(point, tileBox, objects);
if (tileBox.getZoom() >= startZoom) {
getRecordingsFromPoint(point, tileBox, objects);
}
}
public void getRecordingsFromPoint(PointF point, RotatedTileBox tileBox, List<? super Recording> am) {

View file

@ -532,7 +532,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) {
getBugFromPoint(tileBox, point, res);
if (tileBox.getZoom() >= startZoom) {
getBugFromPoint(tileBox, point, res);
}
}
@Override

View file

@ -56,13 +56,15 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (tileBox.getZoom() >= startZoom) {
drawPoints(canvas, tileBox, plugin.getDBBug().getOsmbugsPoints());
drawPoints(canvas, tileBox, plugin.getDBPOI().getOpenstreetmapPoints());
List<LatLon> fullObjectsLatLon = new ArrayList<>();
drawPoints(canvas, tileBox, plugin.getDBBug().getOsmbugsPoints(), fullObjectsLatLon);
drawPoints(canvas, tileBox, plugin.getDBPOI().getOpenstreetmapPoints(), fullObjectsLatLon);
this.fullObjectsLatLon = fullObjectsLatLon;
}
}
private void drawPoints(Canvas canvas, RotatedTileBox tileBox, List<? extends OsmPoint> objects) {
List<LatLon> fullObjectsLatLon = new ArrayList<>();
private void drawPoints(Canvas canvas, RotatedTileBox tileBox, List<? extends OsmPoint> objects,
List<LatLon> fullObjectsLatLon) {
for (OsmPoint o : objects) {
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
@ -77,7 +79,6 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
}
this.fullObjectsLatLon = fullObjectsLatLon;
}
@Override
@ -144,7 +145,9 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
getOsmEditsFromPoint(point, tileBox, o);
if (tileBox.getZoom() >= startZoom) {
getOsmEditsFromPoint(point, tileBox, o);
}
}
@Override

View file

@ -280,13 +280,13 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
true).getIntrinsicWidth() * 3 / 2.5f;
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
// request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds();
for (SelectedGpxFile g : selectedGPXFiles) {
List<WptPt> pts = getListStarPoints(g);
List<WptPt> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
int fcolor = g.getColor() == 0 ? defPointColor : g.getColor();
for (WptPt o : pts) {
if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top
@ -315,9 +315,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true);
fid.drawBitmapInCenter(canvas, x, y);
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
}
@ -482,7 +482,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) {
getWptFromPoint(tileBox, point, res);
if (tileBox.getZoom() >= startZoom) {
getWptFromPoint(tileBox, point, res);
}
}
@Override

View file

@ -117,18 +117,20 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
int ex = (int) point.x;
int ey = (int) point.y;
int compare = getRadiusPoi(tileBox);
int radius = compare * 3 / 2;
if (tileBox.getZoom() >= startZoom) {
int ex = (int) point.x;
int ey = (int) point.y;
int compare = getRadiusPoi(tileBox);
int radius = compare * 3 / 2;
for (RouteDataObject road : getMissingRoads()) {
Location location = getMissingRoadLocations().get(road.getId());
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
if (calculateBelongs(ex, ey, x, y, compare)) {
compare = radius;
o.add(road);
for (RouteDataObject road : getMissingRoads()) {
Location location = getMissingRoadLocations().get(road.getId());
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
if (calculateBelongs(ex, ey, x, y, compare)) {
compare = radius;
o.add(road);
}
}
}
}

View file

@ -392,6 +392,10 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
return;
}
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
List<MapMarker> markers = markersHelper.getActiveMapMarkers();
int r = getRadiusPoi(tileBox);

View file

@ -820,6 +820,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
}
if (twoFingerTapDetector.onTouchEvent(event)) {
ContextMenuLayer contextMenuLayer = getLayerByClass(ContextMenuLayer.class);
if (contextMenuLayer != null) {
contextMenuLayer.onTouchEvent(event, getCurrentRotatedTileBox());
}
return true;
}

View file

@ -507,7 +507,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects) {
getAmenityFromPoint(tileBox, point, objects);
if (tileBox.getZoom() >= startZoom) {
getAmenityFromPoint(tileBox, point, objects);
}
}
@Override

View file

@ -165,7 +165,9 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
getMyLocationFromPoint(tileBox, point, o);
if (tileBox.getZoom() >= 3) {
getMyLocationFromPoint(tileBox, point, o);
}
}
@Override

View file

@ -180,24 +180,24 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
TargetPointsHelper tg = map.getMyApplication().getTargetPointsHelper();
List<TargetPoint> intermediatePoints = tg.getAllPoints();
int r = getRadiusPoi(tileBox);
for (int i = 0; i < intermediatePoints.size(); i++) {
TargetPoint tp = intermediatePoints.get(i);
LatLon latLon = tp.point;
if (latLon != null) {
int ex = (int) point.x;
int ey = (int) point.y;
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
if (calculateBelongs(ex, ey, x, y, r)) {
o.add(tp);
if (tileBox.getZoom() >= 3) {
TargetPointsHelper tg = map.getMyApplication().getTargetPointsHelper();
List<TargetPoint> intermediatePoints = tg.getAllPoints();
int r = getRadiusPoi(tileBox);
for (int i = 0; i < intermediatePoints.size(); i++) {
TargetPoint tp = intermediatePoints.get(i);
LatLon latLon = tp.point;
if (latLon != null) {
int ex = (int) point.x;
int ey = (int) point.y;
int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
if (calculateBelongs(ex, ey, x, y, r)) {
o.add(tp);
}
}
}
}
}
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {

View file

@ -205,7 +205,9 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) {
getFromPoint(tileBox, point, res);
if (tileBox.getZoom() >= startZoom) {
getFromPoint(tileBox, point, res);
}
}
@Override