mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-04 23:45:14 +00:00
30 lines
985 B
Java
30 lines
985 B
Java
package org.thoughtcrime.securesms.preferences;
|
|
|
|
|
|
import androidx.preference.ListPreference;
|
|
import androidx.preference.Preference;
|
|
|
|
import network.loki.messenger.R;
|
|
|
|
import java.util.Arrays;
|
|
|
|
public abstract class ListSummaryPreferenceFragment extends CorrectedPreferenceFragment {
|
|
|
|
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());
|
|
}
|
|
}
|