Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2c53b4df24
5 changed files with 125 additions and 24 deletions
|
@ -305,7 +305,11 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
appModeChanged = false;
|
appModeChanged = false;
|
||||||
|
|
||||||
if (needAcquireMenuController) {
|
if (needAcquireMenuController) {
|
||||||
acquireMenuController(restorePrevious);
|
if (!acquireMenuController(restorePrevious)) {
|
||||||
|
active = false;
|
||||||
|
clearSelectedObject(object);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
menuController.update(pointDescription, object);
|
menuController.update(pointDescription, object);
|
||||||
}
|
}
|
||||||
|
@ -510,7 +514,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acquireMenuController(boolean restorePrevious) {
|
private boolean acquireMenuController(boolean restorePrevious) {
|
||||||
MapContextMenuData menuData = null;
|
MapContextMenuData menuData = null;
|
||||||
if (menuController != null) {
|
if (menuController != null) {
|
||||||
if (menuController.isActive() && !restorePrevious) {
|
if (menuController.isActive() && !restorePrevious) {
|
||||||
|
@ -521,7 +525,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
menuController.onAcquireNewController(pointDescription, object);
|
menuController.onAcquireNewController(pointDescription, object);
|
||||||
}
|
}
|
||||||
menuController = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.STANDARD);
|
menuController = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.STANDARD);
|
||||||
menuController.setActive(true);
|
if (menuController.setActive(true)) {
|
||||||
if (menuData != null && (object != menuData.getObject())
|
if (menuData != null && (object != menuData.getObject())
|
||||||
&& (menuController.hasBackAction() || menuData.hasBackAction())) {
|
&& (menuController.hasBackAction() || menuData.hasBackAction())) {
|
||||||
historyStack.add(menuData);
|
historyStack.add(menuData);
|
||||||
|
@ -529,6 +533,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
if (!(menuController instanceof MapDataMenuController)) {
|
if (!(menuController instanceof MapDataMenuController)) {
|
||||||
menuController.buildMapDownloadButton(latLon);
|
menuController.buildMapDownloadButton(latLon);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showPreviousMenu() {
|
public boolean showPreviousMenu() {
|
||||||
|
|
|
@ -52,6 +52,8 @@ import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
||||||
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.mapillary.MapillaryImage;
|
||||||
|
import net.osmand.plus.mapillary.MapillaryMenuController;
|
||||||
import net.osmand.plus.osmedit.EditPOIMenuController;
|
import net.osmand.plus.osmedit.EditPOIMenuController;
|
||||||
import net.osmand.plus.osmedit.OsmBugMenuController;
|
import net.osmand.plus.osmedit.OsmBugMenuController;
|
||||||
import net.osmand.plus.osmedit.OsmBugsLayer.OpenStreetNote;
|
import net.osmand.plus.osmedit.OsmBugsLayer.OpenStreetNote;
|
||||||
|
@ -127,7 +129,6 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
public static MenuController getMenuController(MapActivity mapActivity,
|
public static MenuController getMenuController(MapActivity mapActivity,
|
||||||
LatLon latLon, PointDescription pointDescription, Object object,
|
LatLon latLon, PointDescription pointDescription, Object object,
|
||||||
MenuType menuType) {
|
MenuType menuType) {
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
|
||||||
MenuController menuController = null;
|
MenuController menuController = null;
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
if (object instanceof Amenity) {
|
if (object instanceof Amenity) {
|
||||||
|
@ -170,6 +171,8 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
|
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
|
||||||
} else if (object instanceof RenderedObject) {
|
} else if (object instanceof RenderedObject) {
|
||||||
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
|
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
|
||||||
|
} else if (object instanceof MapillaryImage) {
|
||||||
|
menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (menuController == null) {
|
if (menuController == null) {
|
||||||
|
@ -197,8 +200,9 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
public boolean setActive(boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
|
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
|
||||||
|
|
|
@ -252,6 +252,17 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MapillaryImageDialog show(MapActivity mapActivity, double latitude, double longitude,
|
||||||
|
String key, double ca, String title, String description) {
|
||||||
|
String imageUrl = MAPILLARY_HIRES_IMAGE_URL_TEMPLATE + key;
|
||||||
|
String viewerUrl = MAPILLARY_VIEWER_URL_TEMPLATE + key;
|
||||||
|
LatLon latLon = new LatLon(latitude, longitude);
|
||||||
|
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, imageUrl, viewerUrl,
|
||||||
|
latLon, ca, title, description);
|
||||||
|
ContextMenuCardDialogFragment.showInstance(dialog);
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
private class DownloadImageTask extends AsyncTask<Void, Void, Bitmap> {
|
private class DownloadImageTask extends AsyncTask<Void, Void, Bitmap> {
|
||||||
|
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package net.osmand.plus.mapillary;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
public class MapillaryMenuController extends MenuController {
|
||||||
|
|
||||||
|
private MapillaryImage image;
|
||||||
|
|
||||||
|
public MapillaryMenuController(MapActivity mapActivity, PointDescription pointDescription, MapillaryImage image) {
|
||||||
|
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setObject(Object object) {
|
||||||
|
if (object instanceof MapillaryImage) {
|
||||||
|
this.image = (MapillaryImage) object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setActive(boolean active) {
|
||||||
|
if (image != null && getMenuType() == MenuType.STANDARD) {
|
||||||
|
MapillaryImageDialog.show(getMapActivity(), image.getLatitude(), image.getLongitude(),
|
||||||
|
image.getKey(), image.getCa(), getMapActivity().getMyApplication().getString(R.string.mapillary), null);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return super.setActive(active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object getObject() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapillaryImage getMapillaryImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needTypeStr() {
|
||||||
|
return !Algorithms.isEmpty(getNameStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean displayDistanceDirection() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable getLeftIcon() {
|
||||||
|
return getIcon(R.drawable.ic_action_mapillary, R.color.mapillary_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needStreetName() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,9 +8,9 @@ import android.graphics.PointF;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
import com.vividsolutions.jts.geom.CoordinateSequence;
|
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import com.vividsolutions.jts.geom.LineString;
|
import com.vividsolutions.jts.geom.LineString;
|
||||||
|
import com.vividsolutions.jts.geom.MultiLineString;
|
||||||
import com.vividsolutions.jts.geom.Point;
|
import com.vividsolutions.jts.geom.Point;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -194,14 +194,14 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
QuadRect tileBounds = tileBox.getTileBounds();
|
QuadRect tileBounds = tileBox.getTileBounds();
|
||||||
double px, py, tx, ty;
|
double px, py, tx, ty;
|
||||||
float x, y;
|
float x, y;
|
||||||
float lx = -1000f;
|
|
||||||
float ly = -1000f;
|
|
||||||
float pw = point.getWidth();
|
float pw = point.getWidth();
|
||||||
float ph = point.getHeight();
|
float ph = point.getHeight();
|
||||||
float pwd = pw / 2;
|
float pwd = pw / 2;
|
||||||
float phd = ph / 2;
|
float phd = ph / 2;
|
||||||
float pwm = pw * 2;
|
//float lx = -1000f;
|
||||||
float phm = ph * 2;
|
//float ly = -1000f;
|
||||||
|
//float pwm = pw * 2;
|
||||||
|
//float phm = ph * 2;
|
||||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||||
for (List<Point> points : seqMap.values()) {
|
for (List<Point> points : seqMap.values()) {
|
||||||
for (int i = 0; i < points.size(); i++) {
|
for (int i = 0; i < points.size(); i++) {
|
||||||
|
@ -218,8 +218,8 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
//if (!QuadRect.intersects(rLast, rNow) || i == points.size() - 1) {
|
//if (!QuadRect.intersects(rLast, rNow) || i == points.size() - 1) {
|
||||||
canvas.drawBitmap(point, x - pwd, y - phd, paintPoint);
|
canvas.drawBitmap(point, x - pwd, y - phd, paintPoint);
|
||||||
visiblePoints.put(new QuadPointDouble(tileX + px, tileY + py), (Map) p.getUserData());
|
visiblePoints.put(new QuadPointDouble(tileX + px, tileY + py), (Map) p.getUserData());
|
||||||
lx = x;
|
//lx = x;
|
||||||
ly = y;
|
//ly = y;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,20 +232,31 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
if (g instanceof LineString && !g.isEmpty()) {
|
if (g instanceof LineString && !g.isEmpty()) {
|
||||||
LineString l = (LineString) g;
|
LineString l = (LineString) g;
|
||||||
if (l.getCoordinateSequence() != null && !l.isEmpty()) {
|
if (l.getCoordinateSequence() != null && !l.isEmpty()) {
|
||||||
draw(l.getCoordinateSequence(), canvas, tileBox, tileX, tileY);
|
draw(l.getCoordinateSequence().toCoordinateArray(), canvas, tileBox, tileX, tileY);
|
||||||
|
}
|
||||||
|
} else if (g instanceof MultiLineString && !g.isEmpty()) {
|
||||||
|
MultiLineString ml = (MultiLineString) g;
|
||||||
|
for (int i = 0; i < ml.getNumGeometries(); i++) {
|
||||||
|
Geometry gm = ml.getGeometryN(i);
|
||||||
|
if (gm instanceof LineString && !gm.isEmpty()) {
|
||||||
|
LineString l = (LineString) gm;
|
||||||
|
if (l.getCoordinateSequence() != null && !l.isEmpty()) {
|
||||||
|
draw(l.getCoordinateSequence().toCoordinateArray(), canvas, tileBox, tileX, tileY);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void draw(CoordinateSequence points, Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY) {
|
protected void draw(Coordinate[] points, Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY) {
|
||||||
if (points.size() > 1) {
|
if (points.length > 1) {
|
||||||
int dzoom = tileBox.getZoom() - TILE_ZOOM;
|
int dzoom = tileBox.getZoom() - TILE_ZOOM;
|
||||||
int mult = (int) Math.pow(2.0, dzoom);
|
int mult = (int) Math.pow(2.0, dzoom);
|
||||||
QuadRect tileBounds = tileBox.getTileBounds();
|
QuadRect tileBounds = tileBox.getTileBounds();
|
||||||
|
|
||||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||||
Coordinate lastPt = points.getCoordinate(0);
|
Coordinate lastPt = points[0];
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
float lastx = 0;
|
float lastx = 0;
|
||||||
|
@ -255,9 +266,9 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
double ly = lastPt.y / EXTENT;
|
double ly = lastPt.y / EXTENT;
|
||||||
boolean reCalculateLastXY = true;
|
boolean reCalculateLastXY = true;
|
||||||
|
|
||||||
int size = points.size();
|
int size = points.length;
|
||||||
for (int i = 1; i < size; i++) {
|
for (int i = 1; i < size; i++) {
|
||||||
Coordinate pt = points.getCoordinate(i);
|
Coordinate pt = points[i];
|
||||||
px = pt.x / EXTENT;
|
px = pt.x / EXTENT;
|
||||||
py = pt.y / EXTENT;
|
py = pt.y / EXTENT;
|
||||||
tpx = (tileX + px) * mult;
|
tpx = (tileX + px) * mult;
|
||||||
|
|
Loading…
Reference in a new issue