diff options
author | Kenny Guy <kennyguy@google.com> | 2014-06-18 11:32:05 +0100 |
---|---|---|
committer | Kenny Guy <kennyguy@google.com> | 2014-06-19 13:17:02 +0100 |
commit | f7ecf7c80520c017255cb350d183f0b62022349b (patch) | |
tree | 54709c0519509a54fce5b48a1d8d344a70371e12 | |
parent | 63860956f1c5fa18e2c89584e9399393831b0e49 (diff) | |
download | frameworks_base-f7ecf7c80520c017255cb350d183f0b62022349b.zip frameworks_base-f7ecf7c80520c017255cb350d183f0b62022349b.tar.gz frameworks_base-f7ecf7c80520c017255cb350d183f0b62022349b.tar.bz2 |
Add badging a label to support accessibility.
To provide a way to differntiate the content description
of an icon that has been badged with a managed profile
badge.
Bug: 15106236
Change-Id: Icd5798bbd2410a105054877e3862e199eff24b88
-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 e0608c1..589225a 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 757f38e..96db772 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 e31dbaf..c8c0d23 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 5f4553b..0436127 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" /> |