diff --git a/OsmAnd/res/drawable-hdpi/warnings_speed_bump.png b/OsmAnd/res/drawable-hdpi/warnings_speed_bump.png index ce09cf4c3a..8d24847d55 100644 Binary files a/OsmAnd/res/drawable-hdpi/warnings_speed_bump.png and b/OsmAnd/res/drawable-hdpi/warnings_speed_bump.png differ diff --git a/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png b/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png index 7e15ced9b3..6f640f7ffa 100644 Binary files a/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png and b/OsmAnd/res/drawable-hdpi/warnings_speed_camera.png differ diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 3a689824c0..fa2ca0bdec 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -653,7 +653,7 @@ public class RouteCalculationResult { return null; } - public AlarmInfo getMostImportantAlarm(Location fromLoc, AlarmInfo speedAlarm) { + public AlarmInfo getMostImportantAlarm(Location fromLoc, AlarmInfo speedAlarm, boolean showCameras) { int aInfo = currentDirectionInfo; int cRoute = currentRoute; AlarmInfo mostImportant = speedAlarm; @@ -676,7 +676,7 @@ public class RouteCalculationResult { } float time = speed > 0 ? d / speed : 0; int vl = inf.updateDistanceAndGetPriority(time, d); - if(vl < value){ + if(vl < value && (!showCameras || inf.getType() == AlarmInfo.SPEED_CAMERA)){ mostImportant = inf; value = vl; } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 4b091803f8..6777259e77 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -467,7 +467,7 @@ public class RoutingHelper { return i; } - public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc){ + public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras){ float mxspeed = route.getCurrentMaxSpeed(); AlarmInfo speedAlarm = null; if(mxspeed != 0 && lastFixedLocation != null && lastFixedLocation.hasSpeed()) { @@ -482,7 +482,7 @@ public class RoutingHelper { speedAlarm = AlarmInfo.createSpeedLimit(speed); } } - return route.getMostImportantAlarm(lastFixedLocation, speedAlarm); + return route.getMostImportantAlarm(lastFixedLocation, speedAlarm, showCameras); } public String formatStreetName(String name, String ref) { diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index a09ccc355f..69fb8270d9 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -321,7 +321,7 @@ public class MapInfoLayer extends OsmandMapLayer { flp = new FrameLayout.LayoutParams((int)(78 * scaleCoefficient), (int)(78 * scaleCoefficient), Gravity.RIGHT | Gravity.BOTTOM); - flp.rightMargin = STATUS_BAR_MARGIN_X; + flp.rightMargin = (int) (10*scaleCoefficient); flp.bottomMargin = (int) (85*scaleCoefficient); alarmControl.setLayoutParams(flp); diff --git a/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java b/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java index 37674c94ec..10eebbeeb3 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteInfoControls.java @@ -16,6 +16,8 @@ import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; import net.osmand.router.TurnType; import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; @@ -516,6 +518,7 @@ public class RouteInfoControls { paintCircle.setStrokeWidth(11 * scaleCoefficient); paintCircle.setStyle(Style.STROKE); paintCircle.setAntiAlias(true); + paintCircle.setDither(true); final Paint content = new Paint(); content.setColor(Color.WHITE); content.setStyle(Style.FILL); @@ -527,18 +530,22 @@ public class RouteInfoControls { final MapInfoControl alarm = new MapInfoControl(ctx) { private String text = ""; + private Bitmap img = null; + private int imgId; @Override public boolean updateInfo() { boolean limits = settings.SHOW_SPEED_LIMITS.get(); boolean cams = settings.SHOW_CAMERAS.get(); boolean visible = false; if ((limits || cams) && routingHelper != null && routingHelper.isFollowingMode()) { - AlarmInfo alarm = routingHelper.getMostImportantAlarm(settings.METRIC_SYSTEM.get()); + AlarmInfo alarm = routingHelper.getMostImportantAlarm(settings.METRIC_SYSTEM.get(), cams); if(alarm != null) { + int locimgId = 0; if(alarm.getType() == AlarmInfo.SPEED_LIMIT) { text = alarm.getIntValue() +""; } else if(alarm.getType() == AlarmInfo.SPEED_CAMERA) { text = "CAM"; + locimgId = R.drawable.warnings_speed_camera; } else if(alarm.getType() == AlarmInfo.BORDER_CONTROL) { text = "CLO"; } else if(alarm.getType() == AlarmInfo.TOLL_BOOTH) { @@ -546,6 +553,7 @@ public class RouteInfoControls { } else if(alarm.getType() == AlarmInfo.TRAFFIC_CALMING) { // temporary omega text = "~^~"; + locimgId = R.drawable.warnings_speed_bump; } else if(alarm.getType() == AlarmInfo.STOP) { // text = "STOP"; } @@ -557,6 +565,16 @@ public class RouteInfoControls { visible = limits; } } + if(visible) { + if(locimgId != imgId) { + imgId = locimgId; + if(imgId == 0) { + img = null; + } else { + img = BitmapFactory.decodeResource(getResources(), locimgId); + } + } + } } } updateVisibility(visible); @@ -565,10 +583,14 @@ public class RouteInfoControls { @Override protected void onDraw(Canvas canvas) { - RectF f = new RectF(th / 2, th / 2, getWidth() - th / 2, getHeight() - th / 2); - canvas.drawOval(f, content); - canvas.drawOval(f, paintCircle); - canvas.drawText(text, getWidth() / 2, getHeight() / 2 + ptext.descent() + 3 * scaleCoefficient, ptext); + if(img == null) { + RectF f = new RectF(th / 2, th / 2, getWidth() - th / 2, getHeight() - th / 2); + canvas.drawOval(f, content); + canvas.drawOval(f, paintCircle); + canvas.drawText(text, getWidth() / 2, getHeight() / 2 + ptext.descent() + 3 * scaleCoefficient, ptext); + } else { + canvas.drawBitmap(img, 0, 0, paintCircle); + } } };