From d69ec3559f4c01ea8ef182f4da9d41d1986ed76f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 14 Jul 2013 02:14:52 +0200 Subject: [PATCH] Add voice warnings (preparation) --- OsmAnd/res/values/strings.xml | 5 +++++ OsmAnd/res/xml/navigation_settings.xml | 1 + OsmAnd/src/net/osmand/plus/OsmandSettings.java | 4 ++++ .../plus/activities/SettingsNavigationActivity.java | 9 +++++++++ .../osmand/plus/development/TestVoiceActivity.java | 4 +++- .../src/net/osmand/plus/routing/RoutingHelper.java | 8 ++++---- OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java | 7 +++++++ .../views/mapwidgets/RouteInfoWidgetsFactory.java | 2 +- .../src/net/osmand/plus/voice/CommandBuilder.java | 13 +++++++++++++ 9 files changed, 47 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 82eedb4e02..9971bc9f94 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,11 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Announce alarms… + Configure traffic warnings (forced stops, speed bumps), speed camera warnings, speed limits + Announce speed limit + Announce speed cameras + Announce traffic warnings \nTime span: %1$d:%2$02d:%3$02d \nTime moving: %1$d:%2$02d:%3$02d Browse map diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml index 50730bf35d..b1bbb0812e 100644 --- a/OsmAnd/res/xml/navigation_settings.xml +++ b/OsmAnd/res/xml/navigation_settings.xml @@ -9,6 +9,7 @@ + SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", true).makeProfile().cache(); public final OsmandPreference SHOW_CAMERAS = new BooleanPreference("show_cameras", true).makeProfile().cache(); public final OsmandPreference SHOW_LANES = new BooleanPreference("show_lanes", true).makeProfile().cache(); + + public final OsmandPreference SPEAK_TRAFFIC_WARNINGS = new BooleanPreference("speak_traffic_warnings", true).makeProfile().cache(); + public final OsmandPreference SPEAK_SPEAD_CAMERAS = new BooleanPreference("speak_cameras", true).makeProfile().cache(); + public final OsmandPreference SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", true).makeProfile().cache(); public final OsmandPreference AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeProfile().cache(); public final OsmandPreference AVOID_MOTORWAY = new BooleanPreference("avoid_motorway", false).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 7d87676699..a1acbb9c4d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -25,6 +25,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { private Preference avoidRouting; private Preference preferRouting; private Preference showAlarms; + private Preference speakAlarms; private ListPreference routerServicePreference; public static final String MORE_VALUE = "MORE_VALUE"; @@ -91,6 +92,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { showAlarms = (Preference) screen.findPreference("show_routing_alarms"); showAlarms.setOnPreferenceClickListener(this); + + speakAlarms = (Preference) screen.findPreference("speak_routing_alarms"); + speakAlarms.setOnPreferenceClickListener(this); } @@ -167,6 +171,11 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { getString(R.string.show_lanes) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS, settings.SHOW_CAMERAS, settings.SHOW_LANES }); return true; + } else if (preference == speakAlarms) { + showBooleanSettings(new String[] { getString(R.string.speak_traffic_warnings), getString(R.string.speak_cameras), + getString(R.string.speak_speed_limit) }, new OsmandPreference[] { settings.SPEAK_TRAFFIC_WARNINGS, + settings.SPEAK_SPEAD_CAMERAS , settings.SPEAK_SPEED_LIMIT}); + return true; } return false; } diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 0e25db9239..15cef2b5b6 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -97,7 +97,7 @@ public class TestVoiceActivity extends SherlockActivity { addButton(ll, "When possible, make a U-turn", builder(p).makeUTwp()); addButton(ll, "Prepare to enter a roundabout after 750m", builder(p).prepareRoundAbout(750)); addButton(ll, "After 450m enter the roundabout and take the 1st exit", builder(p).roundAbout(450, 0, 1)); - addButton(ll, "Roundabout: Take the 3rd exit", builder(p).roundAbout(0, 3)); + addButton(ll, "Roundabout: Take the 2th exit", builder(p).roundAbout(0, 2)); addButton(ll, "GPS signal lost", builder(p).gpsLocationLost()); addButton(ll, "Route recalculated (23150m)", builder(p).routeRecalculated(23150)); addButton(ll, "Continue straight ahead", builder(p).goAhead()); @@ -106,6 +106,8 @@ public class TestVoiceActivity extends SherlockActivity { addButton(ll, "Arrive at waypoint", builder(p).arrivedAtIntermediatePoint()); addButton(ll, "Follow the road for 800m and arrive at destination", builder(p).goAhead(800).andArriveAtDestination()); addButton(ll, "Arrive at destination", builder(p).arrivedAtDestination()); + addButton(ll, "You exceed speed limit", builder(p).speedAlarm()); + addButton(ll, "Attention (bump, speed camera)", builder(p).attention()); ll.forceLayout(); } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 8cfa68eab1..7aa94d51a7 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -538,18 +538,18 @@ public class RoutingHelper { AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, lastProjection); AlarmInfo alarm = route.getMostImportantAlarm(lastProjection, speedAlarm, showCameras); if(alarm != null) { -// voiceRouter.announceAlarm(alarm); + voiceRouter.announceAlarm(alarm); } return alarm; } - public static AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, + public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, MetricsConstants mc, boolean showCameras) { float mxspeed = ro.getMaximumSpeed(); AlarmInfo speedAlarm = createSpeedAlarm(mc, mxspeed, loc); if (speedAlarm != null) { -// voiceRouter.announceAlarm(speedAlarm); + voiceRouter.announceAlarm(speedAlarm); return speedAlarm; } for (int i = 0; i < ro.getPointsLength(); i++) { @@ -561,7 +561,7 @@ public class RoutingHelper { AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0); if (info != null) { if (info.getType() != AlarmInfo.SPEED_CAMERA || showCameras) { -// voiceRouter.announceAlarm(info); + voiceRouter.announceAlarm(info); return info; } } diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 7b9c11da2c..32ac99ab48 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -178,6 +178,12 @@ public class VoiceRouter { } + + public void announceAlarm(AlarmInfo alarm) { + // TODO Auto-generated method stub + + } + /** * Updates status of voice guidance * @param currentLocation @@ -522,4 +528,5 @@ public class VoiceRouter { } } + } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index f9b95c8ff0..a9690c8575 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -638,7 +638,7 @@ public class RouteInfoWidgetsFactory { RouteDataObject ro = locationProvider.getLastKnownRouteSegment(); Location loc = locationProvider.getLastKnownLocation(); if(ro != null && loc != null) { - alarm = RoutingHelper.calculateMostImportantAlarm(ro, loc, settings.METRIC_SYSTEM.get(), cams); + alarm = rh.calculateMostImportantAlarm(ro, loc, settings.METRIC_SYSTEM.get(), cams); } else { alarm = null; } diff --git a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java index cd5e7c7f58..efdcec0d9c 100644 --- a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java +++ b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java @@ -29,6 +29,9 @@ public class CommandBuilder { protected static final String C_AND_ARRIVE_INTERMEDIATE = "and_arrive_intermediate"; //$NON-NLS-1$ protected static final String C_REACHED_INTERMEDIATE = "reached_intermediate"; //$NON-NLS-1$ protected static final String C_THEN = "then"; //$NON-NLS-1$ + protected static final String C_SPEAD_ALARM = "speed_alarm"; //$NON-NLS-1$ + protected static final String C_ATTENTION = "attention"; //$NON-NLS-1$ + protected static final String C_BEAR_LEFT = "bear_left"; //$NON-NLS-1$ protected static final String C_BEAR_RIGHT = "bear_right"; //$NON-NLS-1$ @@ -107,6 +110,16 @@ public class CommandBuilder { return addCommand(C_MAKE_UT); } + public CommandBuilder speedAlarm(){ + return addCommand(C_SPEAD_ALARM); + } + + public CommandBuilder attention(){ + return addCommand(C_ATTENTION); + } + + + public CommandBuilder makeUT(double dist){ return addCommand(C_MAKE_UT, dist); }