Merge branch 'master' of https://github.com/osmandapp/Osmand
This commit is contained in:
commit
0e767ba406
5 changed files with 109 additions and 57 deletions
|
@ -104,9 +104,6 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.object != null) {
|
|
||||||
clearSelectedObject(this.object);
|
|
||||||
}
|
|
||||||
setSelectedObject(object);
|
setSelectedObject(object);
|
||||||
|
|
||||||
if (pointDescription == null) {
|
if (pointDescription == null) {
|
||||||
|
@ -166,6 +163,9 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
active = false;
|
active = false;
|
||||||
|
if (this.object != null) {
|
||||||
|
clearSelectedObject(this.object);
|
||||||
|
}
|
||||||
hide();
|
hide();
|
||||||
mapActivity.getMapView().refreshMap();
|
mapActivity.getMapView().refreshMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import net.osmand.binary.BinaryMapDataObject;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -25,7 +26,7 @@ import net.osmand.plus.mapcontextmenu.controllers.OsMoMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.ParkingPositionMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.ParkingPositionMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.WorldRegionMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||||
import net.osmand.plus.osmedit.OsmPoint;
|
import net.osmand.plus.osmedit.OsmPoint;
|
||||||
|
@ -111,8 +112,8 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
|
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
|
||||||
} else if (object instanceof WptPt) {
|
} else if (object instanceof WptPt) {
|
||||||
menuController = new WptPtMenuController(app, mapActivity, (WptPt) object);
|
menuController = new WptPtMenuController(app, mapActivity, (WptPt) object);
|
||||||
} else if (object instanceof WorldRegion) {
|
} else if (object instanceof BinaryMapDataObject) {
|
||||||
menuController = new WorldRegionMenuController(app, mapActivity, (WorldRegion) object);
|
menuController = new MapDataMenuController(app, mapActivity, (BinaryMapDataObject) object);
|
||||||
} else if (object instanceof LatLon) {
|
} else if (object instanceof LatLon) {
|
||||||
if (pointDescription.isParking()) {
|
if (pointDescription.isParking()) {
|
||||||
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
|
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
|
||||||
|
|
|
@ -2,26 +2,27 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
import net.osmand.binary.BinaryMapDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
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.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadResourceGroup;
|
|
||||||
import net.osmand.plus.download.DownloadResources;
|
|
||||||
import net.osmand.plus.download.IndexItem;
|
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
|
|
||||||
public class WorldRegionMenuController extends MenuController {
|
public class MapDataMenuController extends MenuController {
|
||||||
private WorldRegion region;
|
private WorldRegion region;
|
||||||
|
|
||||||
public WorldRegionMenuController(OsmandApplication app, MapActivity mapActivity, final WorldRegion region) {
|
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, final BinaryMapDataObject dataObject) {
|
||||||
super(new MenuBuilder(app), mapActivity);
|
super(new MenuBuilder(app), mapActivity);
|
||||||
|
OsmandRegions osmandRegions = app.getRegions();
|
||||||
|
String fullName = osmandRegions.getFullName(dataObject);
|
||||||
|
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
this.region = region;
|
this.region = region;
|
||||||
titleButtonController = new TitleButtonController() {
|
titleButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
|
@ -155,13 +155,13 @@ public class ObjectSelectionMenu extends BaseMenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDismiss() {
|
public void onDismiss() {
|
||||||
clearSelectedObjects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openContextMenu(MenuObject menuObject) {
|
public void openContextMenu(MenuObject menuObject) {
|
||||||
if (selectedObjects.containsKey(menuObject.getObject())) {
|
if (selectedObjects.containsKey(menuObject.getObject())) {
|
||||||
selectedObjects.remove(menuObject.getObject());
|
selectedObjects.remove(menuObject.getObject());
|
||||||
}
|
}
|
||||||
|
clearSelectedObjects();
|
||||||
hide(getMapActivity());
|
hide(getMapActivity());
|
||||||
getMapActivity().getContextMenu()
|
getMapActivity().getContextMenu()
|
||||||
.show(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());
|
.show(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());
|
||||||
|
|
|
@ -1,24 +1,5 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
|
||||||
import net.osmand.binary.BinaryMapDataObject;
|
|
||||||
import net.osmand.data.Amenity;
|
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.data.PointDescription;
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
|
||||||
import net.osmand.map.OsmandRegions;
|
|
||||||
import net.osmand.map.WorldRegion;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
import net.osmand.util.MapUtils;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -32,13 +13,37 @@ import android.text.TextPaint;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.binary.BinaryMapDataObject;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.map.OsmandRegions;
|
||||||
|
import net.osmand.map.WorldRegion;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
|
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||||
|
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProviderSelection;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMenuProvider, IContextMenuProviderSelection {
|
||||||
|
|
||||||
private static final int ZOOM_THRESHOLD = 2;
|
private static final int ZOOM_THRESHOLD = 2;
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
|
private Paint paintSelected;
|
||||||
private Path path;
|
private Path path;
|
||||||
|
private Path pathSelected;
|
||||||
private OsmandRegions osmandRegions;
|
private OsmandRegions osmandRegions;
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +51,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
private ResourceManager rm;
|
private ResourceManager rm;
|
||||||
|
|
||||||
private MapLayerData<List<BinaryMapDataObject>> data;
|
private MapLayerData<List<BinaryMapDataObject>> data;
|
||||||
|
private List<BinaryMapDataObject> selectedObjects;
|
||||||
|
|
||||||
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
|
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
|
||||||
private static int ZOOM_AFTER_BASEMAP = 12;
|
private static int ZOOM_AFTER_BASEMAP = 12;
|
||||||
|
@ -64,6 +70,14 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
paint.setStrokeCap(Cap.ROUND);
|
paint.setStrokeCap(Cap.ROUND);
|
||||||
paint.setStrokeJoin(Join.ROUND);
|
paint.setStrokeJoin(Join.ROUND);
|
||||||
|
|
||||||
|
paintSelected = new Paint();
|
||||||
|
paintSelected.setStyle(Style.FILL_AND_STROKE);
|
||||||
|
paintSelected.setStrokeWidth(1);
|
||||||
|
paintSelected.setColor(Color.argb(100, 255, 143, 0));
|
||||||
|
paintSelected.setAntiAlias(true);
|
||||||
|
paintSelected.setStrokeCap(Cap.ROUND);
|
||||||
|
paintSelected.setStrokeJoin(Join.ROUND);
|
||||||
|
|
||||||
textPaint = new TextPaint();
|
textPaint = new TextPaint();
|
||||||
final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
||||||
DisplayMetrics dm = new DisplayMetrics();
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
|
@ -73,6 +87,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
textPaint.setTextAlign(Paint.Align.CENTER);
|
textPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
|
||||||
path = new Path();
|
path = new Path();
|
||||||
|
pathSelected = new Path();
|
||||||
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,8 +132,10 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
}
|
}
|
||||||
// draw objects
|
// draw objects
|
||||||
final List<BinaryMapDataObject> currentObjects = data.results;
|
final List<BinaryMapDataObject> currentObjects = data.results;
|
||||||
|
final List<BinaryMapDataObject> selectedObjects = this.selectedObjects;
|
||||||
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized() &&
|
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized() &&
|
||||||
currentObjects != null) {
|
(currentObjects != null || selectedObjects != null)) {
|
||||||
|
if (currentObjects != null) {
|
||||||
path.reset();
|
path.reset();
|
||||||
for (BinaryMapDataObject o : currentObjects) {
|
for (BinaryMapDataObject o : currentObjects) {
|
||||||
String downloadName = osmandRegions.getDownloadName(o);
|
String downloadName = osmandRegions.getDownloadName(o);
|
||||||
|
@ -137,6 +154,21 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
}
|
}
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
}
|
}
|
||||||
|
if (selectedObjects != null) {
|
||||||
|
pathSelected.reset();
|
||||||
|
for (BinaryMapDataObject o : selectedObjects) {
|
||||||
|
double lat = MapUtils.get31LatitudeY(o.getPoint31YTile(0));
|
||||||
|
double lon = MapUtils.get31LongitudeX(o.getPoint31XTile(0));
|
||||||
|
pathSelected.moveTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
||||||
|
for (int j = 1; j < o.getPointsLength(); j++) {
|
||||||
|
lat = MapUtils.get31LatitudeY(o.getPoint31YTile(j));
|
||||||
|
lon = MapUtils.get31LongitudeX(o.getPoint31XTile(j));
|
||||||
|
pathSelected.lineTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canvas.drawPath(pathSelected, paintSelected);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,8 +337,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LatLon getObjectLocation(Object o) {
|
public LatLon getObjectLocation(Object o) {
|
||||||
if (o instanceof WorldRegion) {
|
if (o instanceof BinaryMapDataObject) {
|
||||||
return ((WorldRegion) o).getRegionCenter();
|
String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
|
||||||
|
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
|
if (region != null) {
|
||||||
|
return region.getRegionCenter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +368,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super WorldRegion> regions) {
|
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super BinaryMapDataObject> dataObjects) {
|
||||||
int zoom = tb.getZoom();
|
int zoom = tb.getZoom();
|
||||||
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized()) {
|
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized()) {
|
||||||
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
|
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
|
||||||
|
@ -359,11 +395,25 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements ContextMen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.size() > 0) {
|
selectedObjects = result;
|
||||||
String fullName = osmandRegions.getFullName(result.get(0));
|
|
||||||
WorldRegion region = osmandRegions.getRegionData(fullName);
|
for (BinaryMapDataObject o : result) {
|
||||||
regions.add(region);
|
dataObjects.add(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelectedObject(Object o) {
|
||||||
|
if (o instanceof BinaryMapDataObject) {
|
||||||
|
List<BinaryMapDataObject> list = new LinkedList<>();
|
||||||
|
list.add((BinaryMapDataObject) o);
|
||||||
|
selectedObjects = list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearSelectedObject() {
|
||||||
|
selectedObjects = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue