From 57f66b77abb445d28766a60110218a2cd899b32f Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Tue, 5 Nov 2019 20:03:46 +0100 Subject: [PATCH] Reorganized settings (sharedpreferences and keys); xml only. --- .../opentracks/TrackDetailActivity.java | 4 +- .../sensors/BluetoothRemoteSensorManager.java | 6 +- .../opentracks/settings/PreferenceHelper.java | 4 +- .../opentracks/settings/SettingsActivity.java | 2 +- .../opentracks/util/StatsUtils.java | 2 +- src/main/res/values/do_not_translate.xml | 68 ++++++-- src/main/res/values/preference_keys.xml | 49 ------ src/main/res/values/preferences_internal.xml | 22 +++ ...rays_do_not_translate.xml => settings.xml} | 161 ++++++++---------- src/main/res/xml/settings.xml | 4 +- 10 files changed, 162 insertions(+), 160 deletions(-) delete mode 100644 src/main/res/values/preference_keys.xml create mode 100644 src/main/res/values/preferences_internal.xml rename src/main/res/values/{arrays_do_not_translate.xml => settings.xml} (68%) diff --git a/src/main/java/de/dennisguse/opentracks/TrackDetailActivity.java b/src/main/java/de/dennisguse/opentracks/TrackDetailActivity.java index 585091490..3c42e6030 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackDetailActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackDetailActivity.java @@ -133,8 +133,8 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA recordingTrackPaused = PreferencesUtils.getBoolean(TrackDetailActivity.this, R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT); } - if (PreferencesUtils.isKey(TrackDetailActivity.this, R.string.trackdetail_show_on_lockscreen_while_recording_key, key)) { - showOnLockScreen = PreferencesUtils.getBoolean(TrackDetailActivity.this, R.string.trackdetail_show_on_lockscreen_while_recording_key, PreferencesUtils.SHOW_TRACKDETAIL_WHILE_RECORDING_ON_LOCKSCREEN); + if (PreferencesUtils.isKey(TrackDetailActivity.this, R.string.stats_show_on_lockscreen_while_recording_key, key)) { + showOnLockScreen = PreferencesUtils.getBoolean(TrackDetailActivity.this, R.string.stats_show_on_lockscreen_while_recording_key, PreferencesUtils.SHOW_TRACKDETAIL_WHILE_RECORDING_ON_LOCKSCREEN); setLockscreenPolicy(); } diff --git a/src/main/java/de/dennisguse/opentracks/services/sensors/BluetoothRemoteSensorManager.java b/src/main/java/de/dennisguse/opentracks/services/sensors/BluetoothRemoteSensorManager.java index 3132cff8d..aceef293a 100644 --- a/src/main/java/de/dennisguse/opentracks/services/sensors/BluetoothRemoteSensorManager.java +++ b/src/main/java/de/dennisguse/opentracks/services/sensors/BluetoothRemoteSensorManager.java @@ -87,8 +87,8 @@ public class BluetoothRemoteSensorManager { private final SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { - if (bluetoothConnectionManager != null && PreferencesUtils.isKey(context, R.string.bluetooth_sensor_key, key)) { - String address = PreferencesUtils.getString(context, R.string.bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT); + if (bluetoothConnectionManager != null && PreferencesUtils.isKey(context, R.string.settings_sensor_bluetooth_sensor_key, key)) { + String address = PreferencesUtils.getString(context, R.string.settings_sensor_bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT); if (address.equals(PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT)) { stop(); return; @@ -184,7 +184,7 @@ public class BluetoothRemoteSensorManager { return; } - String address = PreferencesUtils.getString(context, R.string.bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT); + String address = PreferencesUtils.getString(context, R.string.settings_sensor_bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT); if (PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT.equals(address)) { Log.w(TAG, "No bluetooth address."); return; diff --git a/src/main/java/de/dennisguse/opentracks/settings/PreferenceHelper.java b/src/main/java/de/dennisguse/opentracks/settings/PreferenceHelper.java index 419a88c87..84731e344 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/PreferenceHelper.java +++ b/src/main/java/de/dennisguse/opentracks/settings/PreferenceHelper.java @@ -187,7 +187,7 @@ final class PreferenceHelper { static void configureBluetoothSensorList(ListPreference preference) { Context context = preference.getContext(); - String value = PreferencesUtils.getString(context, R.string.bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT); + String value = PreferencesUtils.getString(context, R.string.settings_sensor_bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT); List devicesNameList = new ArrayList<>(); List devicesAddressList = new ArrayList<>(); BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); @@ -198,7 +198,7 @@ final class PreferenceHelper { // Was the previously configured device unpaired? Then forget it. if (!devicesAddressList.contains(value)) { value = PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT; - PreferencesUtils.setString(context, R.string.bluetooth_sensor_key, value); + PreferencesUtils.setString(context, R.string.settings_sensor_bluetooth_sensor_key, value); } devicesNameList.add(0, context.getString(R.string.value_none)); diff --git a/src/main/java/de/dennisguse/opentracks/settings/SettingsActivity.java b/src/main/java/de/dennisguse/opentracks/settings/SettingsActivity.java index 8b773c199..cd33ba81b 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/SettingsActivity.java +++ b/src/main/java/de/dennisguse/opentracks/settings/SettingsActivity.java @@ -155,7 +155,7 @@ public class SettingsActivity extends AppCompatActivity implements ChooseActivit Preference speedCheckBoxPreference = findPreference(getString(R.string.chart_show_speed_key)); speedCheckBoxPreference.setTitle(PreferencesUtils.isReportSpeed(getActivity()) ? R.string.stats_speed : R.string.stats_pace); - ListPreference bluetoothPreference = findPreference(getString(R.string.bluetooth_sensor_key)); + ListPreference bluetoothPreference = findPreference(getString(R.string.settings_sensor_bluetooth_sensor_key)); PreferenceHelper.configureBluetoothSensorList(bluetoothPreference); } diff --git a/src/main/java/de/dennisguse/opentracks/util/StatsUtils.java b/src/main/java/de/dennisguse/opentracks/util/StatsUtils.java index 20efaba3d..a391ec507 100644 --- a/src/main/java/de/dennisguse/opentracks/util/StatsUtils.java +++ b/src/main/java/de/dennisguse/opentracks/util/StatsUtils.java @@ -108,7 +108,7 @@ public class StatsUtils { public static void setSensorData(Activity activity, SensorDataSet sensorDataSet, boolean isRecording) { // heart rate int isVisible = View.VISIBLE; - if (!isRecording || PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT.equals(PreferencesUtils.getString(activity, R.string.bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT))) { + if (!isRecording || PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT.equals(PreferencesUtils.getString(activity, R.string.settings_sensor_bluetooth_sensor_key, PreferencesUtils.BLUETOOTH_SENSOR_DEFAULT))) { isVisible = View.INVISIBLE; } activity.findViewById(R.id.stats_sensor_container).setVisibility(isVisible); diff --git a/src/main/res/values/do_not_translate.xml b/src/main/res/values/do_not_translate.xml index a35480c73..0afe48518 100644 --- a/src/main/res/values/do_not_translate.xml +++ b/src/main/res/values/do_not_translate.xml @@ -15,20 +15,68 @@ limitations under the License. --> https://github.com/dennisguse/opentracks - DISTANCE - TIME + Google\'s androidX support (Apache License, Version 2.0) + http://maps.google.com/mapfiles/ms/micons/ylw-pushpin.png http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png - NONE + BPM - DATE_ISO_8601 - DATE_LOCAL - NUMBER - PACE - SPEED - IMPERIAL - METRIC + - + + + @string/waypoint_type_atm + @string/waypoint_type_bank + @string/waypoint_type_bar + @string/waypoint_type_barbecue + @string/waypoint_type_building + @string/waypoint_type_bus_stop + @string/waypoint_type_cafe + @string/waypoint_type_campfire + @string/waypoint_type_campground + @string/waypoint_type_church + @string/waypoint_type_coffee_house + @string/waypoint_type_convenience_store + @string/waypoint_type_drinking_water + @string/waypoint_type_falling_rocks + @string/waypoint_type_ferry + @string/waypoint_type_fire_place + @string/waypoint_type_fire_station + @string/waypoint_type_fishing + @string/waypoint_type_gas_station + @string/waypoint_type_golf_course + @string/waypoint_type_grocery_store + @string/waypoint_type_hair_dresser + @string/waypoint_type_harbor + @string/waypoint_type_hiking_path + @string/waypoint_type_hotel + @string/waypoint_type_house + @string/waypoint_type_information + @string/waypoint_type_intersection + @string/waypoint_type_mail_box + @string/waypoint_type_market + @string/waypoint_type_meeting_point + @string/waypoint_type_opera + @string/waypoint_type_parking + @string/waypoint_type_police_station + @string/waypoint_type_post_office + @string/waypoint_type_pothole + @string/waypoint_type_railway_crossing + @string/waypoint_type_restaurant + @string/waypoint_type_shopping + @string/waypoint_type_sight + @string/waypoint_type_store + @string/waypoint_type_swimming_pool + @string/waypoint_type_telephone + @string/waypoint_type_theater + @string/waypoint_type_toilet + @string/waypoint_type_tourist_information + @string/waypoint_type_tree + @string/waypoint_type_tunnel + @string/waypoint_type_waterfall + @string/waypoint_type_water_fountain + @string/waypoint_type_waypoint + \ No newline at end of file diff --git a/src/main/res/values/preference_keys.xml b/src/main/res/values/preference_keys.xml deleted file mode 100644 index d9f2e3265..000000000 --- a/src/main/res/values/preference_keys.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - autoResumeTrackTimeout - chartShowCadence - chartShowElevation - chartShowHeartRate - chartShowPower - chartShowSpeed - chartXAxis - defaultActivity - maxRecordingDistance - minRecordingInterval - recordingDistanceInterval - recordingGpsAccuracy - splitFrequency - - statsRate - statsShowCoordinate - statsShowGradeElevation - statsUnits - trackdetail_show_on_lockscreen_while_recording - trackName - voiceFrequency - - autoResumeTrackCurrentRetry - bluetoothSensor - recordingTrackId - recordingTrackPaused - - settingsRecording - settingsReset - settingsSensorBluetoothPairing - settingsStats - \ No newline at end of file diff --git a/src/main/res/values/preferences_internal.xml b/src/main/res/values/preferences_internal.xml new file mode 100644 index 000000000..01d8c65dc --- /dev/null +++ b/src/main/res/values/preferences_internal.xml @@ -0,0 +1,22 @@ + + + + + autoResumeTrackCurrentRetry + recordingTrackId + recordingTrackPaused + \ No newline at end of file diff --git a/src/main/res/values/arrays_do_not_translate.xml b/src/main/res/values/settings.xml similarity index 68% rename from src/main/res/values/arrays_do_not_translate.xml rename to src/main/res/values/settings.xml index 0ad462b6f..c4d2544e8 100644 --- a/src/main/res/values/arrays_do_not_translate.xml +++ b/src/main/res/values/settings.xml @@ -1,20 +1,23 @@ - + - + + chartShowCadence + chartShowElevation + chartShowHeartRate + chartShowPower + chartShowSpeed + + statsShowCoordinate + statsShowGradeElevation + trackdetail_show_on_lockscreen_while_recording + + settingsReset + + bluetoothSensor + settingsSensorBluetoothPairing + NONE + + defaultActivity @string/activity_type_airplane @string/activity_type_atv @@ -83,6 +86,8 @@ limitations under the License. @string/activity_type_water_skiing @string/activity_type_wind_surfing + + autoResumeTrackTimeout 0 5 @@ -90,14 +95,21 @@ limitations under the License. 15 -1 - - @string/settings_chart_by_distance - @string/settings_chart_by_time - + + chartXAxis @string/chart_x_axis_distance @string/chart_x_axis_time + TIME + DISTANCE + + @string/settings_chart_by_distance + @string/settings_chart_by_time + + + splitFrequency + voiceFrequency 0 1 @@ -114,6 +126,19 @@ limitations under the License. -50 -100 + + recordingDistanceInterval + + 1 + 2 + 5 + 10 + 20 + 50 + 100 + + + maxRecordingDistance 50 100 @@ -122,6 +147,8 @@ limitations under the License. 1000 5000 + + minRecordingInterval -2 -1 @@ -140,15 +167,8 @@ limitations under the License. 900 1800 - - 1 - 2 - 5 - 10 - 20 - 50 - 100 - + + recordingGpsAccuracy 10 20 @@ -160,6 +180,8 @@ limitations under the License. 1000 2000 + + statsRate @string/description_speed_imperial @string/description_pace_imperial @@ -168,79 +190,38 @@ limitations under the License. @string/description_speed_metric @string/description_pace_metric + + PACE + SPEED @string/stats_rate_speed @string/stats_rate_pace + + statsUnits + + @string/stats_units_metric + @string/stats_units_imperial + + METRIC + IMPERIAL @string/settings_stats_units_metric @string/settings_stats_units_imperial - - @string/stats_units_metric - @string/stats_units_imperial + + trackName + DATE_ISO_8601 + DATE_LOCAL + NUMBER + + @string/settings_recording_track_name_date_local_value + @string/settings_recording_track_name_date_iso_8601_value + @string/settings_recording_track_name_number_value @string/settings_recording_track_name_date_local_option @string/settings_recording_track_name_date_iso_8601_option @string/settings_recording_track_name_number_option - - @string/settings_recording_track_name_date_local_value - @string/settings_recording_track_name_date_iso_8601_value - @string/settings_recording_track_name_number_value - - - @string/waypoint_type_atm - @string/waypoint_type_bank - @string/waypoint_type_bar - @string/waypoint_type_barbecue - @string/waypoint_type_building - @string/waypoint_type_bus_stop - @string/waypoint_type_cafe - @string/waypoint_type_campfire - @string/waypoint_type_campground - @string/waypoint_type_church - @string/waypoint_type_coffee_house - @string/waypoint_type_convenience_store - @string/waypoint_type_drinking_water - @string/waypoint_type_falling_rocks - @string/waypoint_type_ferry - @string/waypoint_type_fire_place - @string/waypoint_type_fire_station - @string/waypoint_type_fishing - @string/waypoint_type_gas_station - @string/waypoint_type_golf_course - @string/waypoint_type_grocery_store - @string/waypoint_type_hair_dresser - @string/waypoint_type_harbor - @string/waypoint_type_hiking_path - @string/waypoint_type_hotel - @string/waypoint_type_house - @string/waypoint_type_information - @string/waypoint_type_intersection - @string/waypoint_type_mail_box - @string/waypoint_type_market - @string/waypoint_type_meeting_point - @string/waypoint_type_opera - @string/waypoint_type_parking - @string/waypoint_type_police_station - @string/waypoint_type_post_office - @string/waypoint_type_pothole - @string/waypoint_type_railway_crossing - @string/waypoint_type_restaurant - @string/waypoint_type_shopping - @string/waypoint_type_sight - @string/waypoint_type_store - @string/waypoint_type_swimming_pool - @string/waypoint_type_telephone - @string/waypoint_type_theater - @string/waypoint_type_toilet - @string/waypoint_type_tourist_information - @string/waypoint_type_tree - @string/waypoint_type_tunnel - @string/waypoint_type_waterfall - @string/waypoint_type_water_fountain - @string/waypoint_type_waypoint - \ No newline at end of file diff --git a/src/main/res/xml/settings.xml b/src/main/res/xml/settings.xml index ef2fe00c4..3e4cfa2a1 100644 --- a/src/main/res/xml/settings.xml +++ b/src/main/res/xml/settings.xml @@ -69,7 +69,7 @@ limitations under the License.