Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements distance / speed limit voice announcement and displaying for speed cameras (#3721 and #8108, android part) + minor fix for alert icon resizing on large screens #12923

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
39 changes: 39 additions & 0 deletions OsmAnd/res/drawable/warnings_speed_camera_dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="92dp"
android:height="92dp"
android:viewportWidth="92"
android:viewportHeight="92">

<path
android:pathData="M14,7H78C81.866,7 85,10.134 85,14V77C85,80.866 81.866,84 78,84H14C10.134,84 7,80.866 7,77V14C7,10.134 10.134,7 14,7Z"
android:fillColor="#000000"
android:fillAlpha="0.2"
android:fillType="evenOdd"/>
<path
android:pathData="M8,14C8,10.6863 10.6863,8 14,8H78C81.3137,8 84,10.6863 84,14V77C84,80.3137 81.3137,83 78,83H14C10.6863,83 8,80.3137 8,77V14Z"
android:fillColor="#0055FF"/>
<path
android:pathData="M78,11H14C12.3431,11 11,12.3431 11,14V77C11,78.6569 12.3431,80 14,80H78C79.6569,80 81,78.6569 81,77V14C81,12.3431 79.6569,11 78,11ZM14,8C10.6863,8 8,10.6863 8,14V77C8,80.3137 10.6863,83 14,83H78C81.3137,83 84,80.3137 84,77V14C84,10.6863 81.3137,8 78,8H14Z"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"/>
<path
android:pathData="M14,15C14,14.4477 14.4477,14 15,14H77C77.5523,14 78,14.4477 78,15V55C78,55.5523 77.5523,56 77,56H15C14.4477,56 14,55.5523 14,55V15Z"
android:fillColor="#FFFFFF"/>

<path
android:pathData="M29,20H47C48.657,20 50,21.343 50,23V47C50,48.657 48.657,50 47,50H29C27.343,50 26,48.657 26,47V23C26,21.343 27.343,20 29,20ZM36,34C39.314,34 42,36.686 42,40C42,43.314 39.314,46 36,46C32.686,46 30,43.314 30,40C30,36.686 32.686,34 36,34ZM42,22C44.209,22 46,23.791 46,26C46,28.209 44.209,30 42,30C39.791,30 38,28.209 38,26C38,23.791 39.791,22 42,22Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M36,38C37.105,38 38,38.895 38,40C38,41.105 37.105,42 36,42C34.895,42 34,41.105 34,40C34,38.895 34.895,38 36,38Z"
android:fillColor="#000000"/>
<path
android:pathData="M42,25C42.552,25 43,25.448 43,26C43,26.552 42.552,27 42,27C41.448,27 41,26.552 41,26C41,25.448 41.448,25 42,25Z"
android:fillColor="#000000"/>
<path
android:pathData="M52,26H56V42H52V26Z"
android:fillColor="#000000"/>
<path
android:pathData="M58,30H62V34H66V42H62V50H52V46H58V30Z"
android:fillColor="#000000"/>
</vector>
46 changes: 46 additions & 0 deletions OsmAnd/res/drawable/warnings_speed_camera_dist_lim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="92dp"
android:height="92dp"
android:viewportWidth="92"
android:viewportHeight="92">

<path
android:pathData="M14,7H78C81.866,7 85,10.134 85,14V77C85,80.866 81.866,84 78,84H14C10.134,84 7,80.866 7,77V14C7,10.134 10.134,7 14,7Z"
android:fillColor="#000000"
android:fillAlpha="0.2"
android:fillType="evenOdd"/>
<path
android:pathData="M8,14C8,10.6863 10.6863,8 14,8H78C81.3137,8 84,10.6863 84,14V77C84,80.3137 81.3137,83 78,83H14C10.6863,83 8,80.3137 8,77V14Z"
android:fillColor="#0055FF"/>
<path
android:pathData="M78,11H14C12.3431,11 11,12.3431 11,14V77C11,78.6569 12.3431,80 14,80H78C79.6569,80 81,78.6569 81,77V14C81,12.3431 79.6569,11 78,11ZM14,8C10.6863,8 8,10.6863 8,14V77C8,80.3137 10.6863,83 14,83H78C81.3137,83 84,80.3137 84,77V14C84,10.6863 81.3137,8 78,8H14Z"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"/>
<path
android:pathData="M14,15C14,14.4477 14.4477,14 15,14H77C77.5523,14 78,14.4477 78,15V55C78,55.5523 77.5523,56 77,56H15C14.4477,56 14,55.5523 14,55V15Z"
android:fillColor="#FFFFFF"/>

<path
android:pathData="M19,24H37C38.657,24 40,25.343 40,27V51C40,52.657 38.657,54 37,54H19C17.343,54 16,52.657 16,51V27C16,25.343 17.343,24 19,24ZM26,38C29.314,38 32,40.686 32,44C32,47.314 29.314,50 26,50C22.686,50 20,47.314 20,44C20,40.686 22.686,38 26,38ZM32,26C34.209,26 36,27.791 36,30C36,32.209 34.209,34 32,34C29.791,34 28,32.209 28,30C28,27.791 29.791,26 32,26Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M26,42C27.105,42 28,42.895 28,44C28,45.105 27.105,46 26,46C24.895,46 24,45.105 24,44C24,42.895 24.895,42 26,42Z"
android:fillColor="#000000"/>
<path
android:pathData="M32,29C32.552,29 33,29.448 33,30C33,30.552 32.552,31 32,31C31.448,31 31,30.552 31,30C31,29.448 31.448,29 32,29Z"
android:fillColor="#000000"/>
<path
android:pathData="M42,30H46V46H42V30Z"
android:fillColor="#000000"/>
<path
android:pathData="M48,34H52V38H56V46H52V54H42V50H48V34Z"
android:fillColor="#000000"/>

<path
android:pathData="M74,0C83.941,0 92,8.059 92,18C92,27.941 83.941,36 74,36C64.059,36 56,27.941 56,18C56,8.059 64.059,0 74,0Z"
android:fillColor="#FF0000"/>
<path
android:pathData="M74,3C82.284,3 89,9.716 89,18C89,26.284 82.284,33 74,33C65.716,33 59,26.284 59,18C59,9.716 65.716,3 74,3Z"
android:fillColor="#FFFFFF"/>
</vector>
38 changes: 38 additions & 0 deletions OsmAnd/res/drawable/warnings_speed_camera_dist_lim_us.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="92dp"
android:height="92dp"
android:viewportWidth="92"
android:viewportHeight="92">

<path
android:pathData="M8,14C8,10.6863 10.6863,8 14,8H78C81.3137,8 84,10.6863 84,14V77C84,80.3137 81.3137,83 78,83H14C10.6863,83 8,80.3137 8,77V14Z"
android:fillColor="#FFD200"/>
<path
android:pathData="M78,11H14C12.3431,11 11,12.3431 11,14V77C11,78.6569 12.3431,80 14,80H78C79.6569,80 81,78.6569 81,77V14C81,12.3431 79.6569,11 78,11ZM14,8C10.6863,8 8,10.6863 8,14V77C8,80.3137 10.6863,83 14,83H78C81.3137,83 84,80.3137 84,77V14C84,10.6863 81.3137,8 78,8H14Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>

<path
android:pathData="M59,0H89C90.657,0 92,1.343 92,3V33C92,34.657 90.657,36 89,36H59C57.343,36 56,34.657 56,33V3C56,1.343 57.343,0 59,0Z"
android:fillColor="#000000"/>
<path
android:pathData="M60,2H88C89.105,2 90,2.895 90,4V32C90,33.105 89.105,34 88,34H60C58.895,34 58,33.105 58,32V4C58,2.895 58.895,2 60,2Z"
android:fillColor="#FFFFFF"/>

<path
android:pathData="M19,24H37C38.657,24 40,25.343 40,27V51C40,52.657 38.657,54 37,54H19C17.343,54 16,52.657 16,51V27C16,25.343 17.343,24 19,24ZM26,38C29.314,38 32,40.686 32,44C32,47.314 29.314,50 26,50C22.686,50 20,47.314 20,44C20,40.686 22.686,38 26,38ZM32,26C34.209,26 36,27.791 36,30C36,32.209 34.209,34 32,34C29.791,34 28,32.209 28,30C28,27.791 29.791,26 32,26Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M26,42C27.105,42 28,42.895 28,44C28,45.105 27.105,46 26,46C24.895,46 24,45.105 24,44C24,42.895 24.895,42 26,42Z"
android:fillColor="#000000"/>
<path
android:pathData="M32,29C32.552,29 33,29.448 33,30C33,30.552 32.552,31 32,31C31.448,31 31,30.552 31,30C31,29.448 31.448,29 32,29Z"
android:fillColor="#000000"/>
<path
android:pathData="M42,30H46V46H42V30Z"
android:fillColor="#000000"/>
<path
android:pathData="M48,34H52V38H56V46H52V54H42V50H48V34Z"
android:fillColor="#000000"/>
</vector>
31 changes: 31 additions & 0 deletions OsmAnd/res/drawable/warnings_speed_camera_dist_us.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="92dp"
android:height="92dp"
android:viewportWidth="92"
android:viewportHeight="92">

<path
android:pathData="M8,14C8,10.6863 10.6863,8 14,8H78C81.3137,8 84,10.6863 84,14V77C84,80.3137 81.3137,83 78,83H14C10.6863,83 8,80.3137 8,77V14Z"
android:fillColor="#FFD200"/>
<path
android:pathData="M78,11H14C12.3431,11 11,12.3431 11,14V77C11,78.6569 12.3431,80 14,80H78C79.6569,80 81,78.6569 81,77V14C81,12.3431 79.6569,11 78,11ZM14,8C10.6863,8 8,10.6863 8,14V77C8,80.3137 10.6863,83 14,83H78C81.3137,83 84,80.3137 84,77V14C84,10.6863 81.3137,8 78,8H14Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>

<path
android:pathData="M29,20H47C48.657,20 50,21.343 50,23V47C50,48.657 48.657,50 47,50H29C27.343,50 26,48.657 26,47V23C26,21.343 27.343,20 29,20ZM36,34C39.314,34 42,36.686 42,40C42,43.314 39.314,46 36,46C32.686,46 30,43.314 30,40C30,36.686 32.686,34 36,34ZM42,22C44.209,22 46,23.791 46,26C46,28.209 44.209,30 42,30C39.791,30 38,28.209 38,26C38,23.791 39.791,22 42,22Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M36,38C37.105,38 38,38.895 38,40C38,41.105 37.105,42 36,42C34.895,42 34,41.105 34,40C34,38.895 34.895,38 36,38Z"
android:fillColor="#000000"/>
<path
android:pathData="M42,25C42.552,25 43,25.448 43,26C43,26.552 42.552,27 42,27C41.448,27 41,26.552 41,26C41,25.448 41.448,25 42,25Z"
android:fillColor="#000000"/>
<path
android:pathData="M52,26H56V42H52V26Z"
android:fillColor="#000000"/>
<path
android:pathData="M58,30H62V34H66V42H62V50H52V46H58V30Z"
android:fillColor="#000000"/>
</vector>
4 changes: 2 additions & 2 deletions OsmAnd/res/layout-land/map_hud_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/map_alarm_warning_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
osmand:srcCompat="@drawable/warnings_limit"/>

Expand Down
4 changes: 2 additions & 2 deletions OsmAnd/res/layout/map_hud_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/map_alarm_warning_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
osmand:srcCompat="@drawable/warnings_limit"/>

Expand Down
4 changes: 3 additions & 1 deletion OsmAnd/res/values-large/sizes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
<dimen name="map_button_shadow_margin">6dp</dimen>
<dimen name="map_button_shadow_width">84dp</dimen>
<dimen name="map_alarm_size">138dp</dimen>
<dimen name="map_alarm_bottom_text_margin">12dp</dimen>
<dimen name="map_alarm_bottom_text_margin">15dp</dimen>
<dimen name="map_alarm_text_size">35sp</dimen>
<dimen name="map_alarm_text_top_padding">30dp</dimen>
<dimen name="map_alarm_bottom_text_size">22sp</dimen>
<dimen name="map_alarm_bottom_si_text_size">18sp</dimen>
<dimen name="map_alarm_bottom_margin">131dp</dimen>
<dimen name="map_alarm_bottom_margin_land">81dp</dimen>
<dimen name="map_alarm_speed_camera_speed_info_size">54dp</dimen>
<dimen name="map_alarm_speed_camera_speed_info_text_size">22sp</dimen>

<dimen name="map_widget_icon">36dp</dimen>
<dimen name="map_widget_height">48dp</dimen>
Expand Down
4 changes: 3 additions & 1 deletion OsmAnd/res/values/sizes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dimen name="map_ruler_width">120dp</dimen>
<dimen name="map_ruler_bottom_margin">9dp</dimen>
<dimen name="map_alarm_size">92dp</dimen>
<dimen name="map_alarm_bottom_text_margin">8dp</dimen>
<dimen name="map_alarm_bottom_text_margin">10dp</dimen>


<dimen name="map_alarm_bottom_margin">87dp</dimen>
Expand Down Expand Up @@ -152,6 +152,8 @@
<dimen name="map_alarm_text_top_padding">20dp</dimen>
<dimen name="map_alarm_bottom_text_size">16sp</dimen>
<dimen name="map_alarm_bottom_si_text_size">12sp</dimen>
<dimen name="map_alarm_speed_camera_speed_info_size">36dp</dimen>
<dimen name="map_alarm_speed_camera_speed_info_text_size">16sp</dimen>
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
<dimen name="map_widget_icon_margin">2dp</dimen>
Expand Down
17 changes: 9 additions & 8 deletions OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ private void addButtons(final LinearLayout ll, CommandPlayer p) {

addButton(ll, "Attention prompts:", builder(p));
addButton(ll, "\u25BA (9.1) You are exceeding the speed limit '50' (18 m/s)", builder(p).speedAlarm(50, 18f));
addButton(ll, "\u25BA (9.2) Attention, speed camera", builder(p).attention("SPEED_CAMERA"));
addButton(ll, "\u25BA (9.3) Attention, border control", builder(p).attention("BORDER_CONTROL"));
addButton(ll, "\u25BA (9.4) Attention, railroad crossing", builder(p).attention("RAILWAY"));
addButton(ll, "\u25BA (9.5) Attention, traffic calming", builder(p).attention("TRAFFIC_CALMING"));
addButton(ll, "\u25BA (9.6) Attention, toll booth", builder(p).attention("TOLL_BOOTH"));
addButton(ll, "\u25BA (9.7) Attention, stop sign", builder(p).attention("STOP"));
addButton(ll, "\u25BA (9.8) Attention, pedestrian crosswalk", builder(p).attention("PEDESTRIAN"));
addButton(ll, "\u25BA (9.9) Attention, tunnel", builder(p).attention("TUNNEL"));
addButton(ll, "\u25BA (9.2) Attention, speed camera, distance 650m, speed limit '50' (18 m/s)", builder(p).speedCameraAlarm(650f, 50));
addButton(ll, "\u25BA (9.3) Attention, speed camera", builder(p).attention("SPEED_CAMERA"));
addButton(ll, "\u25BA (9.4) Attention, border control", builder(p).attention("BORDER_CONTROL"));
addButton(ll, "\u25BA (9.5) Attention, railroad crossing", builder(p).attention("RAILWAY"));
addButton(ll, "\u25BA (9.6) Attention, traffic calming", builder(p).attention("TRAFFIC_CALMING"));
addButton(ll, "\u25BA (9.7) Attention, toll booth", builder(p).attention("TOLL_BOOTH"));
addButton(ll, "\u25BA (9.8) Attention, stop sign", builder(p).attention("STOP"));
addButton(ll, "\u25BA (9.9) Attention, pedestrian crosswalk", builder(p).attention("PEDESTRIAN"));
addButton(ll, "\u25BA (9.10) Attention, tunnel", builder(p).attention("TUNNEL"));

addButton(ll, "Other prompts:", builder(p));
addButton(ll, "\u25BA (10.1) GPS signal lost", builder(p).gpsLocationLost());
Expand Down
16 changes: 15 additions & 1 deletion OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ public AlarmInfo getMostImportantAlarm(SpeedConstants sc, boolean showCameras) {
if (!atd.isTurnStateActive(0, d, STATE_LONG_PNT_APPROACH)) {
break;
}

// Set actual distance to speed camera
if (inf.getType() == AlarmInfoType.SPEED_CAMERA) {
inf.setFloatValue(d);
}

float time = speed > 0 ? d / speed : Integer.MAX_VALUE;
int vl = inf.updateDistanceAndGetPriority(time, d);
if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) {
Expand Down Expand Up @@ -460,7 +466,15 @@ public void announceVisibleLocations() {
} else if (type == ALARMS) {
for (LocationPointWrapper pw : approachPoints) {
AlarmInfo alarm = (AlarmInfo) pw.point;
voiceRouter.announceAlarm(new AlarmInfo(alarm.getType(), -1), lastKnownLocation.getSpeed());
AlarmInfo alarmCopy = new AlarmInfo(alarm.getType(), -1);

// Set actual distance and copy max speed to speed camera
if (alarmCopy.getType() == AlarmInfoType.SPEED_CAMERA){
alarmCopy.setFloatValue(route.getDistanceToPoint(alarm.getLocationIndex()));
alarmCopy.setIntValue(alarm.getIntValue());
}

voiceRouter.announceAlarm(alarmCopy, lastKnownLocation.getSpeed());
lastAnnouncedAlarms.put(alarm.getType(), alarm);
}
} else if (type == FAVORITES) {
Expand Down
30 changes: 28 additions & 2 deletions OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.helpers.enums.SpeedConstants;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.router.ExitInfo;
Expand Down Expand Up @@ -260,10 +261,12 @@ private static double getDistanceToLocation(List<Location> locations, LatLon p,
locations.get(currentLocation).getLatitude(), locations.get(currentLocation).getLongitude());
}

private static void attachAlarmInfo(List<AlarmInfo> alarms, RouteSegmentResult res, int intId, int locInd) {
private static void attachAlarmInfo(List<AlarmInfo> alarms, RouteSegmentResult res, int intId, int locInd, SpeedConstants sc) {
int[] pointTypes = res.getObject().getPointTypes(intId);
if (pointTypes != null) {
RouteRegion reg = res.getObject().region;
float maxSpeed = -1;
AlarmInfo speedCameraAlarmInfo = null;
for (int r = 0; r < pointTypes.length; r++) {
RouteTypeRule typeRule = reg.quickGetEncodingRule(pointTypes[r]);
int x31 = res.getObject().getPoint31XTile(intId);
Expand All @@ -272,9 +275,32 @@ private static void attachAlarmInfo(List<AlarmInfo> alarms, RouteSegmentResult r
loc.setLatitude(MapUtils.get31LatitudeY(y31));
loc.setLongitude(MapUtils.get31LongitudeX(x31));
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, locInd, loc);

// For STOP first check if it has directional info
if ((info != null) && !((info.getType() == AlarmInfoType.STOP) && !res.getObject().isStopApplicable(res.isForwardDirection(), intId, res.getStartPointIndex(), res.getEndPointIndex()))) {
alarms.add(info);

if (info.getType() == AlarmInfoType.SPEED_CAMERA) {
speedCameraAlarmInfo = info;
}
}

if (maxSpeed <= 0 || maxSpeed == RouteDataObject.NONE_MAX_SPEED) {
maxSpeed = typeRule.maxSpeed();
}
}

if (speedCameraAlarmInfo != null) {
if (maxSpeed <= 0 || maxSpeed == RouteDataObject.NONE_MAX_SPEED) {
maxSpeed = res.getObject().getMaximumSpeed(res.isForwardDirection());
}

if (maxSpeed > 0 && maxSpeed != RouteDataObject.NONE_MAX_SPEED) {
if (sc.imperial) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks strange that here we store converted data, I guess it should happen at the end UI / Voice prompt cause here it's to early to do conversions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vshcherb To be honest, I also had strong doubts when writing this code.

On the right hand it is not the best place for conversion, on the left hand the AlarmInfo.intValue also used for speed limit alarm, and in that case the field will contain converted value.

It could be very confusing if the same field will contain speed value in different units of measurement.

Probably, it would be better to introduce dedicated explicit field in AlarmInfo for meters per second speed and provide getter method to provide converted speed. But it will require re-factoring in multiple places, and also I guess there was signifact reason to use several common fields like "floatValue", "intValue" etc. instead of "maxSpeedInMetersPerSecond", "distance" etc...

speedCameraAlarmInfo.setIntValue(Math.round(maxSpeed * 3.6f / 1.6f));
} else {
speedCameraAlarmInfo.setIntValue(Math.round(maxSpeed * 3.6f));
}
}
}
}
Expand Down Expand Up @@ -378,7 +404,7 @@ private static List<RouteSegmentResult> convertVectorResult(List<RouteDirectionI
lastHeight = h;
}
locations.add(n);
attachAlarmInfo(alarms, s, i, locations.size());
attachAlarmInfo(alarms, s, i, locations.size(), ctx.getSettings().SPEED_SYSTEM.get());
segmentsToPopulate.add(s);
if (i == s.getEndPointIndex()) {
break;
Expand Down
24 changes: 20 additions & 4 deletions OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,19 @@ public void announceAlarm(AlarmInfo info, float speed) {
AlarmInfoType type = info.getType();
if (type == AlarmInfoType.SPEED_LIMIT) {
announceSpeedAlarm(info.getIntValue(), speed);
} else if (type == AlarmInfoType.SPEED_CAMERA) {
OsmandSettings settings = router.getSettings();
if (settings.SPEAK_SPEED_CAMERA.get()) {
announceSpeedCameraAlarm(info.getFloatValue(), info.getIntValue());
}
} else {
OsmandSettings settings = router.getSettings();
boolean speakTrafficWarnings = settings.SPEAK_TRAFFIC_WARNINGS.get();
boolean speakTunnels = type == AlarmInfoType.TUNNEL && settings.SPEAK_TUNNELS.get();
boolean speakPedestrian = type == AlarmInfoType.PEDESTRIAN && settings.SPEAK_PEDESTRIAN.get();
boolean speakSpeedCamera = type == AlarmInfoType.SPEED_CAMERA && settings.SPEAK_SPEED_CAMERA.get();
boolean speakPrefType = type == AlarmInfoType.TUNNEL || type == AlarmInfoType.PEDESTRIAN || type == AlarmInfoType.SPEED_CAMERA;
boolean speakPrefType = type == AlarmInfoType.TUNNEL || type == AlarmInfoType.PEDESTRIAN;

if (speakSpeedCamera || speakPedestrian || speakTunnels || speakTrafficWarnings && !speakPrefType) {
if (speakPedestrian || speakTunnels || speakTrafficWarnings && !speakPrefType) {
CommandBuilder p = getNewCommandPlayerToPlay();
if (p != null) {
p.attention(String.valueOf(type));
Expand Down Expand Up @@ -365,7 +369,19 @@ public void announceSpeedAlarm(int maxSpeed, float speed) {
}
}
}


private void announceSpeedCameraAlarm(double dist, int maxSpeed) {
CommandBuilder p = getNewCommandPlayerToPlay();
if (p != null) {
if (dist > 0 && maxSpeed > 0) {
p.speedCameraAlarm(dist, maxSpeed);
} else {
p.attention(String.valueOf(AlarmInfoType.SPEED_CAMERA));
}
}
play(p);
}

private boolean isTargetPoint(NextDirectionInfo info) {
boolean in = info != null && info.intermediatePoint;
boolean target = info == null || info.directionInfo == null
Expand Down
Loading