Merge "Keep candidates in radio button picker UI ordered"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2611734af5
@@ -118,7 +118,7 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
|
String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting
|
||||||
public void updateCandidates() {
|
public void updateCandidates() {
|
||||||
mCandidates.clear();
|
mCandidates.clear();
|
||||||
final List<? extends CandidateInfo> candidateList = getCandidates();
|
final List<? extends CandidateInfo> candidateList = getCandidates();
|
||||||
@@ -139,16 +139,18 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
nonePref.setOnClickListener(this);
|
nonePref.setOnClickListener(this);
|
||||||
screen.addPreference(nonePref);
|
screen.addPreference(nonePref);
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, CandidateInfo> app : mCandidates.entrySet()) {
|
if (candidateList != null) {
|
||||||
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
for (CandidateInfo info : candidateList) {
|
||||||
bindPreference(pref, app.getKey(), app.getValue(), defaultKey);
|
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
||||||
bindPreferenceExtra(pref, app.getKey(), app.getValue(), defaultKey, systemDefaultKey);
|
bindPreference(pref, info.getKey(), info, defaultKey);
|
||||||
screen.addPreference(pref);
|
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
|
||||||
|
screen.addPreference(pref);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mayCheckOnlyRadioButton();
|
mayCheckOnlyRadioButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting
|
||||||
public RadioButtonPreference bindPreference(RadioButtonPreference pref,
|
public RadioButtonPreference bindPreference(RadioButtonPreference pref,
|
||||||
String key, CandidateInfo info, String defaultKey) {
|
String key, CandidateInfo info, String defaultKey) {
|
||||||
pref.setTitle(info.loadLabel());
|
pref.setTitle(info.loadLabel());
|
||||||
@@ -162,7 +164,7 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting
|
||||||
public void updateCheckedState(String selectedKey) {
|
public void updateCheckedState(String selectedKey) {
|
||||||
final PreferenceScreen screen = getPreferenceScreen();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
if (screen != null) {
|
if (screen != null) {
|
||||||
@@ -180,7 +182,7 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting
|
||||||
public void mayCheckOnlyRadioButton() {
|
public void mayCheckOnlyRadioButton() {
|
||||||
final PreferenceScreen screen = getPreferenceScreen();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
// If there is only 1 thing on screen, select it.
|
// If there is only 1 thing on screen, select it.
|
||||||
|
Reference in New Issue
Block a user