Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-03-10 19:50:15 +01:00
commit 33360db55d
23 changed files with 286 additions and 134 deletions

View file

@ -1,25 +1,19 @@
package net.osmand.access; package net.osmand.access;
import java.util.ArrayList; import android.graphics.PointF;
import java.util.LinkedHashMap; import android.view.GestureDetector.SimpleOnGestureListener;
import java.util.List; import android.view.MotionEvent;
import java.util.Map;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import android.graphics.PointF;
import android.os.Build; import java.util.List;
import android.view.GestureDetector; import java.util.Map;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
// Provide touch exploration mode for map view // Provide touch exploration mode for map view
// when scrolling it by gestures is disabled. // when scrolling it by gestures is disabled.
@ -91,6 +85,11 @@ public class MapExplorer extends SimpleOnGestureListener implements IContextMenu
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects) {
int radius = (int)(VICINITY_RADIUS * tileBox.getDensity()); int radius = (int)(VICINITY_RADIUS * tileBox.getDensity());

View file

@ -90,14 +90,18 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
final QuadRect latlon = tileBox.getLatLonBounds(); final QuadRect latlon = tileBox.getLatLonBounds();
List<Recording> objects = recs.getObjects(latlon.top, latlon.left, latlon.bottom, latlon.right); List<Recording> objects = recs.getObjects(latlon.top, latlon.left, latlon.bottom, latlon.right);
List<Recording> fullObjects = new ArrayList<>(); List<Recording> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
for (Recording o : objects) { for (Recording 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());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) { if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon); canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} else { } else {
fullObjects.add(o); fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} }
} }
for (Recording o : fullObjects) { for (Recording o : fullObjects) {
@ -113,6 +117,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
} }
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon); canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
} }
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
} }
} }
@ -156,6 +162,11 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof Recording;
}
@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); getRecordingsFromPoint(point, tileBox, objects);

View file

@ -587,6 +587,11 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
return distanceMeasurementMode == 1; return distanceMeasurementMode == 1;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
getMPointsFromPoint(tileBox, point, o); getMPointsFromPoint(tileBox, point, o);

View file

@ -737,6 +737,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
} }
public boolean supportZoomIn() {
return menuController == null || menuController.supportZoomIn();
}
public boolean fabVisible() { public boolean fabVisible() {
return menuController == null || menuController.fabVisible(); return menuController == null || menuController.fabVisible();
} }

View file

@ -231,14 +231,14 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
moving = false; moving = false;
int posY = getViewY(); int posY = getViewY();
if (!centered) { if (!centered) {
if (!zoomIn) { if (!zoomIn && menu.supportZoomIn()) {
LatLon centerLatLon = map.getCurrentRotatedTileBox().getCenterLatLon(); LatLon centerLatLon = map.getCurrentRotatedTileBox().getCenterLatLon();
if (centerLatLon.equals(menu.getLatLon())) { if (centerLatLon.equals(menu.getLatLon())) {
zoomIn = true; zoomIn = true;
} }
} }
centerMarkerLocation(); centerMarkerLocation();
} else if (!zoomIn) { } else if (!zoomIn && menu.supportZoomIn()) {
int fZoom = getZoom(); int fZoom = getZoom();
zoomIn = true; zoomIn = true;
if (fZoom < ZOOM_IN_STANDARD) { if (fZoom < ZOOM_IN_STANDARD) {

View file

@ -236,6 +236,10 @@ public abstract class MenuController extends BaseMenuController {
return titleProgressController; return titleProgressController;
} }
public boolean supportZoomIn() {
return true;
}
public boolean fabVisible() { public boolean fabVisible() {
return true; return true;
} }

View file

@ -8,6 +8,7 @@ import android.os.AsyncTask;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -22,6 +23,7 @@ import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject; import net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject;
@ -41,17 +43,23 @@ public class MapDataMenuController extends MenuController {
private List<IndexItem> otherIndexItems; private List<IndexItem> otherIndexItems;
private boolean srtmDisabled; private boolean srtmDisabled;
private boolean srtmNeedsInstallation; private boolean srtmNeedsInstallation;
boolean downloaded;
private DownloadIndexesThread downloadThread; private DownloadIndexesThread downloadThread;
private ResourceManager rm;
public MapDataMenuController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final DownloadMapObject mapObject) { public MapDataMenuController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final DownloadMapObject mapObject) {
super(new MenuBuilder(app), pointDescription, mapActivity); super(new MenuBuilder(app), pointDescription, mapActivity);
this.mapObject = mapObject; this.mapObject = mapObject;
rm = app.getResourceManager();
indexItem = mapObject.getIndexItem(); indexItem = mapObject.getIndexItem();
downloadThread = app.getDownloadThread(); downloadThread = app.getDownloadThread();
if (indexItem != null) { if (indexItem != null) {
downloaded = indexItem.isDownloaded();
otherIndexItems = new LinkedList<>(downloadThread.getIndexes().getIndexItems(mapObject.getWorldRegion())); otherIndexItems = new LinkedList<>(downloadThread.getIndexes().getIndexItems(mapObject.getWorldRegion()));
otherIndexItems.remove(indexItem); otherIndexItems.remove(indexItem);
} else {
downloaded = checkIfObjectDownloaded(rm.getOsmandRegions().getDownloadName(mapObject.getDataObject()));
} }
srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null; srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null;
@ -93,6 +101,14 @@ public class MapDataMenuController extends MenuController {
public void buttonPressed() { public void buttonPressed() {
if (indexItem != null) { if (indexItem != null) {
deleteItem(); deleteItem();
} else if (downloaded) {
/*
File f = new File(info.getPathToData());
boolean successfull = Algorithms.removeAllFiles(f);
if (successfull) {
getMapActivity().getMyApplication().getResourceManager().closeFile(info.getFileName());
}
*/
} }
} }
}; };
@ -215,6 +231,11 @@ public class MapDataMenuController extends MenuController {
} }
} }
@Override
public boolean supportZoomIn() {
return false;
}
@Override @Override
public boolean fabVisible() { public boolean fabVisible() {
return false; return false;
@ -254,7 +275,7 @@ public class MapDataMenuController extends MenuController {
} }
} }
rightTitleButtonController.visible = indexItem != null && indexItem.isDownloaded(); rightTitleButtonController.visible = downloaded;
topRightTitleButtonController.visible = otherIndexItems.size() > 0; topRightTitleButtonController.visible = otherIndexItems.size() > 0;
boolean downloadIndexes = getMapActivity().getMyApplication().getSettings().isInternetConnectionAvailable() boolean downloadIndexes = getMapActivity().getMyApplication().getSettings().isInternetConnectionAvailable()
@ -332,4 +353,12 @@ public class MapDataMenuController extends MenuController {
confirm.show(); confirm.show();
} }
} }
private boolean checkIfObjectDownloaded(String downloadName) {
final String regionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName)
+ IndexConstants.BINARY_MAP_INDEX_EXT;
final String roadsRegionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName) + ".road"
+ IndexConstants.BINARY_MAP_INDEX_EXT;
return rm.getIndexFileNames().containsKey(regionName) || rm.getIndexFileNames().containsKey(roadsRegionName);
}
} }

View file

@ -133,6 +133,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
float iconSize = resolvedNote.getWidth() * 3 / 2.5f; float iconSize = resolvedNote.getWidth() * 3 / 2.5f;
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox); QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
List<OpenStreetNote> fullObjects = new ArrayList<>(); List<OpenStreetNote> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
for (OpenStreetNote o : objects) { for (OpenStreetNote 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());
@ -145,8 +147,10 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
b = resolvedNoteSmall; b = resolvedNoteSmall;
} }
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon); canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} else { } else {
fullObjects.add(o); fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} }
} }
for (OpenStreetNote o : fullObjects) { for (OpenStreetNote o : fullObjects) {
@ -160,6 +164,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
} }
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon); canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
} }
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
} }
} }
} }
@ -519,6 +525,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof OpenStreetNote;
}
@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); getBugFromPoint(tileBox, point, res);

View file

@ -15,6 +15,7 @@ import net.osmand.plus.views.ContextMenuLayer;
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 java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -61,6 +62,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
} }
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<>();
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());
@ -73,7 +75,9 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
b = poi; b = poi;
} }
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()));
} }
this.fullObjectsLatLon = fullObjectsLatLon;
} }
@Override @Override
@ -133,6 +137,11 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof OsmPoint;
}
@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); getOsmEditsFromPoint(point, tileBox, o);

View file

@ -208,6 +208,11 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof OsMoDevice;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
getOsmoFromPoint(tileBox, point, o); getOsmoFromPoint(tileBox, point, o);

View file

@ -113,6 +113,11 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o == getParkingPoint();
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
getParkingFromPoint(tileBox, point, o); getParkingFromPoint(tileBox, point, o);

View file

@ -40,6 +40,11 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {

View file

@ -14,20 +14,14 @@ import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
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.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
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.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu; import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
import net.osmand.plus.osmedit.OsmBugsLayer.OpenStreetNote;
import net.osmand.plus.osmedit.OsmPoint;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -49,6 +43,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
boolean disableSingleTap(); boolean disableSingleTap();
boolean disableLongPressOnMap(); boolean disableLongPressOnMap();
boolean isObjectClickable(Object o);
} }
public interface IContextMenuProviderSelection { public interface IContextMenuProviderSelection {
@ -70,7 +66,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
private ImageView contextMarker; private ImageView contextMarker;
private Paint paint; private Paint paint;
private Bitmap pressedBitmap; private Bitmap pressedBitmap;
private LatLon pressedLatLon; private Bitmap pressedBitmapSmall;
private List<LatLon> pressedLatLonFull = new ArrayList<>();
private List<LatLon> pressedLatLonSmall = new ArrayList<>();
private GestureDetector movementListener; private GestureDetector movementListener;
@ -99,6 +97,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
paint = new Paint(); paint = new Paint();
pressedBitmap = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_shield_tap); pressedBitmap = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_shield_tap);
pressedBitmapSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_shield_tap_small);
} }
public boolean isVisible() { public boolean isVisible() {
@ -107,9 +106,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) { public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
if (pressedLatLon != null) { for (LatLon latLon : pressedLatLonSmall) {
int x = (int) box.getPixXFromLatLon(pressedLatLon.getLatitude(), pressedLatLon.getLongitude()); int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(pressedLatLon.getLatitude(), pressedLatLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
canvas.drawBitmap(pressedBitmapSmall, x - pressedBitmapSmall.getWidth() / 2, y - pressedBitmapSmall.getHeight() / 2, paint);
}
for (LatLon latLon : pressedLatLonFull) {
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint); canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint);
} }
@ -162,7 +166,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
private boolean showContextMenu(PointF point, RotatedTileBox tileBox, boolean showUnknownLocation) { private boolean showContextMenu(PointF point, RotatedTileBox tileBox, boolean showUnknownLocation) {
Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point); Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false);
if (selectedObjects.size() == 1) { if (selectedObjects.size() == 1) {
Object selectedObj = selectedObjects.keySet().iterator().next(); Object selectedObj = selectedObjects.keySet().iterator().next();
IContextMenuProvider contextObject = selectedObjects.get(selectedObj); IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
@ -229,7 +233,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
return res; return res;
} }
private Map<Object, IContextMenuProvider> selectObjectsForContextMenu(RotatedTileBox tileBox, PointF point) { private Map<Object, IContextMenuProvider> selectObjectsForContextMenu(RotatedTileBox tileBox,
PointF point, boolean acquireObjLatLon) {
List<LatLon> pressedLatLonFull = new ArrayList<>();
List<LatLon> pressedLatLonSmall = new ArrayList<>();
Map<Object, IContextMenuProvider> selectedObjects = new HashMap<>(); Map<Object, IContextMenuProvider> selectedObjects = new HashMap<>();
List<Object> s = new ArrayList<>(); List<Object> s = new ArrayList<>();
for (OsmandMapLayer lt : view.getLayers()) { for (OsmandMapLayer lt : view.getLayers()) {
@ -239,9 +246,21 @@ public class ContextMenuLayer extends OsmandMapLayer {
l.collectObjectsFromPoint(point, tileBox, s); l.collectObjectsFromPoint(point, tileBox, s);
for (Object o : s) { for (Object o : s) {
selectedObjects.put(o, l); selectedObjects.put(o, l);
if (acquireObjLatLon && l.isObjectClickable(o)) {
LatLon latLon = l.getObjectLocation(o);
if (lt.isPresentInFullObjects(latLon) && !pressedLatLonFull.contains(latLon)) {
pressedLatLonFull.add(latLon);
} else if (lt.isPresentInSmallObjects(latLon) && !pressedLatLonSmall.contains(latLon)) {
pressedLatLonSmall.add(latLon);
}
}
} }
} }
} }
if (acquireObjLatLon) {
this.pressedLatLonFull = pressedLatLonFull;
this.pressedLatLonSmall = pressedLatLonSmall;
}
return selectedObjects; return selectedObjects;
} }
@ -316,29 +335,15 @@ public class ContextMenuLayer extends OsmandMapLayer {
switch (event.getAction()) { switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
PointF point = new PointF(event.getX(), event.getY()); selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true);
Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point); if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) {
if (selectedObjects.size() == 1) { view.refreshMap();
Object selectedObj = selectedObjects.keySet().iterator().next();
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
LatLon latLon = null;
PointDescription pointDescription = null;
if (contextObject != null) {
latLon = contextObject.getObjectLocation(selectedObj);
pointDescription = contextObject.getObjectName(selectedObj);
}
if (latLon == null) {
latLon = getLatLon(point, tileBox);
}
if (isObjectClickable(selectedObj, pointDescription)) {
pressedLatLon = latLon;
view.refreshMap();
}
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
pressedLatLon = null; pressedLatLonFull.clear();
pressedLatLonSmall.clear();
view.refreshMap(); view.refreshMap();
break; break;
} }
@ -346,30 +351,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
return false; return false;
} }
private boolean isObjectClickable(Object object, PointDescription pointDescription) {
boolean res;
if (pointDescription != null) {
res = pointDescription.isParking()
|| pointDescription.isFavorite()
|| pointDescription.isAudioNote()
|| pointDescription.isPhotoNote()
|| pointDescription.isVideoNote()
|| pointDescription.isPoi()
|| object instanceof OsmPoint
|| object instanceof FavouritePoint
|| object instanceof OsMoDevice
|| object instanceof OpenStreetNote;
} else {
res = object instanceof Amenity
|| object instanceof Recording
|| object instanceof OsmPoint
|| object instanceof FavouritePoint
|| object instanceof OsMoDevice
|| object instanceof OpenStreetNote;
}
return res;
}
private class MenuLayerOnGestureListener extends GestureDetector.SimpleOnGestureListener { private class MenuLayerOnGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override @Override

View file

@ -2,7 +2,6 @@ package net.osmand.plus.views;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Cap; import android.graphics.Paint.Cap;
import android.graphics.Paint.Join; import android.graphics.Paint.Join;
@ -495,6 +494,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
return false; return false;
} }
@Override
public boolean isObjectClickable(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

@ -101,6 +101,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
// request to load // request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds(); final QuadRect latLonBounds = tileBox.getLatLonBounds();
List<LocationPoint> fullObjects = new ArrayList<>(); List<LocationPoint> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
for (LocationPoint o : getPoints()) { for (LocationPoint o : getPoints()) {
if (!o.isVisible()) { if (!o.isVisible()) {
continue; continue;
@ -112,13 +114,17 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor(); int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor();
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY)); paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon); canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} else { } else {
fullObjects.add(o); fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} }
} }
for (LocationPoint o : fullObjects) { for (LocationPoint o : fullObjects) {
drawPoint(canvas, tileBox, latLonBounds, o); drawPoint(canvas, tileBox, latLonBounds, o);
} }
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
} }
} }
if(textLayer.isVisible()) { if(textLayer.isVisible()) {
@ -196,6 +202,11 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof LocationPoint;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res) {
if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) { if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) {

View file

@ -13,7 +13,6 @@ import android.graphics.PointF;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.support.annotation.NonNull;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -286,6 +285,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
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
@ -299,8 +300,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
int col = visit ? visitedColor : o.getColor(fcolor); int col = visit ? visitedColor : o.getColor(fcolor);
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY)); paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon); canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
} else { } else {
fullObjects.add(o); fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.lat, o.lon));
} }
} }
} }
@ -312,6 +315,8 @@ 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;
} }
} }
} }
@ -470,6 +475,11 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof WptPt;
}
@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); getWptFromPoint(tileBox, point, res);

View file

@ -10,7 +10,6 @@ import android.widget.ArrayAdapter;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
@ -111,6 +110,11 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@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; int ex = (int) point.x;

View file

@ -385,6 +385,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper(); MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();

View file

@ -1,10 +1,11 @@
package net.osmand.plus.views; package net.osmand.plus.views;
import gnu.trove.list.array.TIntArrayList; import android.graphics.Canvas;
import android.graphics.Path;
import java.util.ArrayList; import android.graphics.PointF;
import java.util.List; import android.os.AsyncTask;
import java.util.Map; import android.support.annotation.NonNull;
import android.view.MotionEvent;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
@ -12,52 +13,73 @@ import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.util.MapAlgorithms; import net.osmand.util.MapAlgorithms;
import android.graphics.Canvas;
import android.graphics.Path; import java.util.ArrayList;
import android.graphics.PointF; import java.util.List;
import android.os.AsyncTask; import java.util.Map;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import gnu.trove.list.array.TIntArrayList;
import android.view.MotionEvent;
public abstract class OsmandMapLayer { public abstract class OsmandMapLayer {
protected List<LatLon> fullObjectsLatLon;
protected List<LatLon> smallObjectsLatLon;
public abstract void initLayer(OsmandMapTileView view); public abstract void initLayer(OsmandMapTileView view);
public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings); public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings);
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
} }
public abstract void destroyLayer();
public void onRetainNonConfigurationInstance(Map<String, Object> map) {}
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {} public abstract void destroyLayer();
public void onRetainNonConfigurationInstance(Map<String, Object> map) {
}
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
}
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
return false; return false;
} }
public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) { public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) {
return false; return false;
} }
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { return false;} public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
return false;
public <Params> void executeTaskInBackground(AsyncTask<Params, ?, ?> task, Params... params){ }
public <Params> void executeTaskInBackground(AsyncTask<Params, ?, ?> task, Params... params) {
task.execute(params); task.execute(params);
} }
public boolean isPresentInFullObjects(LatLon latLon) {
if (fullObjectsLatLon == null) {
return true;
} else if (latLon != null) {
return fullObjectsLatLon.contains(latLon);
}
return false;
}
public boolean isPresentInSmallObjects(LatLon latLon) {
if (smallObjectsLatLon != null && latLon != null) {
return smallObjectsLatLon.contains(latLon);
}
return false;
}
/** /**
* This method returns whether canvas should be rotated as * This method returns whether canvas should be rotated as
* map rotated before {@link #onDraw(android.graphics.Canvas, net.osmand.data.RotatedTileBox, net.osmand.plus.views.OsmandMapLayer.DrawSettings)}. * map rotated before {@link #onDraw(android.graphics.Canvas, net.osmand.data.RotatedTileBox, net.osmand.plus.views.OsmandMapLayer.DrawSettings)}.
* If the layer draws simply layer over screen (not over map) * If the layer draws simply layer over screen (not over map)
* it should return true. * it should return true.
*/ */
public abstract boolean drawInScreenPixels(); public abstract boolean drawInScreenPixels();
public static class DrawSettings { public static class DrawSettings {
private final boolean nightMode; private final boolean nightMode;
private final boolean updateVectorRendering; private final boolean updateVectorRendering;
@ -70,23 +92,23 @@ public abstract class OsmandMapLayer {
this.nightMode = nightMode; this.nightMode = nightMode;
this.updateVectorRendering = updateVectorRendering; this.updateVectorRendering = updateVectorRendering;
} }
public boolean isUpdateVectorRendering() { public boolean isUpdateVectorRendering() {
return updateVectorRendering; return updateVectorRendering;
} }
public boolean isNightMode() { public boolean isNightMode() {
return nightMode; return nightMode;
} }
} }
private boolean isIn(int x, int y, int lx, int ty, int rx, int by) { private boolean isIn(int x, int y, int lx, int ty, int rx, int by) {
return x >= lx && x <= rx && y >= ty && y <= by; return x >= lx && x <= rx && y >= ty && y <= by;
} }
public int calculateSplitPaths(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys, public int calculateSplitPaths(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys,
TIntArrayList results) { TIntArrayList results) {
int px = xs.get(0); int px = xs.get(0);
int py = ys.get(0); int py = ys.get(0);
int h = tb.getPixHeight(); int h = tb.getPixHeight();
@ -94,12 +116,12 @@ public abstract class OsmandMapLayer {
int cnt = 0; int cnt = 0;
boolean pin = isIn(px, py, 0, 0, w, h); boolean pin = isIn(px, py, 0, 0, w, h);
Path path = null; Path path = null;
for(int i = 1; i < xs.size(); i++) { for (int i = 1; i < xs.size(); i++) {
int x = xs.get(i); int x = xs.get(i);
int y = ys.get(i); int y = ys.get(i);
boolean in = isIn(x, y, 0, 0, w, h); boolean in = isIn(x, y, 0, 0, w, h);
boolean draw = false; boolean draw = false;
if(pin && in) { if (pin && in) {
draw = true; draw = true;
} else { } else {
long intersection = MapAlgorithms.calculateIntersection(x, y, long intersection = MapAlgorithms.calculateIntersection(x, y,
@ -121,7 +143,7 @@ public abstract class OsmandMapLayer {
} }
return cnt; return cnt;
} }
public int calculatePath(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys, Path path) { public int calculatePath(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys, Path path) {
boolean start = false; boolean start = false;
int px = xs.get(0); int px = xs.get(0);
@ -130,12 +152,12 @@ public abstract class OsmandMapLayer {
int w = tb.getPixWidth(); int w = tb.getPixWidth();
int cnt = 0; int cnt = 0;
boolean pin = isIn(px, py, 0, 0, w, h); boolean pin = isIn(px, py, 0, 0, w, h);
for(int i = 1; i < xs.size(); i++) { for (int i = 1; i < xs.size(); i++) {
int x = xs.get(i); int x = xs.get(i);
int y = ys.get(i); int y = ys.get(i);
boolean in = isIn(x, y, 0, 0, w, h); boolean in = isIn(x, y, 0, 0, w, h);
boolean draw = false; boolean draw = false;
if(pin && in) { if (pin && in) {
draw = true; draw = true;
} else { } else {
long intersection = MapAlgorithms.calculateIntersection(x, y, long intersection = MapAlgorithms.calculateIntersection(x, y,
@ -153,7 +175,7 @@ public abstract class OsmandMapLayer {
} }
path.lineTo(x, y); path.lineTo(x, y);
start = true; start = true;
} else{ } else {
start = false; start = false;
} }
pin = in; pin = in;
@ -166,7 +188,7 @@ public abstract class OsmandMapLayer {
@NonNull @NonNull
public QuadTree<QuadRect> initBoundIntersections(RotatedTileBox tileBox) { public QuadTree<QuadRect> initBoundIntersections(RotatedTileBox tileBox) {
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight()); QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
bounds.inset(-bounds.width()/4, -bounds.height()/4); bounds.inset(-bounds.width() / 4, -bounds.height() / 4);
return new QuadTree<>(bounds, 4, 0.6f); return new QuadTree<>(bounds, 4, 0.6f);
} }
@ -200,23 +222,23 @@ public abstract class OsmandMapLayer {
protected T results; protected T results;
protected Task currentTask; protected Task currentTask;
protected Task pendingTask; protected Task pendingTask;
public RotatedTileBox getQueriedBox() { public RotatedTileBox getQueriedBox() {
return queriedBox; return queriedBox;
} }
public T getResults() { public T getResults() {
return results; return results;
} }
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) { public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
return queriedData != null && queriedData.containsTileBox(newBox) && Math.abs(queriedData.getZoom() - newBox.getZoom()) <= ZOOM_THRESHOLD; return queriedData != null && queriedData.containsTileBox(newBox) && Math.abs(queriedData.getZoom() - newBox.getZoom()) <= ZOOM_THRESHOLD;
} }
public void queryNewData(RotatedTileBox tileBox) { public void queryNewData(RotatedTileBox tileBox) {
if (!queriedBoxContains(queriedBox, tileBox) ) { if (!queriedBoxContains(queriedBox, tileBox)) {
Task ct = currentTask; Task ct = currentTask;
if(ct == null || !queriedBoxContains(ct.getDataBox(), tileBox)) { if (ct == null || !queriedBoxContains(ct.getDataBox(), tileBox)) {
RotatedTileBox original = tileBox.copy(); RotatedTileBox original = tileBox.copy();
RotatedTileBox extended = original.copy(); RotatedTileBox extended = original.copy();
extended.increasePixelDimensions(tileBox.getPixWidth() / 2, tileBox.getPixHeight() / 2); extended.increasePixelDimensions(tileBox.getPixWidth() / 2, tileBox.getPixHeight() / 2);
@ -225,41 +247,41 @@ public abstract class OsmandMapLayer {
executeTaskInBackground(task); executeTaskInBackground(task);
} else { } else {
pendingTask = task; pendingTask = task;
} }
} }
} }
} }
public void layerOnPostExecute() { public void layerOnPostExecute() {
} }
public boolean isInterrupted() { public boolean isInterrupted() {
return pendingTask != null; return pendingTask != null;
} }
protected abstract T calculateResult(RotatedTileBox tileBox); protected abstract T calculateResult(RotatedTileBox tileBox);
public class Task extends AsyncTask<Object, Object, T> { public class Task extends AsyncTask<Object, Object, T> {
private RotatedTileBox dataBox; private RotatedTileBox dataBox;
private RotatedTileBox requestedBox; private RotatedTileBox requestedBox;
public Task(RotatedTileBox requestedBox, RotatedTileBox dataBox) { public Task(RotatedTileBox requestedBox, RotatedTileBox dataBox) {
this.requestedBox = requestedBox; this.requestedBox = requestedBox;
this.dataBox = dataBox; this.dataBox = dataBox;
} }
public RotatedTileBox getOriginalBox() { public RotatedTileBox getOriginalBox() {
return requestedBox; return requestedBox;
} }
public RotatedTileBox getDataBox() { public RotatedTileBox getDataBox() {
return dataBox; return dataBox;
} }
@Override @Override
protected T doInBackground(Object... params) { protected T doInBackground(Object... params) {
if (queriedBoxContains(queriedBox, dataBox) ) { if (queriedBoxContains(queriedBox, dataBox)) {
return null; return null;
} }
return calculateResult(dataBox); return calculateResult(dataBox);
@ -289,9 +311,9 @@ public abstract class OsmandMapLayer {
public void clearCache() { public void clearCache() {
results = null; results = null;
queriedBox = null; queriedBox = null;
} }
} }
} }

View file

@ -232,6 +232,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
List<Amenity> objects = Collections.emptyList(); List<Amenity> objects = Collections.emptyList();
List<Amenity> fullObjects = new ArrayList<>(); List<Amenity> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
if (filter != null) { if (filter != null) {
if (tileBox.getZoom() >= startZoom) { if (tileBox.getZoom() >= startZoom) {
data.queryNewData(tileBox); data.queryNewData(tileBox);
@ -248,8 +250,12 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
if (intersects(boundIntersections, x, y, iconSize, iconSize)) { if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(poiBackgroundSmall, x - poiBackgroundSmall.getWidth() / 2, y - poiBackgroundSmall.getHeight() / 2, paintIconBackground); canvas.drawBitmap(poiBackgroundSmall, x - poiBackgroundSmall.getWidth() / 2, y - poiBackgroundSmall.getHeight() / 2, paintIconBackground);
smallObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(),
o.getLocation().getLongitude()));
} else { } else {
fullObjects.add(o); fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(),
o.getLocation().getLongitude()));
} }
} }
for (Amenity o : fullObjects) { for (Amenity o : fullObjects) {
@ -274,6 +280,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
} }
} }
} }
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
} }
} }
} }
@ -510,6 +518,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
return null; return null;
} }
@Override
public boolean isObjectClickable(Object o) {
return o instanceof Amenity;
}
@Override @Override
public LatLon getTextLocation(Amenity o) { public LatLon getTextLocation(Amenity o) {
return o.getLocation(); return o.getLocation();

View file

@ -194,6 +194,11 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
return false; return false;
} }
@Override
public boolean isObjectClickable(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

@ -172,7 +172,12 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
public boolean disableLongPressOnMap() { public boolean disableLongPressOnMap() {
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@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(); TargetPointsHelper tg = map.getMyApplication().getTargetPointsHelper();

View file

@ -198,6 +198,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
return false; return false;
} }
@Override
public boolean isObjectClickable(Object o) {
return false;
}
@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); getFromPoint(tileBox, point, res);