diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 20 | ||||
| -rw-r--r-- | core/res/res/values/strings.xml | 7 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 1 |
4 files changed, 29 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index e0608c1b0c0d..589225a2c647 100644 --- a/api/current.txt +++ b/api/current.txt @@ -21586,6 +21586,7 @@ package android.os { public class UserManager { method public android.os.Bundle getApplicationRestrictions(java.lang.String); method public android.graphics.drawable.Drawable getBadgedDrawableForUser(android.graphics.drawable.Drawable, android.os.UserHandle); + method public java.lang.String getBadgedLabelForUser(java.lang.String, android.os.UserHandle); method public long getSerialNumberForUser(android.os.UserHandle); method public int getUserCount(); method public android.os.UserHandle getUserForSerialNumber(long); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 757f38e065de..96db772f8ee5 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -719,6 +719,26 @@ public class UserManager { /** * If the target user is a managed profile of the calling user or the caller + * is itself a managed profile, then this returns a copy of the label with + * badging for accessibility services like talkback. E.g. passing in "Email" + * and it might return "Work Email" for Email in the work profile. + * + * @param label The label to change. + * @param user The target user. + * @return A label that combines the original label and a badge as + * determined by the system. + */ + public String getBadgedLabelForUser(String label, UserHandle user) { + UserInfo userInfo = getUserIfProfile(user.getIdentifier()); + if (userInfo != null && userInfo.isManagedProfile()) { + return Resources.getSystem().getString( + R.string.managed_profile_label_badge, label); + } + return label; + } + + /** + * If the target user is a managed profile of the calling user or the caller * is itself a managed profile, then this returns a drawable to use as a small * icon to include in a view to distinguish it from the original icon. * diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index e31dbaf08009..c8c0d236bdd6 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4728,6 +4728,13 @@ <!-- Accessibility announcement when a number that had been typed in is deleted [CHAR_LIMIT=NONE] --> <string name="deleted_key"><xliff:g id="key" example="4">%1$s</xliff:g> deleted</string> + <!-- + Used to wrap a label for content description for a managed profile, e.g. "Work Email" instead + of email when there are two email apps. + [CHAR LIMIT=20] + --> + <string name="managed_profile_label_badge">Work <xliff:g id="label" example="Email">%1$s</xliff:g></string> + <!-- DO NOT TRANSLATE --> <string name="time_placeholder">--</string> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 5f4553b49eac..0436127e208a 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -863,6 +863,7 @@ <java-symbol type="string" name="action_bar_home_description_format" /> <java-symbol type="string" name="action_bar_home_subtitle_description_format" /> <java-symbol type="string" name="wireless_display_route_description" /> + <java-symbol type="string" name="managed_profile_label_badge" /> <java-symbol type="string" name="mediasize_unknown_portrait" /> <java-symbol type="string" name="mediasize_unknown_landscape" /> <java-symbol type="string" name="mediasize_iso_a0" /> |