Update speed cameras icons
This commit is contained in:
parent
98d6de5977
commit
00448eca4d
6 changed files with 32 additions and 10 deletions
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 5.3 KiB |
|
@ -653,7 +653,7 @@ public class RouteCalculationResult {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlarmInfo getMostImportantAlarm(Location fromLoc, AlarmInfo speedAlarm) {
|
public AlarmInfo getMostImportantAlarm(Location fromLoc, AlarmInfo speedAlarm, boolean showCameras) {
|
||||||
int aInfo = currentDirectionInfo;
|
int aInfo = currentDirectionInfo;
|
||||||
int cRoute = currentRoute;
|
int cRoute = currentRoute;
|
||||||
AlarmInfo mostImportant = speedAlarm;
|
AlarmInfo mostImportant = speedAlarm;
|
||||||
|
@ -676,7 +676,7 @@ public class RouteCalculationResult {
|
||||||
}
|
}
|
||||||
float time = speed > 0 ? d / speed : 0;
|
float time = speed > 0 ? d / speed : 0;
|
||||||
int vl = inf.updateDistanceAndGetPriority(time, d);
|
int vl = inf.updateDistanceAndGetPriority(time, d);
|
||||||
if(vl < value){
|
if(vl < value && (!showCameras || inf.getType() == AlarmInfo.SPEED_CAMERA)){
|
||||||
mostImportant = inf;
|
mostImportant = inf;
|
||||||
value = vl;
|
value = vl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -467,7 +467,7 @@ public class RoutingHelper {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc){
|
public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras){
|
||||||
float mxspeed = route.getCurrentMaxSpeed();
|
float mxspeed = route.getCurrentMaxSpeed();
|
||||||
AlarmInfo speedAlarm = null;
|
AlarmInfo speedAlarm = null;
|
||||||
if(mxspeed != 0 && lastFixedLocation != null && lastFixedLocation.hasSpeed()) {
|
if(mxspeed != 0 && lastFixedLocation != null && lastFixedLocation.hasSpeed()) {
|
||||||
|
@ -482,7 +482,7 @@ public class RoutingHelper {
|
||||||
speedAlarm = AlarmInfo.createSpeedLimit(speed);
|
speedAlarm = AlarmInfo.createSpeedLimit(speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return route.getMostImportantAlarm(lastFixedLocation, speedAlarm);
|
return route.getMostImportantAlarm(lastFixedLocation, speedAlarm, showCameras);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatStreetName(String name, String ref) {
|
public String formatStreetName(String name, String ref) {
|
||||||
|
|
|
@ -321,7 +321,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
flp = new FrameLayout.LayoutParams((int)(78 * scaleCoefficient),
|
flp = new FrameLayout.LayoutParams((int)(78 * scaleCoefficient),
|
||||||
(int)(78 * scaleCoefficient), Gravity.RIGHT | Gravity.BOTTOM);
|
(int)(78 * scaleCoefficient), Gravity.RIGHT | Gravity.BOTTOM);
|
||||||
flp.rightMargin = STATUS_BAR_MARGIN_X;
|
flp.rightMargin = (int) (10*scaleCoefficient);
|
||||||
flp.bottomMargin = (int) (85*scaleCoefficient);
|
flp.bottomMargin = (int) (85*scaleCoefficient);
|
||||||
alarmControl.setLayoutParams(flp);
|
alarmControl.setLayoutParams(flp);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
|
@ -516,6 +518,7 @@ public class RouteInfoControls {
|
||||||
paintCircle.setStrokeWidth(11 * scaleCoefficient);
|
paintCircle.setStrokeWidth(11 * scaleCoefficient);
|
||||||
paintCircle.setStyle(Style.STROKE);
|
paintCircle.setStyle(Style.STROKE);
|
||||||
paintCircle.setAntiAlias(true);
|
paintCircle.setAntiAlias(true);
|
||||||
|
paintCircle.setDither(true);
|
||||||
final Paint content = new Paint();
|
final Paint content = new Paint();
|
||||||
content.setColor(Color.WHITE);
|
content.setColor(Color.WHITE);
|
||||||
content.setStyle(Style.FILL);
|
content.setStyle(Style.FILL);
|
||||||
|
@ -527,18 +530,22 @@ public class RouteInfoControls {
|
||||||
|
|
||||||
final MapInfoControl alarm = new MapInfoControl(ctx) {
|
final MapInfoControl alarm = new MapInfoControl(ctx) {
|
||||||
private String text = "";
|
private String text = "";
|
||||||
|
private Bitmap img = null;
|
||||||
|
private int imgId;
|
||||||
@Override
|
@Override
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
boolean limits = settings.SHOW_SPEED_LIMITS.get();
|
boolean limits = settings.SHOW_SPEED_LIMITS.get();
|
||||||
boolean cams = settings.SHOW_CAMERAS.get();
|
boolean cams = settings.SHOW_CAMERAS.get();
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if ((limits || cams) && routingHelper != null && routingHelper.isFollowingMode()) {
|
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) {
|
if(alarm != null) {
|
||||||
|
int locimgId = 0;
|
||||||
if(alarm.getType() == AlarmInfo.SPEED_LIMIT) {
|
if(alarm.getType() == AlarmInfo.SPEED_LIMIT) {
|
||||||
text = alarm.getIntValue() +"";
|
text = alarm.getIntValue() +"";
|
||||||
} else if(alarm.getType() == AlarmInfo.SPEED_CAMERA) {
|
} else if(alarm.getType() == AlarmInfo.SPEED_CAMERA) {
|
||||||
text = "CAM";
|
text = "CAM";
|
||||||
|
locimgId = R.drawable.warnings_speed_camera;
|
||||||
} else if(alarm.getType() == AlarmInfo.BORDER_CONTROL) {
|
} else if(alarm.getType() == AlarmInfo.BORDER_CONTROL) {
|
||||||
text = "CLO";
|
text = "CLO";
|
||||||
} else if(alarm.getType() == AlarmInfo.TOLL_BOOTH) {
|
} else if(alarm.getType() == AlarmInfo.TOLL_BOOTH) {
|
||||||
|
@ -546,6 +553,7 @@ public class RouteInfoControls {
|
||||||
} else if(alarm.getType() == AlarmInfo.TRAFFIC_CALMING) {
|
} else if(alarm.getType() == AlarmInfo.TRAFFIC_CALMING) {
|
||||||
// temporary omega
|
// temporary omega
|
||||||
text = "~^~";
|
text = "~^~";
|
||||||
|
locimgId = R.drawable.warnings_speed_bump;
|
||||||
} else if(alarm.getType() == AlarmInfo.STOP) {
|
} else if(alarm.getType() == AlarmInfo.STOP) {
|
||||||
// text = "STOP";
|
// text = "STOP";
|
||||||
}
|
}
|
||||||
|
@ -557,6 +565,16 @@ public class RouteInfoControls {
|
||||||
visible = limits;
|
visible = limits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(visible) {
|
||||||
|
if(locimgId != imgId) {
|
||||||
|
imgId = locimgId;
|
||||||
|
if(imgId == 0) {
|
||||||
|
img = null;
|
||||||
|
} else {
|
||||||
|
img = BitmapFactory.decodeResource(getResources(), locimgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateVisibility(visible);
|
updateVisibility(visible);
|
||||||
|
@ -565,10 +583,14 @@ public class RouteInfoControls {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
|
if(img == null) {
|
||||||
RectF f = new RectF(th / 2, th / 2, getWidth() - th / 2, getHeight() - th / 2);
|
RectF f = new RectF(th / 2, th / 2, getWidth() - th / 2, getHeight() - th / 2);
|
||||||
canvas.drawOval(f, content);
|
canvas.drawOval(f, content);
|
||||||
canvas.drawOval(f, paintCircle);
|
canvas.drawOval(f, paintCircle);
|
||||||
canvas.drawText(text, getWidth() / 2, getHeight() / 2 + ptext.descent() + 3 * scaleCoefficient, ptext);
|
canvas.drawText(text, getWidth() / 2, getHeight() / 2 + ptext.descent() + 3 * scaleCoefficient, ptext);
|
||||||
|
} else {
|
||||||
|
canvas.drawBitmap(img, 0, 0, paintCircle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue