diff --git a/OsmAnd/res/layout/preference_button.xml b/OsmAnd/res/layout/preference_button.xml
index 5c08af4f86..948c7daaee 100644
--- a/OsmAnd/res/layout/preference_button.xml
+++ b/OsmAnd/res/layout/preference_button.xml
@@ -48,7 +48,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
- android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?colorAccent"
android:textSize="@dimen/default_list_text_size"
diff --git a/OsmAnd/res/layout/preference_radio_button.xml b/OsmAnd/res/layout/preference_radio_button.xml
index f512a7b2ef..db80396b11 100644
--- a/OsmAnd/res/layout/preference_radio_button.xml
+++ b/OsmAnd/res/layout/preference_radio_button.xml
@@ -41,7 +41,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
- android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
diff --git a/OsmAnd/res/layout/preference_switch_with_descr.xml b/OsmAnd/res/layout/preference_switch_with_descr.xml
index d87f77d2bc..5818638e11 100644
--- a/OsmAnd/res/layout/preference_switch_with_descr.xml
+++ b/OsmAnd/res/layout/preference_switch_with_descr.xml
@@ -38,7 +38,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
- android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
diff --git a/OsmAnd/res/layout/preference_with_descr.xml b/OsmAnd/res/layout/preference_with_descr.xml
index f8ac00eb23..f9e01e34a9 100644
--- a/OsmAnd/res/layout/preference_with_descr.xml
+++ b/OsmAnd/res/layout/preference_with_descr.xml
@@ -48,7 +48,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
- android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
diff --git a/OsmAnd/res/layout/preference_with_descr_dialog_and_switch.xml b/OsmAnd/res/layout/preference_with_descr_dialog_and_switch.xml
index 9ee9933fe4..9503b17288 100644
--- a/OsmAnd/res/layout/preference_with_descr_dialog_and_switch.xml
+++ b/OsmAnd/res/layout/preference_with_descr_dialog_and_switch.xml
@@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
- android:singleLine="true"
+ android:maxLines="2"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
diff --git a/OsmAnd/res/layout/profile_edit_list_item.xml b/OsmAnd/res/layout/profile_edit_list_item.xml
index 180ebbad6f..51f763ee1a 100644
--- a/OsmAnd/res/layout/profile_edit_list_item.xml
+++ b/OsmAnd/res/layout/profile_edit_list_item.xml
@@ -53,7 +53,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
- android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index c0e6c0d57e..b0c49508ad 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,6 +11,8 @@
Thx - Hardy
-->
+ Route recalculation
+ Announce
Username and password
This plugin settings are global, and apply to all profiles.
OpenStreetMap Editing
diff --git a/OsmAnd/res/xml/accessibility_settings.xml b/OsmAnd/res/xml/accessibility_settings.xml
new file mode 100644
index 0000000000..c11ba73e18
--- /dev/null
+++ b/OsmAnd/res/xml/accessibility_settings.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/xml/osm_editing.xml b/OsmAnd/res/xml/osm_editing.xml
index d34e6483dd..369b05b2cf 100644
--- a/OsmAnd/res/xml/osm_editing.xml
+++ b/OsmAnd/res/xml/osm_editing.xml
@@ -24,8 +24,8 @@
android:icon="@drawable/ic_action_offline"
android:key="offline_osm_editing"
android:layout="@layout/preference_with_descr_dialog_and_switch"
- android:summaryOff="@string/shared_string_off"
- android:summaryOn="@string/shared_string_on"
+ android:summaryOff="@string/shared_string_disabled"
+ android:summaryOn="@string/shared_string_enabled"
android:title="@string/offline_edition" />
getSettingsFragment() {
- return null;
+ return AccessibilitySettingsFragment.class;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
index 0fdffdf8cb..cd2ce9e711 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
@@ -871,10 +871,14 @@ public class OsmandApplication extends MultiDexApplication {
public OsmandRegions getRegions() {
return regions;
}
-
+
public boolean accessibilityEnabled() {
- final AccessibilityMode mode = getSettings().ACCESSIBILITY_MODE.get();
- if(OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) == null) {
+ return accessibilityEnabledForMode(getSettings().APPLICATION_MODE.get());
+ }
+
+ public boolean accessibilityEnabledForMode(ApplicationMode appMode) {
+ final AccessibilityMode mode = getSettings().ACCESSIBILITY_MODE.getModeValue(appMode);
+ if (OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) == null) {
return false;
}
if (mode == AccessibilityMode.ON) {
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index 7af035b217..cec5ba509a 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -1374,16 +1374,16 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often
public final OsmandPreference DIRECTION_STYLE = new EnumIntPreference(
- "direction_style", RelativeDirectionStyle.SIDEWISE, RelativeDirectionStyle.values()).makeGlobal().cache();
+ "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 ACCESSIBILITY_MODE = new EnumIntPreference(
- "accessibility_mode", AccessibilityMode.DEFAULT, AccessibilityMode.values()).makeGlobal().cache();
+ "accessibility_mode", AccessibilityMode.DEFAULT, AccessibilityMode.values()).makeProfile().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference SPEECH_RATE =
- new FloatPreference("speech_rate", 1f).makeGlobal();
+ new FloatPreference("speech_rate", 1f).makeProfile();
public final OsmandPreference ARRIVAL_DISTANCE_FACTOR =
new FloatPreference("arrival_distance_factor", 1f).makeProfile();
@@ -1409,27 +1409,27 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference ACCESSIBILITY_SMART_AUTOANNOUNCE =
- new BooleanAccessibilityPreference("accessibility_smart_autoannounce", true).makeGlobal();
+ 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 ACCESSIBILITY_AUTOANNOUNCE_PERIOD = new IntPreference("accessibility_autoannounce_period", 10000).makeGlobal().cache();
+ public final OsmandPreference 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 DISABLE_OFFROUTE_RECALC =
- new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeGlobal();
+ new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference DISABLE_WRONG_DIRECTION_RECALC =
- new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeGlobal();
+ new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference DIRECTION_AUDIO_FEEDBACK =
- new BooleanAccessibilityPreference("direction_audio_feedback", false).makeGlobal();
+ new BooleanAccessibilityPreference("direction_audio_feedback", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference DIRECTION_HAPTIC_FEEDBACK =
- new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeGlobal();
+ new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeProfile();
// magnetic field doesn'torkmost of the time on some phones
public final OsmandPreference USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeProfile().cache();
diff --git a/OsmAnd/src/net/osmand/plus/settings/AccessibilitySettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/AccessibilitySettingsFragment.java
new file mode 100644
index 0000000000..1f7fc0c048
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/AccessibilitySettingsFragment.java
@@ -0,0 +1,163 @@
+package net.osmand.plus.settings;
+
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import net.osmand.plus.R;
+import net.osmand.plus.access.AccessibilityMode;
+import net.osmand.plus.access.RelativeDirectionStyle;
+import net.osmand.plus.settings.preferences.ListPreferenceEx;
+import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
+
+public class AccessibilitySettingsFragment extends BaseSettingsFragment implements OnPreferenceChanged {
+
+ private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
+ private static final String RESET_TO_DEFAULT = "reset_to_default";
+
+ @Override
+ protected void setupPreferences() {
+ setupAccessibilityModePref();
+ setupSpeechRatePref();
+
+ setupSmartAutoAnnouncePref();
+ setupAutoAnnouncePeriodPref();
+
+ setupDisableOffRouteRecalculationPref();
+ setupDisableWrongDirectionRecalculationPref();
+
+ setupDirectionStylePref();
+ setupDirectionAudioFeedbackPref();
+ setupDirectionHapticFeedbackPref();
+
+ setupCopyProfileSettingsPref();
+ setupResetToDefaultPref();
+
+ updateAccessibilityOptions();
+ }
+
+ private void setupAccessibilityModePref() {
+ AccessibilityMode[] accessibilityModes = AccessibilityMode.values();
+ String[] entries = new String[accessibilityModes.length];
+ Integer[] entryValues = new Integer[accessibilityModes.length];
+
+ for (int i = 0; i < entries.length; i++) {
+ entries[i] = accessibilityModes[i].toHumanString(app);
+ entryValues[i] = accessibilityModes[i].ordinal();
+ }
+
+ ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_MODE.getId());
+ accessibilityMode.setEntries(entries);
+ accessibilityMode.setEntryValues(entryValues);
+ accessibilityMode.setDescription(R.string.accessibility_mode_descr);
+ }
+
+ private void setupSpeechRatePref() {
+ Float[] entryValues = new Float[] {0.5f, 0.75f, 1f, 1.25f, 1.5f, 2f};
+ String[] entries = new String[entryValues.length];
+
+ for (int i = 0; i < entries.length; i++) {
+ entries[i] = (int) (entryValues[i] * 100) + " %";
+ }
+
+ ListPreferenceEx speechRate = (ListPreferenceEx) findPreference(settings.SPEECH_RATE.getId());
+ speechRate.setEntries(entries);
+ speechRate.setEntryValues(entryValues);
+ speechRate.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
+ speechRate.setDescription(R.string.speech_rate_descr);
+ }
+
+ private void setupSmartAutoAnnouncePref() {
+ SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
+ smartAutoAnnounce.setDescription(getString(R.string.access_smart_autoannounce_descr));
+ }
+
+ private void setupAutoAnnouncePeriodPref() {
+ int[] seconds = new int[] {5, 10, 15, 20, 30, 45, 60, 90};
+ int[] minutes = new int[] {2, 3, 5};
+
+ Integer[] entryValues = new Integer[seconds.length + minutes.length];
+ String[] entries = new String[entryValues.length];
+ int k = 0;
+ for (int second : seconds) {
+ entryValues[k] = second * 1000;
+ entries[k] = second + " " + getString(R.string.int_seconds);
+ k++;
+ }
+ for (int minute : minutes) {
+ entryValues[k] = (minute * 60) * 1000;
+ entries[k] = minute + " " + getString(R.string.int_min);
+ k++;
+ }
+
+ 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(settings.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());
+ disableWrongDirectionRecalculation.setDescription(getString(R.string.access_disable_wrong_direction_recalc_descr));
+ }
+
+ private void setupDirectionStylePref() {
+ RelativeDirectionStyle[] relativeDirectionStyles = RelativeDirectionStyle.values();
+ String[] entries = new String[relativeDirectionStyles.length];
+ Integer[] entryValues = new Integer[relativeDirectionStyles.length];
+
+ for (int i = 0; i < entries.length; i++) {
+ entries[i] = relativeDirectionStyles[i].toHumanString(app);
+ entryValues[i] = relativeDirectionStyles[i].ordinal();
+ }
+
+ 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(settings.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());
+ directionHapticFeedback.setDescription(getString(R.string.access_direction_haptic_feedback_descr));
+ }
+
+ private void setupCopyProfileSettingsPref() {
+ Preference copyProfilePrefs = findPreference(COPY_PLUGIN_SETTINGS);
+ copyProfilePrefs.setIcon(getActiveIcon(R.drawable.ic_action_copy));
+ }
+
+ private void setupResetToDefaultPref() {
+ Preference resetToDefault = findPreference(RESET_TO_DEFAULT);
+ resetToDefault.setIcon(getActiveIcon(R.drawable.ic_action_reset_to_default_dark));
+ }
+
+ @Override
+ public void onPreferenceChanged(String prefId) {
+ if (settings.ACCESSIBILITY_MODE.getId().equals(prefId)) {
+ updateAccessibilityOptions();
+ }
+ }
+
+ private void updateAccessibilityOptions() {
+ boolean accessibilityEnabled = app.accessibilityEnabledForMode(getSelectedAppMode());
+ PreferenceScreen screen = getPreferenceScreen();
+ if (screen != null) {
+ 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))
+ preference.setEnabled(accessibilityEnabled);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
index 74bd76ba79..b9c1bfc48c 100644
--- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java
@@ -95,6 +95,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
ROUTE_PARAMETERS(RouteParametersFragment.class.getName(), true, R.xml.route_parameters, R.layout.profile_preference_toolbar),
SCREEN_ALERTS(ScreenAlertsFragment.class.getName(), true, R.xml.screen_alerts, R.layout.profile_preference_toolbar_with_switch),
VOICE_ANNOUNCES(VoiceAnnouncesFragment.class.getName(), true, R.xml.voice_announces, R.layout.profile_preference_toolbar_with_switch),
+ ACCESSIBILITY_SETTINGS(AccessibilitySettingsFragment.class.getName(), true, R.xml.accessibility_settings, R.layout.profile_preference_toolbar_big),
VEHICLE_PARAMETERS(VehicleParametersFragment.class.getName(), true, R.xml.vehicle_parameters, R.layout.profile_preference_toolbar),
MAP_DURING_NAVIGATION(MapDuringNavigationFragment.class.getName(), true, R.xml.map_during_navigation, R.layout.profile_preference_toolbar),
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, R.xml.turn_screen_on, R.layout.profile_preference_toolbar_with_switch),
diff --git a/OsmAnd/src/net/osmand/plus/settings/OsmEditingFragment.java b/OsmAnd/src/net/osmand/plus/settings/OsmEditingFragment.java
index 981e23f0d1..f4b3962ec3 100644
--- a/OsmAnd/src/net/osmand/plus/settings/OsmEditingFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/OsmEditingFragment.java
@@ -13,7 +13,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.settings.bottomsheets.OsmLoginDataBottomSheet;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
-public class OsmEditingFragment extends BaseSettingsFragment {
+public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged {
private static final String OPEN_OSM_EDITS = "open_osm_edits";
private static final String OSM_LOGIN_DATA = "osm_login_data";
@@ -77,4 +77,12 @@ public class OsmEditingFragment extends BaseSettingsFragment {
}
return super.onPreferenceClick(preference);
}
+
+ @Override
+ public void onPreferenceChanged(String prefId) {
+ if (OSM_LOGIN_DATA.equals(prefId)) {
+ Preference nameAndPasswordPref = findPreference(OSM_LOGIN_DATA);
+ nameAndPasswordPref.setSummary(settings.USER_NAME.get());
+ }
+ }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/OsmLoginDataBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/OsmLoginDataBottomSheet.java
index 7735f56d48..8865458e85 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/OsmLoginDataBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/OsmLoginDataBottomSheet.java
@@ -18,6 +18,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.osmedit.SettingsOsmEditingActivity;
+import net.osmand.plus.settings.OnPreferenceChanged;
public class OsmLoginDataBottomSheet extends BasePreferenceBottomSheet {
@@ -32,8 +33,7 @@ public class OsmLoginDataBottomSheet extends BasePreferenceBottomSheet {
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context context = getContext();
- Preference editTextPreference = getPreference();
- if (context == null || editTextPreference == null) {
+ if (context == null) {
return;
}
OsmandApplication app = requiredMyApplication();
@@ -83,7 +83,13 @@ public class OsmLoginDataBottomSheet extends BasePreferenceBottomSheet {
app.getSettings().USER_NAME.set(userNameEditText.getText().toString());
app.getSettings().USER_PASSWORD.set(passwordEditText.getText().toString());
- new SettingsOsmEditingActivity.ValidateOsmLoginDetailsTask(getActivity()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new SettingsOsmEditingActivity.ValidateOsmLoginDetailsTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+
+ Fragment target = getTargetFragment();
+ Preference preference = getPreference();
+ if (target instanceof OnPreferenceChanged && preference != null) {
+ ((OnPreferenceChanged) target).onPreferenceChanged(preference.getKey());
+ }
dismiss();
}