Add PrefController in XML support
Add the ability to define a Preference Controller in xml using the 'controller' tag. This is useful for two reasons: - It allows the controllers to be instantiated via reflection for Slices and Dashboard fragment - Removes the requirement that controllers be defined manually in Fragments In order to be instantiable, they must have a unified construction following either: ClassName(Context) ClassName(Context, String) Also added a robotest that verifies that all controllers defined in XML follow the constructor schema, and extend BasePreferenceController. Test: robotests Bug: 67996923 Change-Id: I304b35dc666daebecf0c9e286696f3f2a510704a
This commit is contained in:
@@ -67,7 +67,7 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new SystemUpdatePreferenceController(context, UserManager.get(context)));
|
||||
controllers.add(new SystemUpdatePreferenceController(context));
|
||||
controllers.add(new AdditionalSystemUpdatePreferenceController(context));
|
||||
controllers.add(new BackupSettingsActivityPreferenceController(context));
|
||||
controllers.add(new GesturesSettingPreferenceController(context));
|
||||
@@ -88,17 +88,18 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
keys.add((new BackupSettingsActivityPreferenceController(context)
|
||||
.getPreferenceKey()));
|
||||
keys.add((new BackupSettingsActivityPreferenceController(
|
||||
context).getPreferenceKey()));
|
||||
keys.add(KEY_RESET);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user