Move accessibility prefs to plugin
This commit is contained in:
parent
c52c9d2515
commit
fc2ef118f5
9 changed files with 97 additions and 94 deletions
|
@ -11,6 +11,7 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="osm_authorization_success">Authorization is successful</string>
|
||||
<string name="file_does_not_contain_routing_rules">\'%1$s\' file doesn\'t contain routing rules, please choose another file.</string>
|
||||
<string name="not_support_file_type_with_ext">Not supported file type. You need to select a file with %1$s extension.</string>
|
||||
<string name="import_from_file">Import from file</string>
|
||||
|
|
|
@ -7,7 +7,10 @@ import android.support.annotation.NonNull;
|
|||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.access.RelativeDirectionStyle;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -25,8 +28,27 @@ public class AccessibilityPlugin extends OsmandPlugin {
|
|||
private SoundPool sounds;
|
||||
private Map<Integer, Integer> soundIcons = new HashMap<Integer, Integer>();
|
||||
|
||||
public final OsmandSettings.OsmandPreference<AccessibilityMode> ACCESSIBILITY_MODE;
|
||||
public final OsmandSettings.OsmandPreference<Float> SPEECH_RATE;
|
||||
public final OsmandSettings.OsmandPreference<Boolean> ACCESSIBILITY_SMART_AUTOANNOUNCE;
|
||||
public final OsmandSettings.OsmandPreference<Integer> ACCESSIBILITY_AUTOANNOUNCE_PERIOD;
|
||||
public final OsmandSettings.OsmandPreference<Boolean> DISABLE_OFFROUTE_RECALC;
|
||||
public final OsmandSettings.OsmandPreference<Boolean> DISABLE_WRONG_DIRECTION_RECALC;
|
||||
public final OsmandSettings.OsmandPreference<RelativeDirectionStyle> DIRECTION_STYLE;
|
||||
public final OsmandSettings.OsmandPreference<Boolean> DIRECTION_AUDIO_FEEDBACK;
|
||||
public final OsmandSettings.OsmandPreference<Boolean> DIRECTION_HAPTIC_FEEDBACK;
|
||||
|
||||
public AccessibilityPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
ACCESSIBILITY_MODE = registerEnumIntPreference(app, "accessibility_mode", AccessibilityMode.DEFAULT, AccessibilityMode.values(), AccessibilityMode.class).makeProfile().cache();
|
||||
SPEECH_RATE = registerFloatPreference(app, "speech_rate", 1f).makeProfile();
|
||||
ACCESSIBILITY_SMART_AUTOANNOUNCE = registerBooleanAccessibilityPreference(app, "accessibility_smart_autoannounce", true).makeProfile();
|
||||
ACCESSIBILITY_AUTOANNOUNCE_PERIOD = registerIntPreference(app, "accessibility_autoannounce_period", 10000).makeProfile().cache();
|
||||
DISABLE_OFFROUTE_RECALC = registerBooleanAccessibilityPreference(app, "disable_offroute_recalc", false).makeProfile();
|
||||
DISABLE_WRONG_DIRECTION_RECALC = registerBooleanAccessibilityPreference(app, "disable_wrong_direction_recalc", false).makeProfile();
|
||||
DIRECTION_STYLE = registerEnumIntPreference(app, "direction_style", RelativeDirectionStyle.SIDEWISE, RelativeDirectionStyle.values(), RelativeDirectionStyle.class).makeProfile().cache();
|
||||
DIRECTION_AUDIO_FEEDBACK = registerBooleanAccessibilityPreference(app, "direction_audio_feedback", false).makeProfile();
|
||||
DIRECTION_HAPTIC_FEEDBACK = registerBooleanAccessibilityPreference(app, "direction_haptic_feedback", false).makeProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,6 +110,12 @@ public class AccessibilityPlugin extends OsmandPlugin {
|
|||
return R.drawable.ic_plugin_accessibility;
|
||||
}
|
||||
|
||||
private OsmandSettings.CommonPreference<Boolean> registerBooleanAccessibilityPreference(OsmandApplication app, String prefId, boolean defValue) {
|
||||
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().registerBooleanAccessibilityPreference(prefId, defValue);
|
||||
pluginPreferences.add(preference);
|
||||
return preference;
|
||||
}
|
||||
|
||||
public void playSoundIcon(int iconId) {
|
||||
if ((sounds != null) && soundIcons.containsKey(iconId)) {
|
||||
int sound = soundIcons.get(iconId);
|
||||
|
|
|
@ -24,8 +24,11 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
|
||||
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
||||
|
||||
private AccessibilityPlugin plugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
if (plugin != null) {
|
||||
setupAccessibilityModePref();
|
||||
setupSpeechRatePref();
|
||||
|
||||
|
@ -44,6 +47,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
|
||||
updateAccessibilityOptions();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupAccessibilityModePref() {
|
||||
AccessibilityMode[] accessibilityModes = AccessibilityMode.values();
|
||||
|
@ -55,7 +59,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
entryValues[i] = accessibilityModes[i].ordinal();
|
||||
}
|
||||
|
||||
ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_MODE.getId());
|
||||
ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(plugin.ACCESSIBILITY_MODE.getId());
|
||||
accessibilityMode.setEntries(entries);
|
||||
accessibilityMode.setEntryValues(entryValues);
|
||||
accessibilityMode.setDescription(R.string.accessibility_mode_descr);
|
||||
|
@ -69,7 +73,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
entries[i] = (int) (entryValues[i] * 100) + " %";
|
||||
}
|
||||
|
||||
ListPreferenceEx speechRate = (ListPreferenceEx) findPreference(settings.SPEECH_RATE.getId());
|
||||
ListPreferenceEx speechRate = (ListPreferenceEx) findPreference(plugin.SPEECH_RATE.getId());
|
||||
speechRate.setEntries(entries);
|
||||
speechRate.setEntryValues(entryValues);
|
||||
speechRate.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
|
||||
|
@ -77,7 +81,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
}
|
||||
|
||||
private void setupSmartAutoAnnouncePref() {
|
||||
SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
|
||||
SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(plugin.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
|
||||
smartAutoAnnounce.setDescription(getString(R.string.access_smart_autoannounce_descr));
|
||||
}
|
||||
|
||||
|
@ -99,19 +103,19 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
k++;
|
||||
}
|
||||
|
||||
ListPreferenceEx autoAnnouncePeriod = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.getId());
|
||||
ListPreferenceEx autoAnnouncePeriod = (ListPreferenceEx) findPreference(plugin.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.getId());
|
||||
autoAnnouncePeriod.setEntries(entries);
|
||||
autoAnnouncePeriod.setEntryValues(entryValues);
|
||||
autoAnnouncePeriod.setDescription(R.string.access_autoannounce_period_descr);
|
||||
}
|
||||
|
||||
private void setupDisableOffRouteRecalculationPref() {
|
||||
SwitchPreferenceEx disableOffRouteRecalculation = (SwitchPreferenceEx) findPreference(settings.DISABLE_OFFROUTE_RECALC.getId());
|
||||
SwitchPreferenceEx disableOffRouteRecalculation = (SwitchPreferenceEx) findPreference(plugin.DISABLE_OFFROUTE_RECALC.getId());
|
||||
disableOffRouteRecalculation.setDescription(getString(R.string.access_disable_offroute_recalc_descr));
|
||||
}
|
||||
|
||||
private void setupDisableWrongDirectionRecalculationPref() {
|
||||
SwitchPreferenceEx disableWrongDirectionRecalculation = (SwitchPreferenceEx) findPreference(settings.DISABLE_WRONG_DIRECTION_RECALC.getId());
|
||||
SwitchPreferenceEx disableWrongDirectionRecalculation = (SwitchPreferenceEx) findPreference(plugin.DISABLE_WRONG_DIRECTION_RECALC.getId());
|
||||
disableWrongDirectionRecalculation.setDescription(getString(R.string.access_disable_wrong_direction_recalc_descr));
|
||||
}
|
||||
|
||||
|
@ -125,19 +129,19 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
entryValues[i] = relativeDirectionStyles[i].ordinal();
|
||||
}
|
||||
|
||||
ListPreferenceEx directionStyle = (ListPreferenceEx) findPreference(settings.DIRECTION_STYLE.getId());
|
||||
ListPreferenceEx directionStyle = (ListPreferenceEx) findPreference(plugin.DIRECTION_STYLE.getId());
|
||||
directionStyle.setEntries(entries);
|
||||
directionStyle.setEntryValues(entryValues);
|
||||
directionStyle.setDescription(R.string.settings_direction_style_descr);
|
||||
}
|
||||
|
||||
private void setupDirectionAudioFeedbackPref() {
|
||||
SwitchPreferenceEx directionAudioFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_AUDIO_FEEDBACK.getId());
|
||||
SwitchPreferenceEx directionAudioFeedback = (SwitchPreferenceEx) findPreference(plugin.DIRECTION_AUDIO_FEEDBACK.getId());
|
||||
directionAudioFeedback.setDescription(getString(R.string.access_direction_audio_feedback_descr));
|
||||
}
|
||||
|
||||
private void setupDirectionHapticFeedbackPref() {
|
||||
SwitchPreferenceEx directionHapticFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_HAPTIC_FEEDBACK.getId());
|
||||
SwitchPreferenceEx directionHapticFeedback = (SwitchPreferenceEx) findPreference(plugin.DIRECTION_HAPTIC_FEEDBACK.getId());
|
||||
directionHapticFeedback.setDescription(getString(R.string.access_direction_haptic_feedback_descr));
|
||||
}
|
||||
|
||||
|
@ -153,7 +157,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
|
||||
@Override
|
||||
public void onPreferenceChanged(String prefId) {
|
||||
if (settings.ACCESSIBILITY_MODE.getId().equals(prefId)) {
|
||||
if (plugin.ACCESSIBILITY_MODE.getId().equals(prefId)) {
|
||||
updateAccessibilityOptions();
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +202,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
for (int i = 0; i < screen.getPreferenceCount(); i++) {
|
||||
Preference preference = screen.getPreference(i);
|
||||
String prefId = preference.getKey();
|
||||
if (!settings.ACCESSIBILITY_MODE.getId().equals(prefId) && !settings.SPEECH_RATE.getId().equals(prefId))
|
||||
if (!plugin.ACCESSIBILITY_MODE.getId().equals(prefId) && !plugin.SPEECH_RATE.getId().equals(prefId))
|
||||
preference.setEnabled(accessibilityEnabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,20 +46,20 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
private int value;
|
||||
|
||||
public RelativeDirection() {
|
||||
style = settings.DIRECTION_STYLE.get();
|
||||
style = plugin.DIRECTION_STYLE.get();
|
||||
clear();
|
||||
}
|
||||
|
||||
// The argument must be not null as well as the currentLocation
|
||||
// and currentLocation must have bearing.
|
||||
public RelativeDirection(final Location point) {
|
||||
style = settings.DIRECTION_STYLE.get();
|
||||
style = plugin.DIRECTION_STYLE.get();
|
||||
value = directionTo(point, currentLocation.getBearing());
|
||||
}
|
||||
|
||||
// The first argument must be not null as well as the currentLocation.
|
||||
public RelativeDirection(final Location point, float heading) {
|
||||
style = settings.DIRECTION_STYLE.get();
|
||||
style = plugin.DIRECTION_STYLE.get();
|
||||
value = directionTo(point, heading);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
// The first argument must be not null as well as the currentLocation.
|
||||
public boolean update(final Location point, float heading) {
|
||||
boolean result = false;
|
||||
final RelativeDirectionStyle newStyle = settings.DIRECTION_STYLE.get();
|
||||
final RelativeDirectionStyle newStyle = plugin.DIRECTION_STYLE.get();
|
||||
if (style != newStyle) {
|
||||
style = newStyle;
|
||||
result = true;
|
||||
|
@ -151,7 +151,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
private final long HAPTIC_INCLINATION_RIGHT[] = { 0, 20, 80, 20 };
|
||||
|
||||
private final OsmandApplication app;
|
||||
private final OsmandSettings settings;
|
||||
private final AccessibilityPlugin plugin;
|
||||
private Location currentLocation;
|
||||
private RelativeDirection lastDirection;
|
||||
private long lastNotificationTime;
|
||||
|
@ -160,7 +160,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
|
||||
public NavigationInfo(OsmandApplication app) {
|
||||
this.app = app;
|
||||
settings = app.getSettings();
|
||||
plugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
currentLocation = null;
|
||||
lastDirection = new RelativeDirection();
|
||||
lastNotificationTime = SystemClock.uptimeMillis();
|
||||
|
@ -253,11 +253,11 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
if (point != null) {
|
||||
if ((currentLocation != null) && currentLocation.hasBearing() && !MapViewTrackingUtilities.isSmallSpeedForCompass(currentLocation)) {
|
||||
final long now = SystemClock.uptimeMillis();
|
||||
if ((now - lastNotificationTime) >= settings.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.get()) {
|
||||
if ((now - lastNotificationTime) >= plugin.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.get()) {
|
||||
Location destination = new Location("map"); //$NON-NLS-1$
|
||||
destination.setLatitude(point.getLatitude());
|
||||
destination.setLongitude(point.getLongitude());
|
||||
if (lastDirection.update(destination) || !settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.get()) {
|
||||
if (lastDirection.update(destination) || !plugin.ACCESSIBILITY_SMART_AUTOANNOUNCE.get()) {
|
||||
final String notification = distanceString(destination) + " " + lastDirection.getString(); //$NON-NLS-1$
|
||||
lastNotificationTime = now;
|
||||
app.runInUIThread(new Runnable() {
|
||||
|
@ -281,7 +281,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
Integer inclination = direction.getInclination();
|
||||
if (targetDirectionFlag && ((inclination == null) || (inclination != 0))) {
|
||||
targetDirectionFlag = false;
|
||||
if (settings.DIRECTION_AUDIO_FEEDBACK.get()) {
|
||||
if (plugin.DIRECTION_AUDIO_FEEDBACK.get()) {
|
||||
AccessibilityPlugin accessibilityPlugin = OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class);
|
||||
if (accessibilityPlugin != null) {
|
||||
if (inclination == null) {
|
||||
|
@ -293,7 +293,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
}
|
||||
}
|
||||
}
|
||||
if (settings.DIRECTION_HAPTIC_FEEDBACK.get()) {
|
||||
if (plugin.DIRECTION_HAPTIC_FEEDBACK.get()) {
|
||||
Vibrator haptic = (Vibrator)app.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if ((haptic != null) && haptic.hasVibrator()) {
|
||||
if (inclination == null) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.preference.PreferenceGroup;
|
|||
import android.preference.PreferenceScreen;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.access.RelativeDirectionStyle;
|
||||
|
@ -17,6 +18,8 @@ import net.osmand.plus.activities.SettingsBaseActivity;
|
|||
|
||||
public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
||||
|
||||
private AccessibilityPlugin plugin;
|
||||
|
||||
private ListPreference accessibilityModePreference;
|
||||
private ListPreference directionStylePreference;
|
||||
private ListPreference autoannouncePeriodPreference;
|
||||
|
@ -29,11 +32,13 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
getToolbar().setTitle(R.string.shared_string_accessibility);
|
||||
PreferenceScreen grp = getPreferenceScreen();
|
||||
|
||||
plugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
|
||||
String[] entries = new String[AccessibilityMode.values().length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = AccessibilityMode.values()[i].toHumanString(getMyApplication());
|
||||
}
|
||||
accessibilityModePreference = createListPreference(settings.ACCESSIBILITY_MODE, entries, AccessibilityMode.values(),
|
||||
accessibilityModePreference = createListPreference(plugin.ACCESSIBILITY_MODE, entries, AccessibilityMode.values(),
|
||||
R.string.accessibility_mode, R.string.accessibility_mode_descr);
|
||||
accessibilityModePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
private final OnPreferenceChangeListener committer = accessibilityModePreference.getOnPreferenceChangeListener();
|
||||
|
@ -58,7 +63,7 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = RelativeDirectionStyle.values()[i].toHumanString(getMyApplication());
|
||||
}
|
||||
directionStylePreference = createListPreference(settings.DIRECTION_STYLE, entries, RelativeDirectionStyle.values(),
|
||||
directionStylePreference = createListPreference(plugin.DIRECTION_STYLE, entries, RelativeDirectionStyle.values(),
|
||||
R.string.settings_direction_style, R.string.settings_direction_style_descr);
|
||||
directionStylePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
private final OnPreferenceChangeListener committer = directionStylePreference.getOnPreferenceChangeListener();
|
||||
|
@ -72,12 +77,12 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
});
|
||||
cat.addPreference(directionStylePreference);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE, R.string.access_smart_autoannounce,
|
||||
cat.addPreference(createCheckBoxPreference(plugin.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,
|
||||
autoannouncePeriodPreference = createTimeListPreference(plugin.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();
|
||||
|
@ -91,14 +96,14 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
});
|
||||
cat.addPreference(autoannouncePeriodPreference);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.DISABLE_OFFROUTE_RECALC, R.string.access_disable_offroute_recalc,
|
||||
cat.addPreference(createCheckBoxPreference(plugin.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,
|
||||
cat.addPreference(createCheckBoxPreference(plugin.DISABLE_WRONG_DIRECTION_RECALC, R.string.access_disable_wrong_direction_recalc,
|
||||
R.string.access_disable_wrong_direction_recalc_descr));
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.DIRECTION_AUDIO_FEEDBACK, R.string.access_direction_audio_feedback,
|
||||
cat.addPreference(createCheckBoxPreference(plugin.DIRECTION_AUDIO_FEEDBACK, R.string.access_direction_audio_feedback,
|
||||
R.string.access_direction_audio_feedback_descr));
|
||||
cat.addPreference(createCheckBoxPreference(settings.DIRECTION_HAPTIC_FEEDBACK, R.string.access_direction_haptic_feedback,
|
||||
cat.addPreference(createCheckBoxPreference(plugin.DIRECTION_HAPTIC_FEEDBACK, R.string.access_direction_haptic_feedback,
|
||||
R.string.access_direction_haptic_feedback_descr));
|
||||
|
||||
}
|
||||
|
@ -110,7 +115,7 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
for(int i = 0; i < sprNames.length; i++) {
|
||||
sprNames[i] = (int)(sprValues[i] * 100) + " %";
|
||||
}
|
||||
grp.addPreference(createListPreference(settings.SPEECH_RATE, sprNames, sprValues, R.string.speech_rate, R.string.speech_rate_descr));
|
||||
grp.addPreference(createListPreference(plugin.SPEECH_RATE, sprNames, sprValues, R.string.speech_rate, R.string.speech_rate_descr));
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,14 +126,13 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
if (accessibilityOptions != null)
|
||||
accessibilityOptions.setEnabled(getMyApplication().accessibilityEnabled());
|
||||
if(accessibilityModePreference != null) {
|
||||
accessibilityModePreference.setSummary(getString(R.string.accessibility_mode_descr) + " [" + settings.ACCESSIBILITY_MODE.get().toHumanString(getMyApplication()) + "]");
|
||||
accessibilityModePreference.setSummary(getString(R.string.accessibility_mode_descr) + " [" + plugin.ACCESSIBILITY_MODE.get().toHumanString(getMyApplication()) + "]");
|
||||
}
|
||||
if(directionStylePreference != null) {
|
||||
directionStylePreference.setSummary(getString(R.string.settings_direction_style_descr) + " [" + settings.DIRECTION_STYLE.get().toHumanString(getMyApplication()) + "]");
|
||||
directionStylePreference.setSummary(getString(R.string.settings_direction_style_descr) + " [" + plugin.DIRECTION_STYLE.get().toHumanString(getMyApplication()) + "]");
|
||||
}
|
||||
if(autoannouncePeriodPreference != null) {
|
||||
autoannouncePeriodPreference.setSummary(getString(R.string.access_autoannounce_period_descr) + " [" + autoannouncePeriodPreference.getEntry() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -877,10 +877,11 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
}
|
||||
|
||||
public boolean accessibilityEnabledForMode(ApplicationMode appMode) {
|
||||
final AccessibilityMode mode = getSettings().ACCESSIBILITY_MODE.getModeValue(appMode);
|
||||
if (OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) == null) {
|
||||
AccessibilityPlugin accessibilityPlugin = OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class);
|
||||
if (accessibilityPlugin == null) {
|
||||
return false;
|
||||
}
|
||||
AccessibilityMode mode = accessibilityPlugin.ACCESSIBILITY_MODE.getModeValue(appMode);
|
||||
if (mode == AccessibilityMode.ON) {
|
||||
return true;
|
||||
} else if (mode == AccessibilityMode.OFF) {
|
||||
|
|
|
@ -30,8 +30,6 @@ import net.osmand.map.ITileSource;
|
|||
import net.osmand.map.TileSourceManager;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.access.AccessibilityMode;
|
||||
import net.osmand.plus.access.RelativeDirectionStyle;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
import net.osmand.plus.api.SettingsAPI.SettingsEditor;
|
||||
import net.osmand.plus.api.SettingsAPIImpl;
|
||||
|
@ -1409,21 +1407,6 @@ public class OsmandSettings {
|
|||
|
||||
}.makeProfile();
|
||||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
// cache of metrics constants as they are used very often
|
||||
public final OsmandPreference<RelativeDirectionStyle> DIRECTION_STYLE = new EnumIntPreference<RelativeDirectionStyle>(
|
||||
"direction_style", RelativeDirectionStyle.SIDEWISE, RelativeDirectionStyle.values()).makeProfile().cache();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
// cache of metrics constants as they are used very often
|
||||
public final OsmandPreference<AccessibilityMode> ACCESSIBILITY_MODE = new EnumIntPreference<AccessibilityMode>(
|
||||
"accessibility_mode", AccessibilityMode.DEFAULT, AccessibilityMode.values()).makeProfile().cache();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Float> SPEECH_RATE =
|
||||
new FloatPreference("speech_rate", 1f).makeProfile();
|
||||
|
||||
public final OsmandPreference<Float> ARRIVAL_DISTANCE_FACTOR =
|
||||
new FloatPreference("arrival_distance_factor", 1f).makeProfile();
|
||||
|
||||
|
@ -1446,30 +1429,6 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
|
||||
new BooleanPreference("use_trackball_for_movements", true).makeProfile();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> ACCESSIBILITY_SMART_AUTOANNOUNCE =
|
||||
new BooleanAccessibilityPreference("accessibility_smart_autoannounce", true).makeProfile();
|
||||
|
||||
// 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).makeProfile().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).makeProfile();
|
||||
|
||||
// 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).makeProfile();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> DIRECTION_AUDIO_FEEDBACK =
|
||||
new BooleanAccessibilityPreference("direction_audio_feedback", false).makeProfile();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> DIRECTION_HAPTIC_FEEDBACK =
|
||||
new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeProfile();
|
||||
|
||||
// magnetic field doesn'torkmost of the time on some phones
|
||||
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().cache();
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package net.osmand.plus.routing;
|
||||
|
||||
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndAppCustomization.OsmAndAppCustomizationListener;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -71,6 +72,7 @@ public class RoutingHelper {
|
|||
|
||||
private ApplicationMode mode;
|
||||
private OsmandSettings settings;
|
||||
private AccessibilityPlugin accessibilityPlugin;
|
||||
|
||||
private RouteProvider provider;
|
||||
private VoiceRouter voiceRouter;
|
||||
|
@ -101,6 +103,7 @@ public class RoutingHelper {
|
|||
transportRoutingHelper = context.getTransportRoutingHelper();
|
||||
transportRoutingHelper.setRoutingHelper(this);
|
||||
setAppMode(settings.APPLICATION_MODE.get());
|
||||
accessibilityPlugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
|
@ -395,7 +398,7 @@ public class RoutingHelper {
|
|||
// >100m off current route (sideways)
|
||||
if (currentRoute > 0) {
|
||||
distOrth = getOrthogonalDistance(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute));
|
||||
if ((!settings.DISABLE_OFFROUTE_RECALC.get()) && (distOrth > (1.7 * posTolerance))) {
|
||||
if ((!accessibilityPlugin.DISABLE_OFFROUTE_RECALC.get()) && (distOrth > (1.7 * posTolerance))) {
|
||||
log.info("Recalculate route, because correlation : " + distOrth); //$NON-NLS-1$
|
||||
isDeviatedFromRoute = true;
|
||||
calculateRoute = true;
|
||||
|
@ -404,7 +407,7 @@ public class RoutingHelper {
|
|||
// 3. Identify wrong movement direction
|
||||
Location next = route.getNextRouteLocation();
|
||||
boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next);
|
||||
if ((!settings.DISABLE_WRONG_DIRECTION_RECALC.get()) && wrongMovementDirection && (currentLocation.distanceTo(routeNodes.get(currentRoute)) > (2 * posTolerance))) {
|
||||
if ((!accessibilityPlugin.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$
|
||||
isDeviatedFromRoute = true;
|
||||
calculateRoute = true;
|
||||
|
|
|
@ -14,8 +14,10 @@ import android.support.v7.app.AlertDialog;
|
|||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.routing.VoiceRouter;
|
||||
|
@ -83,8 +85,9 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
|||
ctx.getString(R.string.voice_data_corrupted));
|
||||
}
|
||||
OsmandApplication app = (OsmandApplication) ctx.getApplicationContext();
|
||||
if(app.accessibilityEnabled()) {
|
||||
cSpeechRate = app.getSettings().SPEECH_RATE.get();
|
||||
AccessibilityPlugin accessibilityPlugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
if (app.accessibilityEnabled() && accessibilityPlugin != null) {
|
||||
cSpeechRate = accessibilityPlugin.SPEECH_RATE.get();
|
||||
}
|
||||
initializeEngine(app, ctx);
|
||||
params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, app.getSettings().AUDIO_STREAM_GUIDANCE
|
||||
|
|
Loading…
Reference in a new issue