keep informing at regular intervals
This commit is contained in:
parent
696685d0db
commit
a07e3f1223
6 changed files with 68 additions and 22 deletions
|
@ -1090,6 +1090,9 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="choose_auto_follow_route">Auto-center map view</string>
|
||||
<string name="choose_auto_follow_route_descr">Time until map view synchronizes with current position</string>
|
||||
<string name="auto_follow_route_never">Never</string>
|
||||
<string name="keep_informing_never">Never</string>
|
||||
<string name="keep_informing_descr">Announce navigation instructions at regular intervals</string>
|
||||
<string name="keep_informing">Repeat navigation instructions</string>
|
||||
<string name="auto_follow_route_navigation">Auto-center nav only</string>
|
||||
<string name="auto_follow_route_navigation_descr">Auto-center map view only while navigating.</string>
|
||||
<string name="auto_follow_location_enabled">Auto-center map view in use.</string>
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference android:title="@string/router_service" android:key="router_service" android:summary="@string/router_service_descr"></ListPreference>
|
||||
<ListPreference android:title="@string/router_service" android:key="router_service" android:summary="@string/router_service_descr" />
|
||||
<PreferenceCategory android:key="routing_preferences" android:title="@string/routing_preferences_descr">
|
||||
<CheckBoxPreference android:summary="@string/fast_route_mode_descr" android:title="@string/fast_route_mode"
|
||||
android:key="fast_route_mode"></CheckBoxPreference>
|
||||
android:key="fast_route_mode" />
|
||||
<Preference android:title="@string/avoid_in_routing_title" android:summary="@string/avoid_in_routing_descr" android:key="avoid_in_routing"/>
|
||||
<Preference android:title="@string/prefer_in_routing_title" android:summary="@string/prefer_in_routing_descr" android:key="prefer_in_routing"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr">
|
||||
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route"
|
||||
android:summary="@string/choose_auto_follow_route_descr"></ListPreference>
|
||||
android:summary="@string/choose_auto_follow_route_descr" />
|
||||
<ListPreference android:key="auto_zoom_map_new" android:title="@string/auto_zoom_map"
|
||||
android:summary="@string/auto_zoom_map_descr"></ListPreference>
|
||||
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road"></CheckBoxPreference>
|
||||
android:summary="@string/auto_zoom_map_descr" />
|
||||
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road" />
|
||||
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/>
|
||||
<Preference android:title="@string/speak_title" android:summary="@string/speak_descr" android:key="speak_routing_alarms"/>
|
||||
</PreferenceCategory>
|
||||
<ListPreference
|
||||
android:key="keep_informing"
|
||||
android:title="@string/keep_informing"
|
||||
android:summary="@string/keep_informing_descr" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -848,6 +848,16 @@ public class OsmandSettings {
|
|||
AUTO_FOLLOW_ROUTE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
|
||||
}
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
// seconds to auto_follow
|
||||
public final CommonPreference<Integer> KEEP_INFORMING = new IntPreference("keep_informing", 0).makeProfile();
|
||||
{
|
||||
// 0 means never
|
||||
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.CAR, 0);
|
||||
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.BICYCLE, 0);
|
||||
KEEP_INFORMING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
|
||||
}
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
// try without AUTO_FOLLOW_ROUTE_NAV (see forum discussion 'Simplify our navigation preference menu')
|
||||
//public final CommonPreference<Boolean> AUTO_FOLLOW_ROUTE_NAV = new BooleanPreference("auto_follow_route_navigation", true, false);
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
|
||||
|
||||
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
|
||||
|
||||
|
||||
Integer[] intValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
|
||||
entries = new String[intValues.length];
|
||||
entries[0] = getString(R.string.auto_follow_route_never);
|
||||
|
@ -72,15 +72,23 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
entries[i] = (int) intValues[i] + " " + getString(R.string.int_seconds);
|
||||
}
|
||||
registerListPreference(settings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
|
||||
|
||||
|
||||
|
||||
|
||||
entries = new String[AutoZoomMap.values().length];
|
||||
for(int i=0; i<entries.length; i++){
|
||||
entries[i] = getString(AutoZoomMap.values()[i].name);
|
||||
}
|
||||
registerListPreference(settings.AUTO_ZOOM_MAP, screen, entries, AutoZoomMap.values());
|
||||
|
||||
//keep informing option:
|
||||
Integer[] keepInformingValues = new Integer[]{0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30};
|
||||
String[] keepInformingNames = new String[keepInformingValues.length];
|
||||
keepInformingNames[0] = getString(R.string.keep_informing_never);
|
||||
for (int i = 1; i < keepInformingValues.length; i++)
|
||||
{
|
||||
keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
|
||||
}
|
||||
registerListPreference(settings.KEEP_INFORMING, screen, keepInformingNames, keepInformingValues);
|
||||
|
||||
autoZoomMapPreference = (ListPreference) screen.findPreference(settings.AUTO_ZOOM_MAP.getId());
|
||||
autoZoomMapPreference.setOnPreferenceChangeListener(this);
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class RoutingHelper {
|
|||
public RoutingHelper(OsmandApplication context, CommandPlayer player){
|
||||
this.app = context;
|
||||
settings = context.getSettings();
|
||||
voiceRouter = new VoiceRouter(this, player);
|
||||
voiceRouter = new VoiceRouter(this, settings, player);
|
||||
}
|
||||
|
||||
public boolean isFollowingMode() {
|
||||
|
|
|
@ -4,6 +4,7 @@ package net.osmand.plus.routing;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
|
||||
|
@ -29,7 +30,7 @@ public class VoiceRouter {
|
|||
private final RoutingHelper router;
|
||||
private boolean mute = false;
|
||||
private CommandPlayer player;
|
||||
|
||||
private final OsmandSettings settings;
|
||||
|
||||
private int currentStatus = STATUS_UNKNOWN;
|
||||
private boolean playedAndArriveAtTarget = false;
|
||||
|
@ -60,10 +61,15 @@ public class VoiceRouter {
|
|||
private RouteDirectionInfo nextRouteDirection;
|
||||
private Term empty;
|
||||
|
||||
//remember when last announcement was made
|
||||
private long lastAnnouncement = 0;
|
||||
|
||||
public VoiceRouter(RoutingHelper router, CommandPlayer player) {
|
||||
|
||||
public VoiceRouter(RoutingHelper router, final OsmandSettings settings, CommandPlayer player) {
|
||||
this.router = router;
|
||||
this.player = player;
|
||||
this.settings = settings;
|
||||
|
||||
empty = new Struct("");
|
||||
}
|
||||
|
||||
|
@ -95,6 +101,7 @@ public class VoiceRouter {
|
|||
if(player == null || mute){
|
||||
return null;
|
||||
}
|
||||
lastAnnouncement = System.currentTimeMillis();
|
||||
return player.newCommandBuilder();
|
||||
}
|
||||
|
||||
|
@ -279,10 +286,17 @@ public class VoiceRouter {
|
|||
|| info.directionInfo.distance == 0;
|
||||
return in || target;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
private boolean needsInforming() {
|
||||
final Integer repeat = settings.KEEP_INFORMING.get();
|
||||
if (repeat == null || repeat == 0) return false;
|
||||
|
||||
final long notBefore = lastAnnouncement + repeat * 60 * 1000L;
|
||||
|
||||
return System.currentTimeMillis() > notBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates status of voice guidance
|
||||
* @param currentLocation
|
||||
*/
|
||||
|
@ -297,7 +311,6 @@ public class VoiceRouter {
|
|||
speed = Math.max(currentLocation.getSpeed(), speed);
|
||||
}
|
||||
|
||||
|
||||
NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
|
||||
RouteSegmentResult currentSegment = router.getCurrentSegmentResult();
|
||||
if (nextInfo.directionInfo == null) {
|
||||
|
@ -314,11 +327,19 @@ public class VoiceRouter {
|
|||
playGoAheadDist = 0;
|
||||
}
|
||||
|
||||
if (!repeat && (dist == 0 || currentStatus == STATUS_TOLD)) {
|
||||
// nothing said possibly that's wrong case we should say before that
|
||||
// however it should be checked manually ?
|
||||
return;
|
||||
if (!repeat) {
|
||||
if (dist == 0) {
|
||||
return;
|
||||
} else if (needsInforming()) {
|
||||
playGoAhead(dist, getSpeakableStreetName(currentSegment, next));
|
||||
return;
|
||||
} else if (currentStatus == STATUS_TOLD) {
|
||||
// nothing said possibly that's wrong case we should say before that
|
||||
// however it should be checked manually ?
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// say how much to go if there is next turn is a bit far
|
||||
if (currentStatus == STATUS_UNKNOWN) {
|
||||
if (!isDistanceLess(speed, dist, TURN_IN_DISTANCE * 1.3)) {
|
||||
|
|
Loading…
Reference in a new issue