Account settings: Fix duplicate title and extra padding.

This change reverts the change in
I3981ce73fef63f06a40e61e894481d24284614ba to add a PreferenceCategory
for the accounts after merging the page with autofill settings. That was
done to get the Accounts heading to display for the personal/work
profile view.
This change instead sets the title on the existing PreferenceCategory
that's created dynamically in the Controller.

Removing the extra PreferenceCategory also fixes the padding.

Fix: 183677515
Bug: 183677706
Test: manual - with single profile, with personal/work profiles
Test: make -j RunSettingsRoboTests \
 ROBOTEST_FILTER="com.android.settings.accounts.AccountPreferenceControllerTest"
Change-Id: Ib7fe6f97b93b81d5a5897280cdd6bbad1b75f3a9
This commit is contained in:
Ahaan Ugale
2021-05-10 11:22:53 -07:00
parent 899845b1ee
commit 6663bed71c
5 changed files with 49 additions and 79 deletions

View File

@@ -80,7 +80,6 @@ public class AccountPreferenceController extends AbstractPreferenceController
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
private static final String PREF_KEY_ACCOUNTS = "accounts_category";
private static final String PREF_KEY_ADD_ACCOUNT = "add_account";
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
@@ -324,6 +323,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
mHelper.createAccessiblePreferenceCategory(
mFragment.getPreferenceManager().getContext());
preferenceGroup.setOrder(mAccountProfileOrder++);
preferenceGroup.setTitle(R.string.account_settings); // default title; may be modified below
if (isSingleProfile()) {
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
@@ -349,10 +349,8 @@ public class AccountPreferenceController extends AbstractPreferenceController
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
final PreferenceGroup accounts =
screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
if (accounts != null) {
accounts.addPreference(preferenceGroup);
if (screen != null) {
screen.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {