Merge Autofill settings into Account settings.

Autofill settings are removed from Language and Input.

They are now in a new top-level Passwords and Accounts page.

Some polish work is left to match the new design.

Bug: 169455298
Test: manual - check settings page and some search keywords
Test: manual - add work profile and check the above again
Test: make RunSettingsRoboTests
Change-Id: I3981ce73fef63f06a40e61e894481d24284614ba
This commit is contained in:
Ahaan Ugale
2021-03-22 19:00:06 -07:00
parent 2160d5fc4c
commit 9b183778f2
12 changed files with 169 additions and 191 deletions

View File

@@ -7764,8 +7764,8 @@
<string name="app_and_notification_dashboard_summary">Recent apps, default apps</string>
<!-- Toast shown when an app in the work profile attempts to open notification settings. The apps in the work profile cannot access notification settings. [CHAR LIMIT=NONE] -->
<string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
<!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
<string name="account_dashboard_title">Accounts</string>
<!-- Title for setting tile leading to saved autofill passwords, autofill , and account settings [CHAR LIMIT=40]-->
<string name="account_dashboard_title">Passwords and accounts</string>
<!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
<string name="account_dashboard_default_summary">No accounts added</string>
<!-- Title for setting tile leading to setting UI which allows user set default app to

View File

@@ -21,15 +21,39 @@
android:title="@string/account_dashboard_title"
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
android:key="passwords_category"
android:order="10"
android:persistent="false"
android:title="@string/autofill_passwords"
settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
settings:keywords="@string/autofill_keywords" />
<PreferenceCategory
android:key="default_service_category"
android:order="20"
android:title="@string/autofill_app">
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
android:value="false" />
</com.android.settings.widget.GearPreference>
</PreferenceCategory>
<PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="30"/>
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="102"
android:order="202"
settings:allowDividerAbove="true"/>
<SwitchPreference
@@ -37,12 +61,12 @@
android:title="@string/account_settings_menu_auto_sync_work"
android:summary="@string/auto_sync_account_summary"
settings:forWork="true"
android:order="103"/>
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="104"/>
android:order="204"/>
</PreferenceScreen>

View File

@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="30"/>
android:key="passwords_category"
android:order="10"
android:persistent="false"
android:title="@string/autofill_passwords"
settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
settings:keywords="@string/autofill_keywords" />
<SwitchPreference
android:key="auto_sync_account_data"
android:title="@string/auto_sync_account_title"
android:summary="@string/auto_sync_account_summary"
<PreferenceCategory
android:key="default_service_category"
android:order="20"
android:title="@string/autofill_app">
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
android:value="false" />
</com.android.settings.widget.GearPreference>
</PreferenceCategory>
<PreferenceCategory
android:key="accounts_category"
android:order="100"
settings:allowDividerAbove="true"/>
android:title="@string/account_settings">
<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="110"/>
<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_personal_account_data"
android:title="@string/account_settings_menu_auto_sync_personal"
android:summary="@string/auto_sync_account_summary"
android:order="210"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="30"/>
android:key="passwords_category"
android:order="10"
android:persistent="false"
android:title="@string/autofill_passwords"
settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
settings:keywords="@string/autofill_keywords" />
<SwitchPreference
android:key="auto_sync_account_data"
android:title="@string/auto_sync_account_title"
android:summary="@string/auto_sync_account_summary"
<com.android.settings.widget.WorkOnlyCategory
android:key="autofill_work_app_defaults"
android:order="30"
android:title="@string/default_for_work">
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_work"
android:title="@string/autofill_app"
settings:searchable="false">
<extra
android:name="for_work"
android:value="true" />
</com.android.settings.widget.GearPreference>
</com.android.settings.widget.WorkOnlyCategory>
<PreferenceCategory
android:key="accounts_category"
android:order="100"
settings:allowDividerAbove="true"/>
android:title="@string/account_settings">
<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="110"/>
<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_work_account_data"
android:title="@string/account_settings_menu_auto_sync_work"
android:summary="@string/auto_sync_account_summary"
android:order="210"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="default_autofill_picker"
android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<PreferenceCategory
android:key="passwords_category"
android:persistent="false"
android:title="@string/autofill_passwords"
settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController" >
</PreferenceCategory>
<PreferenceCategory
android:key="default_service_category"
android:title="@string/autofill_app">
<!-- TODO(b/169455298): Fix the redundant title. -->
<com.android.settings.widget.GearPreference
android:key="default_autofill_main"
android:title="@string/autofill_app"
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
settings:searchable="false"
settings:keywords="@string/autofill_keywords">
<extra android:name="for_work" android:value="false" />
</com.android.settings.widget.GearPreference>
</PreferenceCategory>
<com.android.settings.widget.WorkOnlyCategory
android:key="autofill_work_app_defaults"
android:title="@string/default_for_work">
<com.android.settings.widget.GearPreference
android:key="default_autofill_work"
android:title="@string/autofill_app"
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
settings:searchable="false"
settings:keywords="@string/autofill_keywords">
<extra android:name="for_work" android:value="true" />
</com.android.settings.widget.GearPreference>
</com.android.settings.widget.WorkOnlyCategory>
</PreferenceScreen>

View File

@@ -54,12 +54,6 @@
android:persistent="false"
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
<Preference
android:key="default_autofill"
android:title="@string/autofill_app"
android:fragment="com.android.settings.applications.defaultapps.AutofillPicker"
settings:keywords="@string/autofill_keywords" />
<!-- User dictionary preference title and fragment will be set programmatically. -->
<Preference
android:key="key_user_dictionary_settings"

View File

@@ -27,6 +27,8 @@ import android.os.UserManager;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -68,14 +70,22 @@ public class AccountDashboardFragment extends DashboardFragment {
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
return buildPreferenceControllers(context, this /* parent */, authorities);
buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
return controllers;
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
SettingsPreferenceFragment parent, String[] authorities) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
static void buildAutofillPreferenceControllers(
Context context, List<AbstractPreferenceController> controllers) {
controllers.add(new DefaultAutofillPreferenceController(context));
controllers.add(new DefaultWorkAutofillPreferenceController(context));
}
private static void buildAccountPreferenceControllers(
Context context, SettingsPreferenceFragment parent, String[] authorities,
List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.ALL);
@@ -86,7 +96,6 @@ public class AccountDashboardFragment extends DashboardFragment {
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
return controllers;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -95,8 +104,11 @@ public class AccountDashboardFragment extends DashboardFragment {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
return buildPreferenceControllers(
context, null /* parent */, null /* authorities*/);
final List<AbstractPreferenceController> controllers = new ArrayList<>();
buildAccountPreferenceControllers(
context, null /* parent */, null /* authorities*/, controllers);
buildAutofillPreferenceControllers(context, controllers);
return controllers;
}
@Override

View File

@@ -18,6 +18,8 @@ package com.android.settings.accounts;
import static android.provider.Settings.EXTRA_AUTHORITIES;
import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
return buildPreferenceControllers(context, this /* parent */, authorities);
buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
return controllers;
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
SettingsPreferenceFragment parent, String[] authorities) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
private static void buildAccountPreferenceControllers(
Context context, SettingsPreferenceFragment parent, String[] authorities,
List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.PERSONAL);
@@ -78,7 +82,6 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@ public class AccountPersonalDashboardFragment extends DashboardFragment {
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }

View File

@@ -75,11 +75,12 @@ public class AccountPreferenceController extends AbstractPreferenceController
private static final String TAG = "AccountPrefController";
private static final int ORDER_ACCOUNT_PROFILES = 1;
private static final int ORDER_ACCOUNT_PROFILES = 101;
private static final int ORDER_LAST = 1002;
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";
@@ -348,8 +349,10 @@ public class AccountPreferenceController extends AbstractPreferenceController
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
if (screen != null) {
screen.addPreference(preferenceGroup);
final PreferenceGroup accounts =
screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
if (accounts != null) {
accounts.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {

View File

@@ -18,6 +18,8 @@ package com.android.settings.accounts;
import static android.provider.Settings.EXTRA_AUTHORITIES;
import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
return buildPreferenceControllers(context, this /* parent */, authorities);
buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
return controllers;
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
SettingsPreferenceFragment parent, String[] authorities) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
private static void buildAccountPreferenceControllers(
Context context, SettingsPreferenceFragment parent, String[] authorities,
List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.WORK);
@@ -78,7 +82,6 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }

View File

@@ -1,72 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.applications.defaultapps;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
import java.util.Arrays;
import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class AutofillPicker extends DashboardFragment {
private static final String TAG = "AutofillPicker";
@Override
public int getMetricsCategory() {
return SettingsEnums.DEFAULT_AUTOFILL_PICKER;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.default_autofill_picker_settings;
}
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
return buildPreferenceControllers(context);
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.default_autofill_picker_settings) {
@Override
public List<AbstractPreferenceController> getPreferenceControllers(Context
context) {
return buildPreferenceControllers(context);
}
};
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
return Arrays.asList(
new DefaultAutofillPreferenceController(context),
new DefaultWorkAutofillPreferenceController(context));
}
}

View File

@@ -39,6 +39,7 @@ 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;
@@ -72,9 +73,13 @@ 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;
@@ -95,6 +100,9 @@ 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]);
@@ -166,6 +174,7 @@ 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));
@@ -184,6 +193,7 @@ 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));