Merge pull request #2454 from poretsky/review_160413_a11y_proposal

[Review] Request from 'poretsky' @ 'poretsky/Osmand/review_160413_a11y_proposal'
This commit is contained in:
vshcherb 2016-04-13 23:55:58 +02:00
commit 9db2211875
6 changed files with 64 additions and 5 deletions

View file

@ -2000,4 +2000,12 @@
<string name="access_hint_enter_description">Введите описание</string>
<string name="access_category_choice">Выберите категорию</string>
<string name="access_default_color">Цвет по умолчанию</string>
<string name="access_smart_autoannounce">Интеллектуальное автооповещение</string>
<string name="access_smart_autoannounce_descr">Говорить только при изменении направления на целевую точку</string>
<string name="access_autoannounce_period">Период автооповещений</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>

View file

@ -10,6 +10,14 @@
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_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_descr">Minimal time interval between announces</string>
<string name="access_default_color">Default color</string>
<string name="access_category_choice">Choose category</string>
<string name="access_hint_enter_name">Enter name</string>

View file

@ -20,7 +20,6 @@ import java.util.List;
public class NavigationInfo {
private static final long MIN_NOTIFICATION_PERIOD = 10000;
private static final float FULL_CIRCLE = 360.0f;
private class RelativeDirection {
@ -227,11 +226,11 @@ public class NavigationInfo {
if (point != null) {
if ((currentLocation != null) && currentLocation.hasBearing()) {
final long now = SystemClock.uptimeMillis();
if ((now - lastNotificationTime) >= MIN_NOTIFICATION_PERIOD) {
if ((now - lastNotificationTime) >= settings.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.get()) {
Location destination = new Location("map"); //$NON-NLS-1$
destination.setLatitude(point.getLatitude());
destination.setLongitude(point.getLongitude());
if (lastDirection.update(destination)) {
if (lastDirection.update(destination) || !settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.get()) {
final String notification = distanceString(destination) + " " + lastDirection.getString(); //$NON-NLS-1$
lastNotificationTime = now;
app.runInUIThread(new Runnable() {

View file

@ -19,6 +19,7 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
private ListPreference accessibilityModePreference;
private ListPreference directionStylePreference;
private ListPreference autoannouncePeriodPreference;
@Override
@ -71,6 +72,30 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
});
cat.addPreference(directionStylePreference);
cat.addPreference(createCheckBoxPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE, R.string.access_smart_autoannounce,
R.string.access_smart_autoannounce_descr));
final int[] seconds = new int[] {5, 10, 15, 20, 30, 45, 60, 90};
final int[] minutes = new int[] {2, 3, 5};
autoannouncePeriodPreference = createTimeListPreference(settings.ACCESSIBILITY_AUTOANNOUNCE_PERIOD, seconds, minutes, 1000,
R.string.access_autoannounce_period, R.string.access_autoannounce_period_descr);
autoannouncePeriodPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
private final OnPreferenceChangeListener committer = autoannouncePeriodPreference.getOnPreferenceChangeListener();
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (committer != null)
committer.onPreferenceChange(preference, newValue);
updateAllSettings();
return true;
}
});
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,
R.string.zoom_by_trackball_descr));
}
@ -98,6 +123,9 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
if(directionStylePreference != null) {
directionStylePreference.setSummary(getString(R.string.settings_direction_style_descr) + " [" + settings.DIRECTION_STYLE.get().toHumanString(getMyApplication()) + "]");
}
if(autoannouncePeriodPreference != null) {
autoannouncePeriodPreference.setSummary(getString(R.string.access_autoannounce_period_descr) + " [" + autoannouncePeriodPreference.getEntry() + "]");
}
}
}

View file

@ -779,6 +779,22 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
new BooleanPreference("use_trackball_for_movements", true).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> ACCESSIBILITY_SMART_AUTOANNOUNCE =
new BooleanAccessibilityPreference("accessibility_smart_autoannounce", true).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
// 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();
// 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
public final OsmandPreference<Boolean> ZOOM_BY_TRACKBALL =
new BooleanAccessibilityPreference("zoom_by_trackball", false).makeGlobal();

View file

@ -315,7 +315,7 @@ public class RoutingHelper {
// >100m off current route (sideways)
if (currentRoute > 0) {
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$
calculateRoute = true;
}
@ -329,7 +329,7 @@ public class RoutingHelper {
// 3. Identify wrong movement direction
Location next = route.getNextRouteLocation();
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$
calculateRoute = true;
}