diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 99345d6f45..9322d0ded4 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -2000,4 +2000,8 @@ Введите описание Выберите категорию Цвет по умолчанию + Интеллектуальное автооповещение + Говорить только при изменении направления на целевую точку + Период автооповещений + Минимальное время между оповещениями diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index e4bbd9d300..ac735882d1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -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 --> + Smart autoannounce + Notify only when direction to the target point is changed + Autoannounce period + Minimal time interval between announces Default color Choose category Enter name diff --git a/OsmAnd/src/net/osmand/access/NavigationInfo.java b/OsmAnd/src/net/osmand/access/NavigationInfo.java index a403da14b0..da42bf5f0f 100644 --- a/OsmAnd/src/net/osmand/access/NavigationInfo.java +++ b/OsmAnd/src/net/osmand/access/NavigationInfo.java @@ -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() { diff --git a/OsmAnd/src/net/osmand/access/SettingsAccessibilityActivity.java b/OsmAnd/src/net/osmand/access/SettingsAccessibilityActivity.java index 7532de51c0..b4f6f35754 100644 --- a/OsmAnd/src/net/osmand/access/SettingsAccessibilityActivity.java +++ b/OsmAnd/src/net/osmand/access/SettingsAccessibilityActivity.java @@ -19,6 +19,7 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity { private ListPreference accessibilityModePreference; private ListPreference directionStylePreference; + private ListPreference autoannouncePeriodPreference; @Override @@ -71,6 +72,25 @@ 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.ZOOM_BY_TRACKBALL, R.string.zoom_by_trackball, R.string.zoom_by_trackball_descr)); } @@ -98,6 +118,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() + "]"); + } } } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 5a22ec4e12..ab2eef3901 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -779,6 +779,14 @@ public class OsmandSettings { public final OsmandPreference 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 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 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 ZOOM_BY_TRACKBALL = new BooleanAccessibilityPreference("zoom_by_trackball", false).makeGlobal();