Update all preferences when the account preference updates UI
When an account is added or removed, the account preference controller just updates the account list, whereas there's no trigger point for the account data sync preferences to refresh. Add an API to update all preferences in DashboardFragment, so we can refresh the account sync preferences whenever the account list is updated. Bug: 185479221 Test: robotest, manual Change-Id: Ide3d972abae09ce0175e3bafbb1f4a5e307d20c8
This commit is contained in:
@@ -415,6 +415,30 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
updatePreferenceVisibility(mPreferenceControllers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force update all the preferences in this fragment.
|
||||
*/
|
||||
public void forceUpdatePreferences() {
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen == null || mPreferenceControllers == null) {
|
||||
return;
|
||||
}
|
||||
for (List<AbstractPreferenceController> controllerList : mPreferenceControllers.values()) {
|
||||
for (AbstractPreferenceController controller : controllerList) {
|
||||
final String key = controller.getPreferenceKey();
|
||||
final Preference preference = findPreference(key);
|
||||
if (preference == null) {
|
||||
continue;
|
||||
}
|
||||
final boolean available = controller.isAvailable();
|
||||
if (available) {
|
||||
controller.updateState(preference);
|
||||
}
|
||||
preference.setVisible(available);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updatePreferenceVisibility(
|
||||
Map<Class, List<AbstractPreferenceController>> preferenceControllers) {
|
||||
|
Reference in New Issue
Block a user