From 0c0233fc6348e1ee6b665fddbc7cb1b50515046c Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 25 Jun 2020 12:53:34 +0300 Subject: [PATCH] Add preference and UI --- OsmAnd/res/values/strings.xml | 2 ++ OsmAnd/res/xml/general_profile_settings.xml | 8 ++++++++ .../net/osmand/plus/settings/backend/OsmandSettings.java | 1 + .../fragments/GeneralProfileSettingsFragment.java | 9 +++++++++ 4 files changed, 20 insertions(+) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 096d691d91..6eacd5c202 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,8 @@ Thx - Hardy --> + Volume buttons as zoom + Enable to control the map zoom level with device volume buttons. Inline skates This device doesn\'t have speed cameras. Uninstall and Restart diff --git a/OsmAnd/res/xml/general_profile_settings.xml b/OsmAnd/res/xml/general_profile_settings.xml index e0c7ec3fa7..6a4148647e 100644 --- a/OsmAnd/res/xml/general_profile_settings.xml +++ b/OsmAnd/res/xml/general_profile_settings.xml @@ -82,6 +82,14 @@ android:layout="@layout/preference_category_with_descr" android:title="@string/shared_string_other" /> + + USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeProfile().cache(); public final OsmandPreference USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().cache(); + public final OsmandPreference USE_VOLUME_BUTTONS_AS_ZOOM = new BooleanPreference("use_volume_buttons_as_zoom", false).makeProfile().cache(); public final OsmandPreference DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache(); public final OsmandPreference SHOW_DOWNLOAD_MAP_DIALOG = new BooleanPreference("show_download_map_dialog", true).makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java index 4ac4d78d32..80488797ec 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java @@ -54,6 +54,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme setupAngularUnitsPref(); setupSpeedSystemPref(); + setupVolumeButtonsAsZoom(); setupKalmanFilterPref(); setupMagneticFieldSensorPref(); setupMapEmptyStateAllowedPref(); @@ -224,6 +225,14 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme speedSystem.setIcon(getActiveIcon(R.drawable.ic_action_speed)); } + private void setupVolumeButtonsAsZoom() { + SwitchPreferenceEx volumeButtonsPref = (SwitchPreferenceEx) findPreference(settings.USE_VOLUME_BUTTONS_AS_ZOOM.getId()); + volumeButtonsPref.setTitle(getString(R.string.use_volume_buttons_as_zoom)); + volumeButtonsPref.setDescription(getString(R.string.use_volume_buttons_as_zoom_descr)); + Drawable icon = getPersistentPrefIcon(R.drawable.ic_action_zoom_volume_buttons); + volumeButtonsPref.setIcon(icon); + } + private void setupKalmanFilterPref() { SwitchPreferenceEx kalmanFilterPref = (SwitchPreferenceEx) findPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS.getId()); kalmanFilterPref.setTitle(getString(R.string.use_kalman_filter_compass));