Reorganized settings (sharedpreferences and keys); xml only.

This commit is contained in:
Dennis Guse
2019-11-05 20:03:46 +01:00
parent 53572406e9
commit 57f66b77ab
10 changed files with 162 additions and 160 deletions
@@ -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();
}
@@ -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;
@@ -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<String> devicesNameList = new ArrayList<>();
List<String> 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));
@@ -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);
}
@@ -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);
+58 -10
View File
@@ -15,20 +15,68 @@ limitations under the License.
-->
<resources>
<string name="app_web_url" translatable="false">https://github.com/dennisguse/opentracks</string>
<string name="chart_x_axis_distance" translatable="false">DISTANCE</string>
<string name="chart_x_axis_time" translatable="false">TIME</string>
<!-- List here all used libraries (will be shown in the about activity -->
<string name="third_party_libraries" translatable="false"><a href="https://developer.android.com/topic/libraries/support-library/">Google\'s androidX support</a> (Apache License, Version 2.0)</string>
<string name="marker_statistics_icon_url" translatable="false">http://maps.google.com/mapfiles/ms/micons/ylw-pushpin.png</string>
<string name="marker_waypoint_icon_url" translatable="false">http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png</string>
<string name="sensor_type_value_none" translatable="false">NONE</string>
<string name="sensor_unit_beats_per_minute" translatable="false">BPM</string>
<string name="settings_recording_track_name_date_iso_8601_value" translatable="false">DATE_ISO_8601</string>
<string name="settings_recording_track_name_date_local_value" translatable="false">DATE_LOCAL</string>
<string name="settings_recording_track_name_number_value" translatable="false">NUMBER</string>
<string name="stats_rate_pace" translatable="false">PACE</string>
<string name="stats_rate_speed" translatable="false">SPEED</string>
<string name="stats_units_imperial" translatable="false">IMPERIAL</string>
<string name="stats_units_metric" translatable="false">METRIC</string>
<string name="value_unknown" translatable="false">-</string>
<string-array name="waypoint_types">
<item>@string/waypoint_type_atm</item>
<item>@string/waypoint_type_bank</item>
<item>@string/waypoint_type_bar</item>
<item>@string/waypoint_type_barbecue</item>
<item>@string/waypoint_type_building</item>
<item>@string/waypoint_type_bus_stop</item>
<item>@string/waypoint_type_cafe</item>
<item>@string/waypoint_type_campfire</item>
<item>@string/waypoint_type_campground</item>
<item>@string/waypoint_type_church</item>
<item>@string/waypoint_type_coffee_house</item>
<item>@string/waypoint_type_convenience_store</item>
<item>@string/waypoint_type_drinking_water</item>
<item>@string/waypoint_type_falling_rocks</item>
<item>@string/waypoint_type_ferry</item>
<item>@string/waypoint_type_fire_place</item>
<item>@string/waypoint_type_fire_station</item>
<item>@string/waypoint_type_fishing</item>
<item>@string/waypoint_type_gas_station</item>
<item>@string/waypoint_type_golf_course</item>
<item>@string/waypoint_type_grocery_store</item>
<item>@string/waypoint_type_hair_dresser</item>
<item>@string/waypoint_type_harbor</item>
<item>@string/waypoint_type_hiking_path</item>
<item>@string/waypoint_type_hotel</item>
<item>@string/waypoint_type_house</item>
<item>@string/waypoint_type_information</item>
<item>@string/waypoint_type_intersection</item>
<item>@string/waypoint_type_mail_box</item>
<item>@string/waypoint_type_market</item>
<item>@string/waypoint_type_meeting_point</item>
<item>@string/waypoint_type_opera</item>
<item>@string/waypoint_type_parking</item>
<item>@string/waypoint_type_police_station</item>
<item>@string/waypoint_type_post_office</item>
<item>@string/waypoint_type_pothole</item>
<item>@string/waypoint_type_railway_crossing</item>
<item>@string/waypoint_type_restaurant</item>
<item>@string/waypoint_type_shopping</item>
<item>@string/waypoint_type_sight</item>
<item>@string/waypoint_type_store</item>
<item>@string/waypoint_type_swimming_pool</item>
<item>@string/waypoint_type_telephone</item>
<item>@string/waypoint_type_theater</item>
<item>@string/waypoint_type_toilet</item>
<item>@string/waypoint_type_tourist_information</item>
<item>@string/waypoint_type_tree</item>
<item>@string/waypoint_type_tunnel</item>
<item>@string/waypoint_type_waterfall</item>
<item>@string/waypoint_type_water_fountain</item>
<item>@string/waypoint_type_waypoint</item>
</string-array>
</resources>
-49
View File
@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Keys for persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
<string name="auto_resume_track_timeout_key" translatable="false">autoResumeTrackTimeout</string>
<string name="chart_show_cadence_key" translatable="false">chartShowCadence</string>
<string name="chart_show_elevation_key" translatable="false">chartShowElevation</string>
<string name="chart_show_heart_rate_key" translatable="false">chartShowHeartRate</string>
<string name="chart_show_power_key" translatable="false">chartShowPower</string>
<string name="chart_show_speed_key" translatable="false">chartShowSpeed</string>
<string name="chart_x_axis_key" translatable="false">chartXAxis</string>
<string name="default_activity_key" translatable="false">defaultActivity</string>
<string name="max_recording_distance_key" translatable="false">maxRecordingDistance</string>
<string name="min_recording_interval_key" translatable="false">minRecordingInterval</string>
<string name="recording_distance_interval_key" translatable="false">recordingDistanceInterval</string>
<string name="recording_gps_accuracy_key" translatable="false">recordingGpsAccuracy</string>
<string name="split_frequency_key" translatable="false">splitFrequency</string>
<string name="stats_rate_key" translatable="false">statsRate</string>
<string name="stats_show_coordinate_key" translatable="false">statsShowCoordinate</string>
<string name="stats_show_grade_elevation_key" translatable="false">statsShowGradeElevation</string>
<string name="stats_units_key" translatable="false">statsUnits</string>
<string name="trackdetail_show_on_lockscreen_while_recording_key" translatable="false">trackdetail_show_on_lockscreen_while_recording</string>
<string name="track_name_key" translatable="false">trackName</string>
<string name="voice_frequency_key" translatable="false">voiceFrequency</string>
<!-- Keys for persistend preferences. But they should not get backed up or restored. -->
<string name="auto_resume_track_current_retry_key" translatable="false">autoResumeTrackCurrentRetry</string>
<string name="bluetooth_sensor_key" translatable="false">bluetoothSensor</string>
<string name="recording_track_id_key" translatable="false">recordingTrackId</string>
<string name="recording_track_paused_key" translatable="false">recordingTrackPaused</string>
<!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
<string name="settings_recording_key" translatable="false">settingsRecording</string>
<string name="settings_reset_key" translatable="false">settingsReset</string>
<string name="settings_sensor_bluetooth_pairing_key" translatable="false">settingsSensorBluetoothPairing</string>
<string name="settings_stats_key" translatable="false">settingsStats</string>
</resources>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Keys for persisted preferences that are used by internally. -->
<!--But they should not get backed up or restored.-->
<string name="auto_resume_track_current_retry_key" translatable="false">autoResumeTrackCurrentRetry</string>
<string name="recording_track_id_key" translatable="false">recordingTrackId</string>
<string name="recording_track_paused_key" translatable="false">recordingTrackPaused</string>
</resources>
@@ -1,20 +1,23 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Do not translate any arrays in this file. -->
<!-- Do not translate anything in this file directly. -->
<string name="chart_show_cadence_key" translatable="false">chartShowCadence</string>
<string name="chart_show_elevation_key" translatable="false">chartShowElevation</string>
<string name="chart_show_heart_rate_key" translatable="false">chartShowHeartRate</string>
<string name="chart_show_power_key" translatable="false">chartShowPower</string>
<string name="chart_show_speed_key" translatable="false">chartShowSpeed</string>
<string name="stats_show_coordinate_key" translatable="false">statsShowCoordinate</string>
<string name="stats_show_grade_elevation_key" translatable="false">statsShowGradeElevation</string>
<string name="stats_show_on_lockscreen_while_recording_key" translatable="false">trackdetail_show_on_lockscreen_while_recording</string>
<string name="settings_reset_key" translatable="false">settingsReset</string>
<string name="settings_sensor_bluetooth_sensor_key" translatable="false">bluetoothSensor</string>
<string name="settings_sensor_bluetooth_pairing_key" translatable="false">settingsSensorBluetoothPairing</string>
<string name="sensor_type_value_none" translatable="false">NONE</string>
<string name="default_activity_key" translatable="false">defaultActivity</string>
<string-array name="activity_types">
<item>@string/activity_type_airplane</item>
<item>@string/activity_type_atv</item>
@@ -83,6 +86,8 @@ limitations under the License.
<item>@string/activity_type_water_skiing</item>
<item>@string/activity_type_wind_surfing</item>
</string-array>
<string name="auto_resume_track_timeout_key" translatable="false">autoResumeTrackTimeout</string>
<string-array name="auto_resume_track_timeout_values">
<item>0</item>
<item>5</item>
@@ -90,14 +95,21 @@ limitations under the License.
<item>15</item>
<item>-1</item>
</string-array>
<string-array name="chart_x_axis_options">
<item>@string/settings_chart_by_distance</item>
<item>@string/settings_chart_by_time</item>
</string-array>
<string name="chart_x_axis_key" translatable="false">chartXAxis</string>
<string-array name="chart_x_axis_values">
<item>@string/chart_x_axis_distance</item>
<item>@string/chart_x_axis_time</item>
</string-array>
<string name="chart_x_axis_time" translatable="false">TIME</string>
<string name="chart_x_axis_distance" translatable="false">DISTANCE</string>
<string-array name="chart_x_axis_options">
<item>@string/settings_chart_by_distance</item>
<item>@string/settings_chart_by_time</item>
</string-array>
<string name="split_frequency_key" translatable="false">splitFrequency</string>
<string name="voice_frequency_key" translatable="false">voiceFrequency</string>
<string-array name="frequency_values">
<item>0</item>
<item>1</item>
@@ -114,6 +126,19 @@ limitations under the License.
<item>-50</item>
<item>-100</item>
</string-array>
<string name="recording_distance_interval_key" translatable="false">recordingDistanceInterval</string>
<string-array name="recording_distance_interval_values">
<item>1</item>
<item>2</item>
<item>5</item>
<item>10</item>
<item>20</item>
<item>50</item>
<item>100</item>
</string-array>
<string name="max_recording_distance_key" translatable="false">maxRecordingDistance</string>
<string-array name="max_recording_distance_values">
<item>50</item>
<item>100</item>
@@ -122,6 +147,8 @@ limitations under the License.
<item>1000</item>
<item>5000</item>
</string-array>
<string name="min_recording_interval_key" translatable="false">minRecordingInterval</string>
<string-array name="min_recording_interval_values">
<item>-2</item>
<item>-1</item>
@@ -140,15 +167,8 @@ limitations under the License.
<item>900</item>
<item>1800</item>
</string-array>
<string-array name="recording_distance_interval_values">
<item>1</item>
<item>2</item>
<item>5</item>
<item>10</item>
<item>20</item>
<item>50</item>
<item>100</item>
</string-array>
<string name="recording_gps_accuracy_key" translatable="false">recordingGpsAccuracy</string>
<string-array name="recording_gps_accuracy_values">
<item>10</item>
<item>20</item>
@@ -160,6 +180,8 @@ limitations under the License.
<item>1000</item>
<item>2000</item>
</string-array>
<string name="stats_rate_key" translatable="false">statsRate</string>
<string-array name="stats_rate_imperial_options">
<item>@string/description_speed_imperial</item>
<item>@string/description_pace_imperial</item>
@@ -168,79 +190,38 @@ limitations under the License.
<item>@string/description_speed_metric</item>
<item>@string/description_pace_metric</item>
</string-array>
<string name="stats_rate_pace" translatable="false">PACE</string>
<string name="stats_rate_speed" translatable="false">SPEED</string>
<string-array name="stats_rate_values">
<item>@string/stats_rate_speed</item>
<item>@string/stats_rate_pace</item>
</string-array>
<string name="stats_units_key" translatable="false">statsUnits</string>
<string-array name="stats_units_values">
<item>@string/stats_units_metric</item>
<item>@string/stats_units_imperial</item>
</string-array>
<string name="stats_units_metric" translatable="false">METRIC</string>
<string name="stats_units_imperial" translatable="false">IMPERIAL</string>
<string-array name="stats_units_options">
<item>@string/settings_stats_units_metric</item>
<item>@string/settings_stats_units_imperial</item>
</string-array>
<string-array name="stats_units_values">
<item>@string/stats_units_metric</item>
<item>@string/stats_units_imperial</item>
<string name="track_name_key" translatable="false">trackName</string>
<string name="settings_recording_track_name_date_iso_8601_value" translatable="false">DATE_ISO_8601</string>
<string name="settings_recording_track_name_date_local_value" translatable="false">DATE_LOCAL</string>
<string name="settings_recording_track_name_number_value" translatable="false">NUMBER</string>
<string-array name="track_name_values">
<item>@string/settings_recording_track_name_date_local_value</item>
<item>@string/settings_recording_track_name_date_iso_8601_value</item>
<item>@string/settings_recording_track_name_number_value</item>
</string-array>
<string-array name="track_name_options">
<item>@string/settings_recording_track_name_date_local_option</item>
<item>@string/settings_recording_track_name_date_iso_8601_option</item>
<item>@string/settings_recording_track_name_number_option</item>
</string-array>
<string-array name="track_name_values">
<item>@string/settings_recording_track_name_date_local_value</item>
<item>@string/settings_recording_track_name_date_iso_8601_value</item>
<item>@string/settings_recording_track_name_number_value</item>
</string-array>
<string-array name="waypoint_types">
<item>@string/waypoint_type_atm</item>
<item>@string/waypoint_type_bank</item>
<item>@string/waypoint_type_bar</item>
<item>@string/waypoint_type_barbecue</item>
<item>@string/waypoint_type_building</item>
<item>@string/waypoint_type_bus_stop</item>
<item>@string/waypoint_type_cafe</item>
<item>@string/waypoint_type_campfire</item>
<item>@string/waypoint_type_campground</item>
<item>@string/waypoint_type_church</item>
<item>@string/waypoint_type_coffee_house</item>
<item>@string/waypoint_type_convenience_store</item>
<item>@string/waypoint_type_drinking_water</item>
<item>@string/waypoint_type_falling_rocks</item>
<item>@string/waypoint_type_ferry</item>
<item>@string/waypoint_type_fire_place</item>
<item>@string/waypoint_type_fire_station</item>
<item>@string/waypoint_type_fishing</item>
<item>@string/waypoint_type_gas_station</item>
<item>@string/waypoint_type_golf_course</item>
<item>@string/waypoint_type_grocery_store</item>
<item>@string/waypoint_type_hair_dresser</item>
<item>@string/waypoint_type_harbor</item>
<item>@string/waypoint_type_hiking_path</item>
<item>@string/waypoint_type_hotel</item>
<item>@string/waypoint_type_house</item>
<item>@string/waypoint_type_information</item>
<item>@string/waypoint_type_intersection</item>
<item>@string/waypoint_type_mail_box</item>
<item>@string/waypoint_type_market</item>
<item>@string/waypoint_type_meeting_point</item>
<item>@string/waypoint_type_opera</item>
<item>@string/waypoint_type_parking</item>
<item>@string/waypoint_type_police_station</item>
<item>@string/waypoint_type_post_office</item>
<item>@string/waypoint_type_pothole</item>
<item>@string/waypoint_type_railway_crossing</item>
<item>@string/waypoint_type_restaurant</item>
<item>@string/waypoint_type_shopping</item>
<item>@string/waypoint_type_sight</item>
<item>@string/waypoint_type_store</item>
<item>@string/waypoint_type_swimming_pool</item>
<item>@string/waypoint_type_telephone</item>
<item>@string/waypoint_type_theater</item>
<item>@string/waypoint_type_toilet</item>
<item>@string/waypoint_type_tourist_information</item>
<item>@string/waypoint_type_tree</item>
<item>@string/waypoint_type_tunnel</item>
<item>@string/waypoint_type_waterfall</item>
<item>@string/waypoint_type_water_fountain</item>
<item>@string/waypoint_type_waypoint</item>
</string-array>
</resources>
+2 -2
View File
@@ -69,7 +69,7 @@ limitations under the License.
<PreferenceCategory android:title="@string/settings_recording">
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/trackdetail_show_on_lockscreen_while_recording_key"
android:key="@string/stats_show_on_lockscreen_while_recording_key"
android:summary="@string/settings_recording_show_on_lockscreen_while_recording_summary"
android:title="@string/settings_recording_show_on_lockscreen_while_recording_title" />
<ListPreference
@@ -132,7 +132,7 @@ limitations under the License.
android:title="@string/settings_sensor">
<ListPreference
android:defaultValue="@string/sensor_type_value_none"
android:key="@string/bluetooth_sensor_key"
android:key="@string/settings_sensor_bluetooth_sensor_key"
android:summary="%s"
android:title="@string/settings_sensor_bluetooth_sensor" />
<Preference