Remove unnecessary changes
This commit is contained in:
parent
cb426eae75
commit
1f9a94cea4
8 changed files with 114 additions and 89 deletions
|
@ -8,13 +8,14 @@ import android.support.annotation.NonNull;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AccessibilityPlugin extends OsmandPlugin {
|
||||
|
@ -28,27 +29,19 @@ 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;
|
||||
private List<OsmandPreference> pluginPreferences = new ArrayList<>();
|
||||
|
||||
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();
|
||||
pluginPreferences.add(app.getSettings().ACCESSIBILITY_MODE);
|
||||
pluginPreferences.add(app.getSettings().SPEECH_RATE);
|
||||
pluginPreferences.add(app.getSettings().ACCESSIBILITY_SMART_AUTOANNOUNCE);
|
||||
pluginPreferences.add(app.getSettings().ACCESSIBILITY_AUTOANNOUNCE_PERIOD);
|
||||
pluginPreferences.add(app.getSettings().DISABLE_OFFROUTE_RECALC);
|
||||
pluginPreferences.add(app.getSettings().DISABLE_WRONG_DIRECTION_RECALC);
|
||||
pluginPreferences.add(app.getSettings().DIRECTION_STYLE);
|
||||
pluginPreferences.add(app.getSettings().DIRECTION_AUDIO_FEEDBACK);
|
||||
pluginPreferences.add(app.getSettings().DIRECTION_HAPTIC_FEEDBACK);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,6 +80,11 @@ public class AccessibilityPlugin extends OsmandPlugin {
|
|||
return AccessibilitySettingsFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OsmandPreference> getPreferences() {
|
||||
return pluginPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefsDescription() {
|
||||
return app.getString(R.string.accessibility_prefs_descr);
|
||||
|
|
|
@ -24,29 +24,25 @@ 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();
|
||||
setupAccessibilityModePref();
|
||||
setupSpeechRatePref();
|
||||
|
||||
setupSmartAutoAnnouncePref();
|
||||
setupAutoAnnouncePeriodPref();
|
||||
setupSmartAutoAnnouncePref();
|
||||
setupAutoAnnouncePeriodPref();
|
||||
|
||||
setupDisableOffRouteRecalculationPref();
|
||||
setupDisableWrongDirectionRecalculationPref();
|
||||
setupDisableOffRouteRecalculationPref();
|
||||
setupDisableWrongDirectionRecalculationPref();
|
||||
|
||||
setupDirectionStylePref();
|
||||
setupDirectionAudioFeedbackPref();
|
||||
setupDirectionHapticFeedbackPref();
|
||||
setupDirectionStylePref();
|
||||
setupDirectionAudioFeedbackPref();
|
||||
setupDirectionHapticFeedbackPref();
|
||||
|
||||
setupCopyProfileSettingsPref();
|
||||
setupResetToDefaultPref();
|
||||
setupCopyProfileSettingsPref();
|
||||
setupResetToDefaultPref();
|
||||
|
||||
updateAccessibilityOptions();
|
||||
}
|
||||
updateAccessibilityOptions();
|
||||
}
|
||||
|
||||
private void setupAccessibilityModePref() {
|
||||
|
@ -59,7 +55,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
entryValues[i] = accessibilityModes[i].ordinal();
|
||||
}
|
||||
|
||||
ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(plugin.ACCESSIBILITY_MODE.getId());
|
||||
ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_MODE.getId());
|
||||
accessibilityMode.setEntries(entries);
|
||||
accessibilityMode.setEntryValues(entryValues);
|
||||
accessibilityMode.setDescription(R.string.accessibility_mode_descr);
|
||||
|
@ -73,7 +69,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
entries[i] = (int) (entryValues[i] * 100) + " %";
|
||||
}
|
||||
|
||||
ListPreferenceEx speechRate = (ListPreferenceEx) findPreference(plugin.SPEECH_RATE.getId());
|
||||
ListPreferenceEx speechRate = (ListPreferenceEx) findPreference(settings.SPEECH_RATE.getId());
|
||||
speechRate.setEntries(entries);
|
||||
speechRate.setEntryValues(entryValues);
|
||||
speechRate.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
|
||||
|
@ -81,7 +77,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
}
|
||||
|
||||
private void setupSmartAutoAnnouncePref() {
|
||||
SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(plugin.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
|
||||
SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
|
||||
smartAutoAnnounce.setDescription(getString(R.string.access_smart_autoannounce_descr));
|
||||
}
|
||||
|
||||
|
@ -103,19 +99,19 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
k++;
|
||||
}
|
||||
|
||||
ListPreferenceEx autoAnnouncePeriod = (ListPreferenceEx) findPreference(plugin.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.getId());
|
||||
ListPreferenceEx autoAnnouncePeriod = (ListPreferenceEx) findPreference(settings.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(plugin.DISABLE_OFFROUTE_RECALC.getId());
|
||||
SwitchPreferenceEx disableOffRouteRecalculation = (SwitchPreferenceEx) findPreference(settings.DISABLE_OFFROUTE_RECALC.getId());
|
||||
disableOffRouteRecalculation.setDescription(getString(R.string.access_disable_offroute_recalc_descr));
|
||||
}
|
||||
|
||||
private void setupDisableWrongDirectionRecalculationPref() {
|
||||
SwitchPreferenceEx disableWrongDirectionRecalculation = (SwitchPreferenceEx) findPreference(plugin.DISABLE_WRONG_DIRECTION_RECALC.getId());
|
||||
SwitchPreferenceEx disableWrongDirectionRecalculation = (SwitchPreferenceEx) findPreference(settings.DISABLE_WRONG_DIRECTION_RECALC.getId());
|
||||
disableWrongDirectionRecalculation.setDescription(getString(R.string.access_disable_wrong_direction_recalc_descr));
|
||||
}
|
||||
|
||||
|
@ -129,19 +125,19 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
entryValues[i] = relativeDirectionStyles[i].ordinal();
|
||||
}
|
||||
|
||||
ListPreferenceEx directionStyle = (ListPreferenceEx) findPreference(plugin.DIRECTION_STYLE.getId());
|
||||
ListPreferenceEx directionStyle = (ListPreferenceEx) findPreference(settings.DIRECTION_STYLE.getId());
|
||||
directionStyle.setEntries(entries);
|
||||
directionStyle.setEntryValues(entryValues);
|
||||
directionStyle.setDescription(R.string.settings_direction_style_descr);
|
||||
}
|
||||
|
||||
private void setupDirectionAudioFeedbackPref() {
|
||||
SwitchPreferenceEx directionAudioFeedback = (SwitchPreferenceEx) findPreference(plugin.DIRECTION_AUDIO_FEEDBACK.getId());
|
||||
SwitchPreferenceEx directionAudioFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_AUDIO_FEEDBACK.getId());
|
||||
directionAudioFeedback.setDescription(getString(R.string.access_direction_audio_feedback_descr));
|
||||
}
|
||||
|
||||
private void setupDirectionHapticFeedbackPref() {
|
||||
SwitchPreferenceEx directionHapticFeedback = (SwitchPreferenceEx) findPreference(plugin.DIRECTION_HAPTIC_FEEDBACK.getId());
|
||||
SwitchPreferenceEx directionHapticFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_HAPTIC_FEEDBACK.getId());
|
||||
directionHapticFeedback.setDescription(getString(R.string.access_direction_haptic_feedback_descr));
|
||||
}
|
||||
|
||||
|
@ -157,7 +153,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
|
||||
@Override
|
||||
public void onPreferenceChanged(String prefId) {
|
||||
if (plugin.ACCESSIBILITY_MODE.getId().equals(prefId)) {
|
||||
if (settings.ACCESSIBILITY_MODE.getId().equals(prefId)) {
|
||||
updateAccessibilityOptions();
|
||||
}
|
||||
}
|
||||
|
@ -198,11 +194,12 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
private void updateAccessibilityOptions() {
|
||||
boolean accessibilityEnabled = app.accessibilityEnabledForMode(getSelectedAppMode());
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen != null) {
|
||||
OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
|
||||
if (screen != null && plugin != null) {
|
||||
for (int i = 0; i < screen.getPreferenceCount(); i++) {
|
||||
Preference preference = screen.getPreference(i);
|
||||
String prefId = preference.getKey();
|
||||
if (!plugin.ACCESSIBILITY_MODE.getId().equals(prefId) && !plugin.SPEECH_RATE.getId().equals(prefId))
|
||||
if (!settings.ACCESSIBILITY_MODE.getId().equals(prefId) && !settings.SPEECH_RATE.getId().equals(prefId))
|
||||
preference.setEnabled(accessibilityEnabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,20 +46,20 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
private int value;
|
||||
|
||||
public RelativeDirection() {
|
||||
style = plugin.DIRECTION_STYLE.get();
|
||||
style = settings.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 = plugin.DIRECTION_STYLE.get();
|
||||
style = settings.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 = plugin.DIRECTION_STYLE.get();
|
||||
style = settings.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 = plugin.DIRECTION_STYLE.get();
|
||||
final RelativeDirectionStyle newStyle = settings.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 AccessibilityPlugin plugin;
|
||||
private final OsmandSettings settings;
|
||||
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;
|
||||
plugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
settings = app.getSettings();
|
||||
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) >= plugin.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.get()) {
|
||||
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) || !plugin.ACCESSIBILITY_SMART_AUTOANNOUNCE.get()) {
|
||||
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() {
|
||||
|
@ -281,7 +281,7 @@ public class NavigationInfo implements OsmAndCompassListener, OsmAndLocationList
|
|||
Integer inclination = direction.getInclination();
|
||||
if (targetDirectionFlag && ((inclination == null) || (inclination != 0))) {
|
||||
targetDirectionFlag = false;
|
||||
if (plugin.DIRECTION_AUDIO_FEEDBACK.get()) {
|
||||
if (settings.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 (plugin.DIRECTION_HAPTIC_FEEDBACK.get()) {
|
||||
if (settings.DIRECTION_HAPTIC_FEEDBACK.get()) {
|
||||
Vibrator haptic = (Vibrator)app.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if ((haptic != null) && haptic.hasVibrator()) {
|
||||
if (inclination == null) {
|
||||
|
|
|
@ -10,7 +10,6 @@ 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;
|
||||
|
@ -18,8 +17,6 @@ import net.osmand.plus.activities.SettingsBaseActivity;
|
|||
|
||||
public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
||||
|
||||
private AccessibilityPlugin plugin;
|
||||
|
||||
private ListPreference accessibilityModePreference;
|
||||
private ListPreference directionStylePreference;
|
||||
private ListPreference autoannouncePeriodPreference;
|
||||
|
@ -32,13 +29,11 @@ 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(plugin.ACCESSIBILITY_MODE, entries, AccessibilityMode.values(),
|
||||
accessibilityModePreference = createListPreference(settings.ACCESSIBILITY_MODE, entries, AccessibilityMode.values(),
|
||||
R.string.accessibility_mode, R.string.accessibility_mode_descr);
|
||||
accessibilityModePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
private final OnPreferenceChangeListener committer = accessibilityModePreference.getOnPreferenceChangeListener();
|
||||
|
@ -63,7 +58,7 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = RelativeDirectionStyle.values()[i].toHumanString(getMyApplication());
|
||||
}
|
||||
directionStylePreference = createListPreference(plugin.DIRECTION_STYLE, entries, RelativeDirectionStyle.values(),
|
||||
directionStylePreference = createListPreference(settings.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();
|
||||
|
@ -77,12 +72,12 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
});
|
||||
cat.addPreference(directionStylePreference);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(plugin.ACCESSIBILITY_SMART_AUTOANNOUNCE, R.string.access_smart_autoannounce,
|
||||
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(plugin.ACCESSIBILITY_AUTOANNOUNCE_PERIOD, seconds, minutes, 1000,
|
||||
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();
|
||||
|
@ -96,14 +91,14 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
});
|
||||
cat.addPreference(autoannouncePeriodPreference);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(plugin.DISABLE_OFFROUTE_RECALC, R.string.access_disable_offroute_recalc,
|
||||
cat.addPreference(createCheckBoxPreference(settings.DISABLE_OFFROUTE_RECALC, R.string.access_disable_offroute_recalc,
|
||||
R.string.access_disable_offroute_recalc_descr));
|
||||
cat.addPreference(createCheckBoxPreference(plugin.DISABLE_WRONG_DIRECTION_RECALC, R.string.access_disable_wrong_direction_recalc,
|
||||
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(plugin.DIRECTION_AUDIO_FEEDBACK, R.string.access_direction_audio_feedback,
|
||||
cat.addPreference(createCheckBoxPreference(settings.DIRECTION_AUDIO_FEEDBACK, R.string.access_direction_audio_feedback,
|
||||
R.string.access_direction_audio_feedback_descr));
|
||||
cat.addPreference(createCheckBoxPreference(plugin.DIRECTION_HAPTIC_FEEDBACK, R.string.access_direction_haptic_feedback,
|
||||
cat.addPreference(createCheckBoxPreference(settings.DIRECTION_HAPTIC_FEEDBACK, R.string.access_direction_haptic_feedback,
|
||||
R.string.access_direction_haptic_feedback_descr));
|
||||
|
||||
}
|
||||
|
@ -115,7 +110,7 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
for(int i = 0; i < sprNames.length; i++) {
|
||||
sprNames[i] = (int)(sprValues[i] * 100) + " %";
|
||||
}
|
||||
grp.addPreference(createListPreference(plugin.SPEECH_RATE, sprNames, sprValues, R.string.speech_rate, R.string.speech_rate_descr));
|
||||
grp.addPreference(createListPreference(settings.SPEECH_RATE, sprNames, sprValues, R.string.speech_rate, R.string.speech_rate_descr));
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,13 +121,14 @@ public class SettingsAccessibilityActivity extends SettingsBaseActivity {
|
|||
if (accessibilityOptions != null)
|
||||
accessibilityOptions.setEnabled(getMyApplication().accessibilityEnabled());
|
||||
if(accessibilityModePreference != null) {
|
||||
accessibilityModePreference.setSummary(getString(R.string.accessibility_mode_descr) + " [" + plugin.ACCESSIBILITY_MODE.get().toHumanString(getMyApplication()) + "]");
|
||||
accessibilityModePreference.setSummary(getString(R.string.accessibility_mode_descr) + " [" + settings.ACCESSIBILITY_MODE.get().toHumanString(getMyApplication()) + "]");
|
||||
}
|
||||
if(directionStylePreference != null) {
|
||||
directionStylePreference.setSummary(getString(R.string.settings_direction_style_descr) + " [" + plugin.DIRECTION_STYLE.get().toHumanString(getMyApplication()) + "]");
|
||||
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() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -877,11 +877,10 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
}
|
||||
|
||||
public boolean accessibilityEnabledForMode(ApplicationMode appMode) {
|
||||
AccessibilityPlugin accessibilityPlugin = OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class);
|
||||
if (accessibilityPlugin == null) {
|
||||
final AccessibilityMode mode = getSettings().ACCESSIBILITY_MODE.getModeValue(appMode);
|
||||
if (OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) == null) {
|
||||
return false;
|
||||
}
|
||||
AccessibilityMode mode = accessibilityPlugin.ACCESSIBILITY_MODE.getModeValue(appMode);
|
||||
if (mode == AccessibilityMode.ON) {
|
||||
return true;
|
||||
} else if (mode == AccessibilityMode.OFF) {
|
||||
|
|
|
@ -30,6 +30,8 @@ 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;
|
||||
|
@ -1407,6 +1409,21 @@ 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();
|
||||
|
||||
|
@ -1429,6 +1446,30 @@ 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,13 +1,12 @@
|
|||
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;
|
||||
|
@ -72,7 +71,6 @@ public class RoutingHelper {
|
|||
|
||||
private ApplicationMode mode;
|
||||
private OsmandSettings settings;
|
||||
private AccessibilityPlugin accessibilityPlugin;
|
||||
|
||||
private RouteProvider provider;
|
||||
private VoiceRouter voiceRouter;
|
||||
|
@ -103,7 +101,6 @@ public class RoutingHelper {
|
|||
transportRoutingHelper = context.getTransportRoutingHelper();
|
||||
transportRoutingHelper.setRoutingHelper(this);
|
||||
setAppMode(settings.APPLICATION_MODE.get());
|
||||
accessibilityPlugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
|
||||
OsmAndAppCustomizationListener customizationListener = new OsmAndAppCustomizationListener() {
|
||||
@Override
|
||||
|
@ -398,7 +395,7 @@ public class RoutingHelper {
|
|||
// >100m off current route (sideways)
|
||||
if (currentRoute > 0) {
|
||||
distOrth = getOrthogonalDistance(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute));
|
||||
if ((!accessibilityPlugin.DISABLE_OFFROUTE_RECALC.get()) && (distOrth > (1.7 * posTolerance))) {
|
||||
if ((!settings.DISABLE_OFFROUTE_RECALC.get()) && (distOrth > (1.7 * posTolerance))) {
|
||||
log.info("Recalculate route, because correlation : " + distOrth); //$NON-NLS-1$
|
||||
isDeviatedFromRoute = true;
|
||||
calculateRoute = true;
|
||||
|
@ -407,7 +404,7 @@ public class RoutingHelper {
|
|||
// 3. Identify wrong movement direction
|
||||
Location next = route.getNextRouteLocation();
|
||||
boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next);
|
||||
if ((!accessibilityPlugin.DISABLE_WRONG_DIRECTION_RECALC.get()) && 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$
|
||||
isDeviatedFromRoute = true;
|
||||
calculateRoute = true;
|
||||
|
|
|
@ -14,10 +14,8 @@ 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;
|
||||
|
@ -85,9 +83,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
|||
ctx.getString(R.string.voice_data_corrupted));
|
||||
}
|
||||
OsmandApplication app = (OsmandApplication) ctx.getApplicationContext();
|
||||
AccessibilityPlugin accessibilityPlugin = OsmandPlugin.getPlugin(AccessibilityPlugin.class);
|
||||
if (app.accessibilityEnabled() && accessibilityPlugin != null) {
|
||||
cSpeechRate = accessibilityPlugin.SPEECH_RATE.get();
|
||||
if(app.accessibilityEnabled()) {
|
||||
cSpeechRate = app.getSettings().SPEECH_RATE.get();
|
||||
}
|
||||
initializeEngine(app, ctx);
|
||||
params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, app.getSettings().AUDIO_STREAM_GUIDANCE
|
||||
|
|
Loading…
Reference in a new issue