Merge "Account settings: Fix duplicate title and extra padding." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
52f627f9ef
@@ -46,33 +46,27 @@
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="accounts_category"
|
||||
android:order="100"
|
||||
android:title="@string/account_settings">
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_account_data"
|
||||
android:title="@string/auto_sync_account_title"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="202"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_account_data"
|
||||
android:title="@string/auto_sync_account_title"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="202"
|
||||
settings:allowDividerAbove="true"/>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_work_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_work"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
settings:forWork="true"
|
||||
android:order="203"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_work_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_work"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
settings:forWork="true"
|
||||
android:order="203"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_personal_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="204"/>
|
||||
</PreferenceCategory>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_personal_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="204"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -47,26 +47,20 @@
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="accounts_category"
|
||||
android:order="100"
|
||||
android:title="@string/account_settings">
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_account_data"
|
||||
android:title="@string/auto_sync_account_title"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="200"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_account_data"
|
||||
android:title="@string/auto_sync_account_title"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="200"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_personal_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="210"/>
|
||||
</PreferenceCategory>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_personal_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_personal"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="210"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -33,7 +33,7 @@
|
||||
<com.android.settings.widget.WorkOnlyCategory
|
||||
android:key="autofill_work_app_defaults"
|
||||
android:order="30"
|
||||
android:title="@string/default_for_work">
|
||||
android:title="@string/autofill_app">
|
||||
|
||||
<com.android.settings.widget.GearPreference
|
||||
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
|
||||
@@ -47,26 +47,20 @@
|
||||
</com.android.settings.widget.WorkOnlyCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="accounts_category"
|
||||
android:order="100"
|
||||
android:title="@string/account_settings">
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="130"/>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_account_data"
|
||||
android:title="@string/auto_sync_account_title"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="200"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_account_data"
|
||||
android:title="@string/auto_sync_account_title"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="200"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_work_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_work"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="210"/>
|
||||
</PreferenceCategory>
|
||||
<SwitchPreference
|
||||
android:key="auto_sync_work_account_data"
|
||||
android:title="@string/account_settings_menu_auto_sync_work"
|
||||
android:summary="@string/auto_sync_account_summary"
|
||||
android:order="210"/>
|
||||
|
||||
</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_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()) {
|
||||
final String title = 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()) {
|
||||
|
@@ -39,7 +39,6 @@ import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -73,13 +72,9 @@ import java.util.List;
|
||||
ShadowSettingsLibUtils.class})
|
||||
public class AccountPreferenceControllerTest {
|
||||
|
||||
private static final String PREF_KEY_ACCOUNTS = "accounts_category";
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private PreferenceCategory mAccountsCategory;
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private UserManager mUserManager;
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private SettingsPreferenceFragment mFragment;
|
||||
@@ -100,9 +95,6 @@ public class AccountPreferenceControllerTest {
|
||||
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
|
||||
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(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
||||
.thenReturn(new AuthenticatorDescription[0]);
|
||||
@@ -174,7 +166,6 @@ public class AccountPreferenceControllerTest {
|
||||
// First time resume will build the UI
|
||||
mController.onResume();
|
||||
reset(mScreen);
|
||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
||||
|
||||
mController.onResume();
|
||||
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
|
||||
@@ -193,7 +184,6 @@ public class AccountPreferenceControllerTest {
|
||||
// add a new profile
|
||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
reset(mScreen);
|
||||
when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
|
||||
|
||||
mController.onResume();
|
||||
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));
|
||||
|
Reference in New Issue
Block a user