Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7ecf7c8 authored by Kenny Guy's avatar Kenny Guy
Browse files

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
parent 63860956
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+20 −0
Original line number Diff line number Diff line
@@ -717,6 +717,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
+7 −0
Original line number Diff line number Diff line
@@ -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>

+1 −0
Original line number Diff line number Diff line
@@ -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" />