Settings: Place and order Google & Digital Wellbeing

... in the same category as Security & privacy
... with an approach that can be reused for other keys in the future

Change-Id: I666ebd7f90c11f1836bac10f7fca38baa5aedf93
This commit is contained in:
Michael W 2024-11-11 21:16:46 +01:00 committed by Michael Bestas
parent e38f9c251d
commit d117f53b77
No known key found for this signature in database

View file

@ -82,14 +82,22 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
private static final long TIMEOUT_MILLIS = 50L;
private static final List<String> ACCOUNT_INJECTED_KEYS = Arrays.asList(
"dashboard_tile_pref_com.google.android.gms.backup.component.BackupOrRestoreSettingsActivity",
"top_level_google"
"dashboard_tile_pref_com.google.android.gms.backup.component.BackupOrRestoreSettingsActivity"
);
private static final List<String> SECURITY_PRIVACY_INJECTED_KEYS = Arrays.asList(
"top_level_wellbeing"
"top_level_wellbeing",
"top_level_google"
);
private static final ArrayMap<String, Integer> KEY_ORDER = new ArrayMap<>();
static {
// We have "Passwords, passkeys & accounts with order "-10" above
KEY_ORDER.put("top_level_wellbeing", -5);
KEY_ORDER.put("top_level_google", 0);
// We have "Safety & emergency with order "10" below
}
@VisibleForTesting
final ArrayMap<String, List<DynamicDataObserver>> mDashboardTilePrefKeys = new ArrayMap<>();
private final Map<Class, List<AbstractPreferenceController>> mPreferenceControllers =
@ -657,6 +665,10 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
} else if (SECURITY_PRIVACY_INJECTED_KEYS.contains(key)) {
group = screen.findPreference("top_level_security_privacy_category");
}
// Order the prefs within their respective category
if (KEY_ORDER.containsKey(key)) {
pref.setOrder(KEY_ORDER.get(key));
}
if (group instanceof PreferenceCategory) {
((PreferenceCategory) group).addPreference(pref);
} else {