Modify clone profile accounts info section

This change renames clone profile accounts header on the account
management dashboard to "Clone" from "Personal" by using the newly added
clone category header config. This also includes changes to remove the
add account preference from the clone profile accounts.

Bug: 260181765
Test: Flashed on a sunfish device and tested

Change-Id: Iff8b75119d85d2cd8ab065ed1057fb2b35e64650
This commit is contained in:
Jigar Thakkar
2023-01-17 18:14:49 +00:00
parent d7bbff0041
commit 0e8b8ec57f
2 changed files with 47 additions and 17 deletions

View File

@@ -2268,6 +2268,8 @@
<string name="accessibility_category_work">Work profile accounts - <xliff:g id="managed_by" example="Managed by Corporate application">%s</xliff:g></string> <string name="accessibility_category_work">Work profile accounts - <xliff:g id="managed_by" example="Managed by Corporate application">%s</xliff:g></string>
<!-- Content description for personal profile accounts group [CHAR LIMIT=NONE] --> <!-- Content description for personal profile accounts group [CHAR LIMIT=NONE] -->
<string name="accessibility_category_personal">Personal profile accounts</string> <string name="accessibility_category_personal">Personal profile accounts</string>
<!-- Content description for personal clone accounts group [CHAR LIMIT=NONE] -->
<string name="accessibility_category_clone">Clone profile accounts</string>
<!-- Content description for work profile details page title [CHAR LIMIT=NONE] --> <!-- Content description for work profile details page title [CHAR LIMIT=NONE] -->
<string name="accessibility_work_account_title">Work account - <xliff:g id="managed_by" example="Email provider">%s</xliff:g></string> <string name="accessibility_work_account_title">Work account - <xliff:g id="managed_by" example="Email provider">%s</xliff:g></string>
<!-- Content description for personal profile details page title [CHAR LIMIT=NONE] --> <!-- Content description for personal profile details page title [CHAR LIMIT=NONE] -->

View File

@@ -16,8 +16,10 @@
package com.android.settings.accounts; package com.android.settings.accounts;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_CLONE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_PERSONAL; import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_PERSONAL;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_WORK; import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_WORK;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CLONE_CATEGORY_HEADER;
import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_BY; import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_BY;
import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_PROFILE_SETTINGS_TITLE; import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_PROFILE_SETTINGS_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER; import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER;
@@ -349,28 +351,34 @@ public class AccountPreferenceController extends AbstractPreferenceController
preferenceGroup.setContentDescription(title); preferenceGroup.setContentDescription(title);
} else if (userInfo.isManagedProfile()) { } else if (userInfo.isManagedProfile()) {
if (mType == ProfileSelectFragment.ProfileType.ALL) { if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle( setCategoryTitleFromDevicePolicyResource(preferenceGroup, WORK_CATEGORY_HEADER,
mDpm.getResources().getString(WORK_CATEGORY_HEADER, R.string.category_work);
() -> mContext.getString(R.string.category_work)));
final String workGroupSummary = getWorkGroupSummary(context, userInfo); final String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary); preferenceGroup.setSummary(workGroupSummary);
preferenceGroup.setContentDescription( setContentDescriptionFromDevicePolicyResource(preferenceGroup,
mDpm.getResources().getString(ACCESSIBILITY_CATEGORY_WORK, () -> ACCESSIBILITY_CATEGORY_WORK, R.string.accessibility_category_work,
mContext.getString( workGroupSummary);
R.string.accessibility_category_work, workGroupSummary)));
} }
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(); profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference();
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference, mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference,
DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId()); DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
profileData.managedProfilePreference = newManagedProfileSettings(); profileData.managedProfilePreference = newManagedProfileSettings();
} else { } else if (userInfo.isCloneProfile()) {
if (mType == ProfileSelectFragment.ProfileType.ALL) { if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle( setCategoryTitleFromDevicePolicyResource(preferenceGroup, CLONE_CATEGORY_HEADER,
mDpm.getResources().getString(PERSONAL_CATEGORY_HEADER, R.string.category_clone);
() -> mContext.getString(R.string.category_personal))); setContentDescriptionFromDevicePolicyResource(preferenceGroup,
preferenceGroup.setContentDescription( ACCESSIBILITY_CATEGORY_CLONE, R.string.accessibility_category_clone,
mDpm.getResources().getString(ACCESSIBILITY_CATEGORY_PERSONAL, () -> null);
mContext.getString(R.string.accessibility_category_personal))); }
} else {
// Primary Profile
if (mType == ProfileSelectFragment.ProfileType.ALL) {
setCategoryTitleFromDevicePolicyResource(preferenceGroup, PERSONAL_CATEGORY_HEADER,
R.string.category_personal);
setContentDescriptionFromDevicePolicyResource(preferenceGroup,
ACCESSIBILITY_CATEGORY_PERSONAL, R.string.accessibility_category_personal,
null);
} }
} }
final PreferenceScreen screen = mFragment.getPreferenceScreen(); final PreferenceScreen screen = mFragment.getPreferenceScreen();
@@ -381,13 +389,33 @@ public class AccountPreferenceController extends AbstractPreferenceController
if (userInfo.isEnabled()) { if (userInfo.isEnabled()) {
profileData.authenticatorHelper = new AuthenticatorHelper(context, profileData.authenticatorHelper = new AuthenticatorHelper(context,
userInfo.getUserHandle(), this); userInfo.getUserHandle(), this);
profileData.addAccountPreference = newAddAccountPreference(); if (!userInfo.isCloneProfile()) {
mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference, profileData.addAccountPreference = newAddAccountPreference();
DISALLOW_MODIFY_ACCOUNTS, userInfo.id); mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference,
DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
}
} }
mProfiles.put(userInfo.id, profileData); mProfiles.put(userInfo.id, profileData);
} }
private void setCategoryTitleFromDevicePolicyResource(
AccessiblePreferenceCategory preferenceGroup, String stringId, int resourceIdentifier) {
preferenceGroup.setTitle(
mDpm.getResources().getString(stringId,
() -> mContext.getString(resourceIdentifier)));
}
private void setContentDescriptionFromDevicePolicyResource(
AccessiblePreferenceCategory preferenceGroup, String stringId, int resourceIdentifier,
String formatArgs) {
preferenceGroup.setContentDescription(mDpm.getResources().getString(stringId, () -> {
if (formatArgs != null) {
return mContext.getString(resourceIdentifier, formatArgs);
}
return mContext.getString(resourceIdentifier);
}));
}
private RestrictedPreference newAddAccountPreference() { private RestrictedPreference newAddAccountPreference() {
RestrictedPreference preference = RestrictedPreference preference =
new RestrictedPreference(mFragment.getPreferenceManager().getContext()); new RestrictedPreference(mFragment.getPreferenceManager().getContext());