From 76996469da490dd7c2f55b880f9b823d8a4c08c9 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 26 Nov 2011 13:35:48 +0100 Subject: [PATCH] Update look and feel --- .../plus/activities/MapActivityLayers.java | 10 ++-- .../osmand/plus/views/PointLocationLayer.java | 58 +++++++++++-------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index 21fba801b2..28f96bf4c7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -126,12 +126,12 @@ public class MapActivityLayers { // 5.5 transport info layer transportInfoLayer = new TransportInfoLayer(TransportRouteHelper.getInstance()); mapView.addLayer(transportInfoLayer, 5.5f); - // 6. point navigation layer - navigationLayer = new PointNavigationLayer(); - mapView.addLayer(navigationLayer, 6); - // 7. point location layer + // 6. point location layer locationLayer = new PointLocationLayer(); - mapView.addLayer(locationLayer, 7); + mapView.addLayer(locationLayer, 6); + // 7. point navigation layer + navigationLayer = new PointNavigationLayer(); + mapView.addLayer(navigationLayer, 7); // 8. map info layer mapInfoLayer = new MapInfoLayer(activity, routeLayer); mapView.addLayer(mapInfoLayer, 8); diff --git a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java index 3821150e6b..e7abcb7e3e 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java @@ -22,6 +22,7 @@ public class PointLocationLayer implements OsmandMapLayer { private Paint locationPaint; private Paint area; + private Paint aroundArea; private Paint headingPaint; protected Location lastKnownLocation = null; @@ -42,7 +43,13 @@ public class PointLocationLayer implements OsmandMapLayer { area = new Paint(); area.setColor(Color.BLUE); - area.setAlpha(40); + area.setAlpha(40); + + aroundArea = new Paint(); + aroundArea.setColor(Color.rgb(112, 124, 220)); + aroundArea.setStyle(Style.STROKE); + aroundArea.setStrokeWidth(1); + aroundArea.setAntiAlias(true); headingPaint = new Paint(); headingPaint.setColor(Color.BLUE); @@ -66,41 +73,46 @@ public class PointLocationLayer implements OsmandMapLayer { private RectF getHeadingRect(int locationX, int locationY){ - int rad = Math.min(3*view.getWidth()/8, 3*view.getHeight()/8); + int rad = Math.min(3 * view.getWidth() / 8, 3 * view.getHeight() / 8); return new RectF(locationX - rad, locationY - rad, locationX + rad, locationY + rad); } @Override public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, boolean nightMode) { + // draw + if(lastKnownLocation == null || view == null){ + return; + } + int locationX = view.getMapXForPoint(lastKnownLocation.getLongitude()); + int locationY = view.getMapYForPoint(lastKnownLocation.getLatitude()); + + int radius = MapUtils.getLengthXFromMeters(view.getZoom(), view.getLatitude(), view.getLongitude(), + lastKnownLocation.getAccuracy(), view.getTileSize(), view.getWidth()); + if (radius > RADIUS * dm.density) { + int allowedRad = Math.min(view.getWidth() / 2, view.getHeight() / 2); + canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), area); + canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), aroundArea); + } + // draw bearing/direction/location if (isLocationVisible(lastKnownLocation)) { checkAppMode(view.getSettings().getApplicationMode()); - - int locationX = view.getMapXForPoint(lastKnownLocation.getLongitude()); - int locationY = view.getMapYForPoint(lastKnownLocation.getLatitude()); - - int radius = MapUtils.getLengthXFromMeters(view.getZoom(), view.getLatitude(), view.getLongitude(), - lastKnownLocation.getAccuracy(), view.getTileSize(), view.getWidth()); boolean isBearing = lastKnownLocation.hasBearing(); - if(!isBearing){ - canvas.drawBitmap(locationIcon, locationX - locationIcon.getWidth() / 2, - locationY - locationIcon.getHeight() / 2, locationPaint); + if (!isBearing) { + canvas.drawBitmap(locationIcon, locationX - locationIcon.getWidth() / 2, locationY - locationIcon.getHeight() / 2, + locationPaint); } - if (radius > RADIUS * dm.density) { - canvas.drawCircle(locationX, locationY, radius, area); + + if (heading != null) { + canvas.drawArc(getHeadingRect(locationX, locationY), heading - HEADING_ANGLE / 2 - 90, HEADING_ANGLE, true, headingPaint); } - - if(heading != null){ - canvas.drawArc(getHeadingRect(locationX, locationY), - heading - HEADING_ANGLE/ 2 - 90, HEADING_ANGLE, true, headingPaint); - } - - if(isBearing){ + + if (isBearing) { float bearing = lastKnownLocation.getBearing(); canvas.rotate(bearing - 90, locationX, locationY); - canvas.drawBitmap(bearingIcon, locationX - bearingIcon.getWidth() / 2, - locationY - bearingIcon.getHeight() / 2, locationPaint); + canvas.drawBitmap(bearingIcon, locationX - bearingIcon.getWidth() / 2, locationY - bearingIcon.getHeight() / 2, + locationPaint); } - + } }