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:
@@ -45,11 +45,6 @@
|
|||||||
</com.android.settings.widget.GearPreference>
|
</com.android.settings.widget.GearPreference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="accounts_category"
|
|
||||||
android:order="100"
|
|
||||||
android:title="@string/account_settings">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="dashboard_tile_placeholder"
|
android:key="dashboard_tile_placeholder"
|
||||||
android:order="130"/>
|
android:order="130"/>
|
||||||
@@ -73,6 +68,5 @@
|
|||||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||||
android:summary="@string/auto_sync_account_summary"
|
android:summary="@string/auto_sync_account_summary"
|
||||||
android:order="204"/>
|
android:order="204"/>
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -46,11 +46,6 @@
|
|||||||
</com.android.settings.widget.GearPreference>
|
</com.android.settings.widget.GearPreference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="accounts_category"
|
|
||||||
android:order="100"
|
|
||||||
android:title="@string/account_settings">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="dashboard_tile_placeholder"
|
android:key="dashboard_tile_placeholder"
|
||||||
android:order="130"/>
|
android:order="130"/>
|
||||||
@@ -67,6 +62,5 @@
|
|||||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||||
android:summary="@string/auto_sync_account_summary"
|
android:summary="@string/auto_sync_account_summary"
|
||||||
android:order="210"/>
|
android:order="210"/>
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
<com.android.settings.widget.WorkOnlyCategory
|
<com.android.settings.widget.WorkOnlyCategory
|
||||||
android:key="autofill_work_app_defaults"
|
android:key="autofill_work_app_defaults"
|
||||||
android:order="30"
|
android:order="30"
|
||||||
android:title="@string/default_for_work">
|
android:title="@string/autofill_app">
|
||||||
|
|
||||||
<com.android.settings.widget.GearPreference
|
<com.android.settings.widget.GearPreference
|
||||||
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
|
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
|
||||||
@@ -46,11 +46,6 @@
|
|||||||
</com.android.settings.widget.GearPreference>
|
</com.android.settings.widget.GearPreference>
|
||||||
</com.android.settings.widget.WorkOnlyCategory>
|
</com.android.settings.widget.WorkOnlyCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="accounts_category"
|
|
||||||
android:order="100"
|
|
||||||
android:title="@string/account_settings">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="dashboard_tile_placeholder"
|
android:key="dashboard_tile_placeholder"
|
||||||
android:order="130"/>
|
android:order="130"/>
|
||||||
@@ -67,6 +62,5 @@
|
|||||||
android:title="@string/account_settings_menu_auto_sync_work"
|
android:title="@string/account_settings_menu_auto_sync_work"
|
||||||
android:summary="@string/auto_sync_account_summary"
|
android:summary="@string/auto_sync_account_summary"
|
||||||
android:order="210"/>
|
android:order="210"/>
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -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_LAST = 1001;
|
||||||
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
|
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_ADD_ACCOUNT = "add_account";
|
||||||
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
|
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
|
||||||
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
|
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
|
||||||
@@ -324,6 +323,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
|||||||
mHelper.createAccessiblePreferenceCategory(
|
mHelper.createAccessiblePreferenceCategory(
|
||||||
mFragment.getPreferenceManager().getContext());
|
mFragment.getPreferenceManager().getContext());
|
||||||
preferenceGroup.setOrder(mAccountProfileOrder++);
|
preferenceGroup.setOrder(mAccountProfileOrder++);
|
||||||
|
preferenceGroup.setTitle(R.string.account_settings); // default title; may be modified below
|
||||||
if (isSingleProfile()) {
|
if (isSingleProfile()) {
|
||||||
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
|
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
|
||||||
BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
|
BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
|
||||||
@@ -349,10 +349,8 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final PreferenceScreen screen = mFragment.getPreferenceScreen();
|
final PreferenceScreen screen = mFragment.getPreferenceScreen();
|
||||||
final PreferenceGroup accounts =
|
if (screen != null) {
|
||||||
screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
|
screen.addPreference(preferenceGroup);
|
||||||
if (accounts != null) {
|
|
||||||
accounts.addPreference(preferenceGroup);
|
|
||||||
}
|
}
|
||||||
profileData.preferenceGroup = preferenceGroup;
|
profileData.preferenceGroup = preferenceGroup;
|
||||||
if (userInfo.isEnabled()) {
|
if (userInfo.isEnabled()) {
|
||||||
|
@@ -39,7 +39,6 @@ import android.os.UserManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceCategory;
|
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
@@ -73,13 +72,9 @@ import java.util.List;
|
|||||||
ShadowSettingsLibUtils.class})
|
ShadowSettingsLibUtils.class})
|
||||||
public class AccountPreferenceControllerTest {
|
public class AccountPreferenceControllerTest {
|
||||||
|
|
||||||
private static final String PREF_KEY_ACCOUNTS = "accounts_category";
|
|
||||||
|
|
||||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||||
private PreferenceCategory mAccountsCategory;
|
|
||||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
|
||||||
private UserManager mUserManager;
|
private UserManager mUserManager;
|
||||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||||
private SettingsPreferenceFragment mFragment;
|
private SettingsPreferenceFragment mFragment;
|
||||||
@@ -100,9 +95,6 @@ public class AccountPreferenceControllerTest {
|
|||||||
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||||
|
|
||||||
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
||||||
// This is a bit ugly, but hard to avoid because of how the mocks are used in these tests.
|
|
||||||
// TODO: Refactor these tests to not use RETURNS_DEEP_STUBS.
|
|
||||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
|
||||||
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
||||||
.thenReturn(new AuthenticatorDescription[0]);
|
.thenReturn(new AuthenticatorDescription[0]);
|
||||||
@@ -174,7 +166,6 @@ public class AccountPreferenceControllerTest {
|
|||||||
// First time resume will build the UI
|
// First time resume will build the UI
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
reset(mScreen);
|
reset(mScreen);
|
||||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
|
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
|
||||||
@@ -193,7 +184,6 @@ public class AccountPreferenceControllerTest {
|
|||||||
// add a new profile
|
// add a new profile
|
||||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||||
reset(mScreen);
|
reset(mScreen);
|
||||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));
|
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));
|
||||||
|
Reference in New Issue
Block a user