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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user