2014-12-12 06:08:04 +00:00
|
|
|
package org.thoughtcrime.securesms.preferences;
|
|
|
|
|
2017-09-21 01:10:44 +00:00
|
|
|
|
2020-08-19 00:06:26 +00:00
|
|
|
import androidx.preference.ListPreference;
|
|
|
|
import androidx.preference.Preference;
|
2014-12-12 06:08:04 +00:00
|
|
|
|
2019-07-24 02:30:23 +00:00
|
|
|
import network.loki.messenger.R;
|
2014-12-12 06:08:04 +00:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
2017-04-15 03:39:38 +00:00
|
|
|
public abstract class ListSummaryPreferenceFragment extends CorrectedPreferenceFragment {
|
2014-12-12 06:08:04 +00:00
|
|
|
|
|
|
|
protected class ListSummaryListener implements Preference.OnPreferenceChangeListener {
|
|
|
|
@Override
|
|
|
|
public boolean onPreferenceChange(Preference preference, Object value) {
|
|
|
|
ListPreference listPref = (ListPreference) preference;
|
|
|
|
int entryIndex = Arrays.asList(listPref.getEntryValues()).indexOf(value);
|
|
|
|
|
|
|
|
listPref.setSummary(entryIndex >= 0 && entryIndex < listPref.getEntries().length
|
|
|
|
? listPref.getEntries()[entryIndex]
|
|
|
|
: getString(R.string.preferences__led_color_unknown));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void initializeListSummary(ListPreference pref) {
|
|
|
|
pref.setSummary(pref.getEntry());
|
|
|
|
}
|
|
|
|
}
|