Integrated ChartSettingsActivity in SettingsActivity.

This commit is contained in:
Dennis Guse
2019-08-06 19:52:18 +02:00
parent 1028e09888
commit fda95bbec9
6 changed files with 45 additions and 114 deletions
-1
View File
@@ -129,7 +129,6 @@ limitations under the License.
android:value=".SearchListActivity" />
</activity>
<activity android:name=".io.file.exporter.SaveActivity" />
<activity android:name=".settings.ChartSettingsActivity" />
<activity android:name=".settings.RecordingSettingsActivity" />
<activity android:name=".settings.SensorSettingsActivity" />
<activity android:name=".settings.SettingsActivity" />
@@ -1,51 +0,0 @@
/*
* Copyright 2012 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.
*/
package de.dennisguse.opentracks.settings;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import de.dennisguse.opentracks.util.PreferencesUtils;
import de.dennisguse.opentracks.R;
/**
* An activity for accessing chart settings.
*
* @author Jimmy Shih
*/
public class ChartSettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.settings_chart);
}
@Override
protected void onResume() {
super.onResume();
updateUi();
}
private void updateUi() {
CheckBoxPreference speedCheckBoxPreference = (CheckBoxPreference) findPreference(getString(R.string.chart_show_speed_key));
speedCheckBoxPreference.setTitle(PreferencesUtils.isReportSpeed(this) ? R.string.stats_speed : R.string.stats_pace);
}
}
@@ -45,13 +45,15 @@ public class SettingsActivity extends PreferenceActivity {
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (key != null && key.equals(PreferencesUtils.getKey(SettingsActivity.this, R.string.recording_track_id_key))) {
recordingTrackId = PreferencesUtils.getLong(SettingsActivity.this, R.string.recording_track_id_key);
runOnUiThread(new Runnable() {
@Override
public void run() {
updateUI();
}
});
}
//TODO Should only be called if something meaningful happens.
runOnUiThread(new Runnable() {
@Override
public void run() {
updateUI();
}
});
}
};
@@ -61,7 +63,6 @@ public class SettingsActivity extends PreferenceActivity {
addPreferencesFromResource(R.xml.settings);
configPreference(R.string.settings_chart_key, ChartSettingsActivity.class);
configPreference(R.string.settings_stats_key, StatsSettingsActivity.class);
configPreference(R.string.settings_recording_key, RecordingSettingsActivity.class);
configPreference(R.string.settings_sensor_key, SensorSettingsActivity.class);
@@ -103,7 +104,10 @@ public class SettingsActivity extends PreferenceActivity {
//TODO Remove the following if recordingTrackId is replaced by direct communication rather than via preferences.
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
Preference resetPreference = findPreference(getString(R.string.settings_reset_key));
resetPreference.setEnabled(!isRecording);
resetPreference.setSummary(isRecording ? getString(R.string.settings_not_while_recording) : "");
resetPreference.setEnabled(!isRecording);
Preference speedCheckBoxPreference = findPreference(getString(R.string.chart_show_speed_key));
speedCheckBoxPreference.setTitle(PreferencesUtils.isReportSpeed(this) ? R.string.stats_speed : R.string.stats_pace);
}
}
@@ -250,7 +250,6 @@ public class PreferencesUtils {
public static void resetPreferences(Context context, boolean readAgain) {
PreferenceManager.setDefaultValues(context, R.xml.settings, readAgain);
PreferenceManager.setDefaultValues(context, R.xml.settings_chart, readAgain);
PreferenceManager.setDefaultValues(context, R.xml.settings_recording, readAgain);
PreferenceManager.setDefaultValues(context, R.xml.settings_sensors, readAgain);
PreferenceManager.setDefaultValues(context, R.xml.settings_statistics, readAgain);
+33 -4
View File
@@ -15,10 +15,39 @@ limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/menu_settings">
<Preference
android:key="@string/settings_chart_key"
android:persistent="false"
android:title="@string/track_detail_chart_tab" />
<PreferenceScreen android:title="@string/track_detail_chart_tab">
<ListPreference
android:defaultValue="@string/chart_x_axis_distance"
android:key="@string/chart_x_axis_key"
android:summary="%s"
android:entryValues="@array/chart_x_axis_values"
android:entries="@array/chart_x_axis_options"
android:title="@string/settings_chart_x_axis" />
<PreferenceCategory android:title="@string/settings_show">
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_elevation_key"
android:title="@string/stats_elevation" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_speed_key" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_heart_rate_key"
android:title="@string/sensor_state_heart_rate" />
<!--
TODO: Sensors are not implemented.
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_cadence_key"
android:title="@string/sensor_state_cadence" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_power_key"
android:title="@string/sensor_state_power" />
-->
</PreferenceCategory>
</PreferenceScreen>
<Preference
android:key="@string/settings_stats_key"
android:persistent="false"
-49
View File
@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2012 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/track_detail_chart_tab">
<ListPreference
android:defaultValue="@string/chart_x_axis_distance"
android:key="@string/chart_x_axis_key"
android:summary="%s"
android:entryValues="@array/chart_x_axis_values"
android:entries="@array/chart_x_axis_options"
android:title="@string/settings_chart_x_axis" />
<PreferenceCategory android:title="@string/settings_show">
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_elevation_key"
android:title="@string/stats_elevation" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_speed_key" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_heart_rate_key"
android:title="@string/sensor_state_heart_rate" />
<!--
TODO: Sensors are not implemented.
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_cadence_key"
android:title="@string/sensor_state_cadence" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/chart_show_power_key"
android:title="@string/sensor_state_power" />
-->
</PreferenceCategory>
</PreferenceScreen>