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 @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects) { 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) { 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 @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) {
getBugFromPoint(tileBox, point, res); if (tileBox.getZoom() >= startZoom) {
getBugFromPoint(tileBox, point, res);
}
} }
@Override @Override

View file

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

View file

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

View file

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

View file

@ -392,6 +392,10 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) { 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(); MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
List<MapMarker> markers = markersHelper.getActiveMapMarkers(); List<MapMarker> markers = markersHelper.getActiveMapMarkers();
int r = getRadiusPoi(tileBox); int r = getRadiusPoi(tileBox);

View file

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

View file

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

View file

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

View file

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