Add voice warnings (preparation)
This commit is contained in:
parent
d69ec3559f
commit
17e0de132c
4 changed files with 39 additions and 4 deletions
|
@ -684,7 +684,7 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", true).makeProfile().cache();
|
public final OsmandPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", true).makeProfile().cache();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> SPEAK_TRAFFIC_WARNINGS = new BooleanPreference("speak_traffic_warnings", true).makeProfile().cache();
|
public final OsmandPreference<Boolean> SPEAK_TRAFFIC_WARNINGS = new BooleanPreference("speak_traffic_warnings", true).makeProfile().cache();
|
||||||
public final OsmandPreference<Boolean> SPEAK_SPEAD_CAMERAS = new BooleanPreference("speak_cameras", true).makeProfile().cache();
|
public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference("speak_cameras", true).makeProfile().cache();
|
||||||
public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", true).makeProfile().cache();
|
public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", true).makeProfile().cache();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeProfile().cache();
|
public final OsmandPreference<Boolean> AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeProfile().cache();
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
} else if (preference == speakAlarms) {
|
} else if (preference == speakAlarms) {
|
||||||
showBooleanSettings(new String[] { getString(R.string.speak_traffic_warnings), getString(R.string.speak_cameras),
|
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,
|
getString(R.string.speak_speed_limit) }, new OsmandPreference[] { settings.SPEAK_TRAFFIC_WARNINGS,
|
||||||
settings.SPEAK_SPEAD_CAMERAS , settings.SPEAK_SPEED_LIMIT});
|
settings.SPEAK_SPEED_CAMERA , settings.SPEAK_SPEED_LIMIT});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -509,6 +509,10 @@ public class RoutingHelper {
|
||||||
return route.getLeftTime(lastFixedLocation);
|
return route.getLeftTime(lastFixedLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OsmandSettings getSettings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
public String getGeneralRouteInformation(){
|
public String getGeneralRouteInformation(){
|
||||||
int dist = getLeftDistance();
|
int dist = getLeftDistance();
|
||||||
int hours = getLeftTime() / (60 * 60);
|
int hours = getLeftTime() / (60 * 60);
|
||||||
|
|
|
@ -27,6 +27,9 @@ public class VoiceRouter {
|
||||||
|
|
||||||
private int currentStatus = STATUS_UNKNOWN;
|
private int currentStatus = STATUS_UNKNOWN;
|
||||||
private float playGoAheadDist = 0;
|
private float playGoAheadDist = 0;
|
||||||
|
private long lastAnnouncedSpeedLimit = 0;
|
||||||
|
private long lastAnnouncedSpeedCamera = 0;
|
||||||
|
private long lastAnnouncedWarning = 0;
|
||||||
|
|
||||||
// private long lastTimeRouteRecalcAnnounced = 0;
|
// private long lastTimeRouteRecalcAnnounced = 0;
|
||||||
|
|
||||||
|
@ -180,8 +183,36 @@ public class VoiceRouter {
|
||||||
|
|
||||||
|
|
||||||
public void announceAlarm(AlarmInfo alarm) {
|
public void announceAlarm(AlarmInfo alarm) {
|
||||||
// TODO Auto-generated method stub
|
if(alarm == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long ms = System.currentTimeMillis();
|
||||||
|
if (alarm.getTime() == AlarmInfo.SPEED_LIMIT) {
|
||||||
|
if (router.getSettings().SPEAK_SPEED_LIMIT.get() && ms - lastAnnouncedSpeedLimit > 120 * 60 * 1000) {
|
||||||
|
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||||
|
if (p != null) {
|
||||||
|
lastAnnouncedSpeedLimit = ms;
|
||||||
|
p.speedAlarm().play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (alarm.getTime() == AlarmInfo.SPEED_CAMERA) {
|
||||||
|
if (router.getSettings().SPEAK_SPEED_CAMERA.get() && ms - lastAnnouncedSpeedCamera > 120 * 60 * 1000) {
|
||||||
|
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||||
|
if (p != null) {
|
||||||
|
lastAnnouncedSpeedCamera = ms;
|
||||||
|
p.speedAlarm().play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (router.getSettings().SPEAK_TRAFFIC_WARNINGS.get() && ms - lastAnnouncedWarning > 120 * 60 * 1000) {
|
||||||
|
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||||
|
if (p != null) {
|
||||||
|
lastAnnouncedWarning = ms;
|
||||||
|
p.speedAlarm().play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue