From 67ae7516ac50a3cf106377ee118bc4e99f0ede2d Mon Sep 17 00:00:00 2001 From: sonora Date: Fri, 27 May 2016 19:50:53 +0200 Subject: [PATCH] speedAlarm: pass maxSpeed and speed --- .../net/osmand/plus/development/TestVoiceActivity.java | 2 +- OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java | 8 ++++---- OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java | 9 +++++---- OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 1c8ba47de5..64382c3823 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -199,7 +199,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity { addButton(ll, "Passing favorite 'Brewery'", builder(p).arrivedAtFavorite("Brewery")); addButton(ll, "Passing POI 'Museum'", builder(p).arrivedAtPoi("Museum")); - addButton(ll, "You are exceeding the speed limit", builder(p).speedAlarm()); + addButton(ll, "You are exceeding the speed limit", builder(p).speedAlarm(50, 65f)); addButton(ll, "Attention, speed camera", builder(p).attention("SPEED_CAMERA")); addButton(ll, "Attention, border control", builder(p).attention("BORDER_CONTROL")); addButton(ll, "Attention, railroad crossing", builder(p).attention("RAILWAY")); diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index 0accc7fc2f..93a792e652 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -170,7 +170,7 @@ public class WaypointHelper { float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f; AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, lastProjection, delta); if (speedAlarm != null) { - getVoiceRouter().announceSpeedAlarm(); + getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), lastProjection.getSpeed()); } AlarmInfo mostImportant = speedAlarm; int value = speedAlarm != null ? speedAlarm.updateDistanceAndGetPriority(0, 0) : Integer.MAX_VALUE; @@ -271,7 +271,7 @@ public class WaypointHelper { float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f; AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, loc, delta); if (speedAlarm != null) { - getVoiceRouter().announceSpeedAlarm(); + getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), loc.getSpeed()); return speedAlarm; } for (int i = 0; i < ro.getPointsLength(); i++) { @@ -286,7 +286,7 @@ public class WaypointHelper { long ms = System.currentTimeMillis(); if (ms - announcedAlarmTime > 50 * 1000) { announcedAlarmTime = ms; - getVoiceRouter().announceAlarm(info.getType()); + getVoiceRouter().announceAlarm(info, loc.getSpeed()); } return info; } @@ -381,7 +381,7 @@ public class WaypointHelper { ait.add(((AlarmInfo) pw.point).getType()); } for (AlarmInfoType t : ait) { - app.getRoutingHelper().getVoiceRouter().announceAlarm(t); + app.getRoutingHelper().getVoiceRouter().announceAlarm(new AlarmInfo(t, -1), lastKnownLocation.getSpeed()); } } else if (type == FAVORITES) { getVoiceRouter().approachFavorite(lastKnownLocation, approachPoints); diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index caf900a280..47d9d4a094 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -329,9 +329,10 @@ public class VoiceRouter { return text; } - public void announceAlarm(AlarmInfoType type) { + public void announceAlarm(AlarmInfo info, float speed) { + AlarmInfoType type = info.getType(); if (type == AlarmInfoType.SPEED_LIMIT) { - announceSpeedAlarm(); + announceSpeedAlarm(info.getIntValue(), speed); } else if (type == AlarmInfoType.SPEED_CAMERA) { if (router.getSettings().SPEAK_SPEED_CAMERA.get()) { CommandBuilder p = getNewCommandPlayerToPlay(); @@ -363,7 +364,7 @@ public class VoiceRouter { } } - public void announceSpeedAlarm() { + public void announceSpeedAlarm(int maxSpeed, float speed) { long ms = System.currentTimeMillis(); if (waitAnnouncedSpeedLimit == 0) { // wait 10 seconds before announcement @@ -380,7 +381,7 @@ public class VoiceRouter { notifyOnVoiceMessage(); lastAnnouncedSpeedLimit = ms; waitAnnouncedSpeedLimit = 0; - p.speedAlarm().play(); + p.speedAlarm(maxSpeed, speed).play(); } } } diff --git a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java index d3f7e4a5b9..51304963cd 100644 --- a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java +++ b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java @@ -130,8 +130,8 @@ public class CommandBuilder { return alt(prepareStruct(C_MAKE_UT, streetName), prepareStruct(C_MAKE_UT)); } - public CommandBuilder speedAlarm(){ - return addCommand(C_SPEAD_ALARM); + public CommandBuilder speedAlarm(int maxSpeed, float speed){ + return addCommand(C_SPEAD_ALARM, maxSpeed, speed); } public CommandBuilder attention(String type){