Introduced accessibility mode options allowing to prevent automatic

route recalculation.
This commit is contained in:
Igor B. Poretsky 2013-10-27 03:26:02 +04:00
parent 1111ed1928
commit 3a02be2e5a
5 changed files with 23 additions and 2 deletions

View file

@ -2004,4 +2004,8 @@
<string name="access_smart_autoannounce_descr">Говорить только при изменении направления на целевую точку</string> <string name="access_smart_autoannounce_descr">Говорить только при изменении направления на целевую точку</string>
<string name="access_autoannounce_period">Период автооповещений</string> <string name="access_autoannounce_period">Период автооповещений</string>
<string name="access_autoannounce_period_descr">Минимальное время между оповещениями</string> <string name="access_autoannounce_period_descr">Минимальное время между оповещениями</string>
<string name="access_disable_offroute_recalc">Не менять маршрут при сходе с пути</string>
<string name="access_disable_offroute_recalc_descr">Предотвращает автоматический пересчет маршрута при значительном удалении от заданного пути</string>
<string name="access_disable_wrong_direction_recalc">Не менять маршрут при неверном направлении движения</string>
<string name="access_disable_wrong_direction_recalc_descr">Предотвращает автоматический пересчет маршрута при неверном направлении движения</string>
</resources> </resources>

View file

@ -10,6 +10,10 @@
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="access_disable_offroute_recalc">Don\'t change route when you are off the way</string>
<string name="access_disable_offroute_recalc_descr">Prevent automatic route recalculation when you are quite far from the right way</string>
<string name="access_disable_wrong_direction_recalc">Don\'t change route by wrong direction</string>
<string name="access_disable_wrong_direction_recalc_descr">Prevent automatic route recalculation when you are moving in wrong direction</string>
<string name="access_smart_autoannounce">Smart autoannounce</string> <string name="access_smart_autoannounce">Smart autoannounce</string>
<string name="access_smart_autoannounce_descr">Notify only when direction to the target point is changed</string> <string name="access_smart_autoannounce_descr">Notify only when direction to the target point is changed</string>
<string name="access_autoannounce_period">Autoannounce period</string> <string name="access_autoannounce_period">Autoannounce period</string>

View file

@ -91,6 +91,11 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
}); });
cat.addPreference(autoannouncePeriodPreference); cat.addPreference(autoannouncePeriodPreference);
cat.addPreference(createCheckBoxPreference(settings.DISABLE_OFFROUTE_RECALC, R.string.access_disable_offroute_recalc,
R.string.access_disable_offroute_recalc_descr));
cat.addPreference(createCheckBoxPreference(settings.DISABLE_WRONG_DIRECTION_RECALC, R.string.access_disable_wrong_direction_recalc,
R.string.access_disable_wrong_direction_recalc_descr));
cat.addPreference(createCheckBoxPreference(settings.ZOOM_BY_TRACKBALL, R.string.zoom_by_trackball, cat.addPreference(createCheckBoxPreference(settings.ZOOM_BY_TRACKBALL, R.string.zoom_by_trackball,
R.string.zoom_by_trackball_descr)); R.string.zoom_by_trackball_descr));
} }

View file

@ -787,6 +787,14 @@ public class OsmandSettings {
// cache of metrics constants as they are used very often // cache of metrics constants as they are used very often
public final OsmandPreference<Integer> ACCESSIBILITY_AUTOANNOUNCE_PERIOD = new IntPreference("accessibility_autoannounce_period", 10000).makeGlobal().cache(); public final OsmandPreference<Integer> ACCESSIBILITY_AUTOANNOUNCE_PERIOD = new IntPreference("accessibility_autoannounce_period", 10000).makeGlobal().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DISABLE_OFFROUTE_RECALC =
new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DISABLE_WRONG_DIRECTION_RECALC =
new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> ZOOM_BY_TRACKBALL = public final OsmandPreference<Boolean> ZOOM_BY_TRACKBALL =
new BooleanAccessibilityPreference("zoom_by_trackball", false).makeGlobal(); new BooleanAccessibilityPreference("zoom_by_trackball", false).makeGlobal();

View file

@ -315,7 +315,7 @@ public class RoutingHelper {
// >100m off current route (sideways) // >100m off current route (sideways)
if (currentRoute > 0) { if (currentRoute > 0) {
double dist = getOrthogonalDistance(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute)); double dist = getOrthogonalDistance(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute));
if (dist > 1.7 * posTolerance) { if ((!settings.DISABLE_OFFROUTE_RECALC.get()) && (dist > (1.7 * posTolerance))) {
log.info("Recalculate route, because correlation : " + dist); //$NON-NLS-1$ log.info("Recalculate route, because correlation : " + dist); //$NON-NLS-1$
calculateRoute = true; calculateRoute = true;
} }
@ -329,7 +329,7 @@ public class RoutingHelper {
// 3. Identify wrong movement direction // 3. Identify wrong movement direction
Location next = route.getNextRouteLocation(); Location next = route.getNextRouteLocation();
boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next); boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next);
if (wrongMovementDirection && currentLocation.distanceTo(routeNodes.get(currentRoute)) > 2 * posTolerance) { if ((!settings.DISABLE_WRONG_DIRECTION_RECALC.get()) && wrongMovementDirection && (currentLocation.distanceTo(routeNodes.get(currentRoute)) > (2 * posTolerance))) {
log.info("Recalculate route, because wrong movement direction: " + currentLocation.distanceTo(routeNodes.get(currentRoute))); //$NON-NLS-1$ log.info("Recalculate route, because wrong movement direction: " + currentLocation.distanceTo(routeNodes.get(currentRoute))); //$NON-NLS-1$
calculateRoute = true; calculateRoute = true;
} }