mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-11 10:44:21 +00:00
761049d6f8
1) shorten some summaries 2) add summaries to appearance subscreen 3) move common summary functions to common parent class // FREEBIE
30 lines
1.0 KiB
Java
30 lines
1.0 KiB
Java
package org.thoughtcrime.securesms.preferences;
|
|
|
|
import android.preference.ListPreference;
|
|
import android.preference.Preference;
|
|
import android.support.v4.preference.PreferenceFragment;
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
import java.util.Arrays;
|
|
|
|
public abstract class ListSummaryPreferenceFragment extends PreferenceFragment {
|
|
|
|
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());
|
|
}
|
|
}
|