forked from upstream-mirrors/OpenTracks
PreferenceList: let summary be set by Android.
Some preferences used customized summaries - these were also removed.
This commit is contained in:
@@ -66,50 +66,29 @@ public class AbstractSettingsActivity extends PreferenceActivity {
|
||||
* Configures a list preference.
|
||||
*
|
||||
* @param listPreference the list preference
|
||||
* @param summary the summary array
|
||||
* @param options the options array
|
||||
* @param values the values array
|
||||
* @param value the value
|
||||
* @param listener optional listener
|
||||
*/
|
||||
protected void configureListPreference(ListPreference listPreference, final String[] summary,
|
||||
final String[] options, final String[] values, String value,
|
||||
protected void configureListPreference(ListPreference listPreference, final String[] options, final String[] values, String value,
|
||||
final OnPreferenceChangeListener listener) {
|
||||
listPreference.setEntryValues(values);
|
||||
listPreference.setEntries(options);
|
||||
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference pref, Object newValue) {
|
||||
updatePreferenceSummary(pref, summary, values, (String) newValue);
|
||||
if (listener != null) {
|
||||
listener.onPreferenceChange(pref, newValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
updatePreferenceSummary(listPreference, summary, values, value);
|
||||
if (listener != null) {
|
||||
listener.onPreferenceChange(listPreference, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the preference summary.
|
||||
*
|
||||
* @param preference the preference
|
||||
* @param summary the summary array
|
||||
* @param values the values array
|
||||
* @param value the value
|
||||
*/
|
||||
private void updatePreferenceSummary(Preference preference, String[] summary, String[] values, String value) {
|
||||
int index = getIndex(values, value);
|
||||
if (index == -1) {
|
||||
preference.setSummary(R.string.value_unknown);
|
||||
} else {
|
||||
preference.setSummary(summary[index]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array index for a value.
|
||||
*
|
||||
|
||||
@@ -60,6 +60,6 @@ public class ChartSettingsActivity extends AbstractSettingsActivity {
|
||||
this, R.string.chart_x_axis_key, PreferencesUtils.CHART_X_AXIS_DEFAULT);
|
||||
String[] values = getResources().getStringArray(R.array.chart_x_axis_values);
|
||||
String[] options = getResources().getStringArray(R.array.chart_x_axis_options);
|
||||
configureListPreference(listPreference, options, options, values, value, null);
|
||||
configureListPreference(listPreference, options, values, value, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
|
||||
int value = PreferencesUtils.getInt(this, key, defaultValue);
|
||||
String[] values = getResources().getStringArray(valueArray);
|
||||
String[] options = StringUtils.getFrequencyOptions(this, metricUnits);
|
||||
configureListPreference(preference, options, options, values, String.valueOf(value), null);
|
||||
configureListPreference(preference, options, values, String.valueOf(value), null);
|
||||
}
|
||||
|
||||
private void configTrackName() {
|
||||
@@ -95,7 +95,7 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
|
||||
this, R.string.track_name_key, PreferencesUtils.TRACK_NAME_DEFAULT);
|
||||
String[] values = getResources().getStringArray(R.array.track_name_values);
|
||||
String[] options = getResources().getStringArray(R.array.track_name_options);
|
||||
configureListPreference(preference, options, options, values, value, null);
|
||||
configureListPreference(preference, options, values, value, null);
|
||||
}
|
||||
|
||||
private void configDefaultActivity() {
|
||||
@@ -146,7 +146,7 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
|
||||
default:
|
||||
return;
|
||||
}
|
||||
configureListPreference(preference, summary, options, values, String.valueOf(value), null);
|
||||
configureListPreference(preference, options, values, String.valueOf(value), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,8 +319,7 @@ public class RecordingSettingsActivity extends AbstractSettingsActivity
|
||||
* @param options the options
|
||||
* @param values the values
|
||||
*/
|
||||
private void setAutoResumeTrackTimeoutSummaryAndOptions(
|
||||
String[] summary, String[] options, String[] values) {
|
||||
private void setAutoResumeTrackTimeoutSummaryAndOptions(String[] summary, String[] options, String[] values) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
int value = Integer.parseInt(values[i]);
|
||||
switch (value) {
|
||||
|
||||
@@ -85,6 +85,6 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
|
||||
|
||||
String[] options = devicesNameList.toArray(new String[0]);
|
||||
String[] values = devicesAddressList.toArray(new String[0]);
|
||||
configureListPreference(preference, options, options, values, value, null);
|
||||
configureListPreference(preference, options, values, value, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
|
||||
this, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
|
||||
String[] values = getResources().getStringArray(R.array.stats_units_values);
|
||||
String[] options = getResources().getStringArray(R.array.stats_units_options);
|
||||
configureListPreference(listPreference, options, options, values, value, listener);
|
||||
configureListPreference(listPreference, options, values, value, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,6 +78,6 @@ public class StatsSettingsActivity extends AbstractSettingsActivity {
|
||||
String[] values = getResources().getStringArray(R.array.stats_rate_values);
|
||||
String[] options = getResources().getStringArray(
|
||||
metricUnits ? R.array.stats_rate_metric_options : R.array.stats_rate_imperial_options);
|
||||
configureListPreference(listPreference, options, options, values, value, null);
|
||||
configureListPreference(listPreference, options, values, value, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ limitations under the License.
|
||||
android:key="@string/settings_advanced_key"
|
||||
android:persistent="false"
|
||||
android:title="@string/settings_advanced" />
|
||||
<Preference
|
||||
android:title="@string/about_preference_title">
|
||||
<intent
|
||||
android:targetPackage="@string/applicationId"
|
||||
android:targetClass="de.dennisguse.opentracks.AboutActivity" />
|
||||
</Preference>
|
||||
<PreferenceCategory android:title="@string/about_preference_title">
|
||||
<Preference
|
||||
android:title="@string/about_preference_title">
|
||||
<intent
|
||||
android:targetPackage="@string/applicationId"
|
||||
android:targetClass="de.dennisguse.opentracks.AboutActivity" />
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -18,6 +18,7 @@ limitations under the License.
|
||||
<ListPreference
|
||||
android:defaultValue="@string/chart_x_axis_distance"
|
||||
android:key="@string/chart_x_axis_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_chart_x_axis" />
|
||||
<PreferenceCategory android:title="@string/settings_show">
|
||||
<CheckBoxPreference
|
||||
|
||||
@@ -18,37 +18,46 @@ limitations under the License.
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:key="@string/voice_frequency_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/menu_voice_frequency" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:key="@string/split_frequency_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/menu_split_frequency" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/settings_recording_track_name_date_iso_8601_value"
|
||||
android:key="@string/track_name_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_track_name_title" />
|
||||
<de.dennisguse.opentracks.settings.ActivityTypePreference
|
||||
android:defaultValue="@string/activity_type_running"
|
||||
android:key="@string/default_activity_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_default_activity_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:key="@string/min_recording_interval_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_min_recording_interval_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="10"
|
||||
android:key="@string/recording_distance_interval_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_min_recording_distance_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="200"
|
||||
android:key="@string/max_recording_distance_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_max_recording_distance_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="50"
|
||||
android:key="@string/recording_gps_accuracy_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_min_required_accuracy_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="10"
|
||||
android:key="@string/auto_resume_track_timeout_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_recording_auto_resume_track_timeout_title" />
|
||||
</PreferenceScreen>
|
||||
@@ -27,6 +27,7 @@ limitations under the License.
|
||||
<ListPreference
|
||||
android:defaultValue="@string/sensor_type_value_none"
|
||||
android:key="@string/bluetooth_sensor_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_sensor_bluetooth_sensor" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -18,10 +18,12 @@ limitations under the License.
|
||||
<ListPreference
|
||||
android:defaultValue="@string/stats_units_metric"
|
||||
android:key="@string/stats_units_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_stats_units_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/stats_rate_speed"
|
||||
android:key="@string/stats_rate_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_stats_rate_title" />
|
||||
<PreferenceCategory android:title="@string/settings_show">
|
||||
<CheckBoxPreference
|
||||
|
||||
Reference in New Issue
Block a user