Commit 71a8024a authored by Jay Harris's avatar Jay Harris Committed by Commit Bot

Updates the badge accessibility text on Windows.

Previously, the accessibility text for saturated badges (e.g. 99+ for
badge values greater than 99) was the full number (e.g. 125).
Accessibility recommended that we update the text to match what is
displayed on the badge, as the consistency can be helpful to those with
low vision.

Bug: 719176
Change-Id: Ide81d0dd6f51b0ac2571944db05bd64c00682d90
Reviewed-on: https://chromium-review.googlesource.com/c/1480290Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Jay Harris <harrisjay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634453}
parent f66cd5dd
...@@ -28,9 +28,9 @@ std::string GetBadgeString(base::Optional<uint64_t> badge_content) { ...@@ -28,9 +28,9 @@ std::string GetBadgeString(base::Optional<uint64_t> badge_content) {
if (!badge_content) if (!badge_content)
return "•"; return "•";
if (badge_content > 99u) { if (badge_content > kMaxBadgeContent) {
return base::UTF16ToUTF8(l10n_util::GetStringFUTF16( return base::UTF16ToUTF8(l10n_util::GetStringFUTF16(
IDS_SATURATED_BADGE_CONTENT, base::FormatNumber(99))); IDS_SATURATED_BADGE_CONTENT, base::FormatNumber(kMaxBadgeContent)));
} }
return base::UTF16ToUTF8(base::FormatNumber(badge_content.value())); return base::UTF16ToUTF8(base::FormatNumber(badge_content.value()));
......
...@@ -20,6 +20,9 @@ class Profile; ...@@ -20,6 +20,9 @@ class Profile;
namespace badging { namespace badging {
// The maximum value of badge contents before saturation occurs.
constexpr uint64_t kMaxBadgeContent = 99u;
// Determines the text to put on the badge based on some badge_content. // Determines the text to put on the badge based on some badge_content.
std::string GetBadgeString(base::Optional<uint64_t> badge_content); std::string GetBadgeString(base::Optional<uint64_t> badge_content);
......
...@@ -22,11 +22,32 @@ BadgeManagerDelegateWin::BadgeManagerDelegateWin(Profile* profile) ...@@ -22,11 +22,32 @@ BadgeManagerDelegateWin::BadgeManagerDelegateWin(Profile* profile)
void BadgeManagerDelegateWin::OnBadgeSet(const std::string& app_id, void BadgeManagerDelegateWin::OnBadgeSet(const std::string& app_id,
base::Optional<uint64_t> contents) { base::Optional<uint64_t> contents) {
auto badge_string = badging::GetBadgeString(contents); auto badge_string = badging::GetBadgeString(contents);
auto badge_alt_string = // There are 3 different cases:
contents ? l10n_util::GetPluralStringFUTF8(IDS_BADGE_UNREAD_NOTIFICATIONS, // 1. |contents| is between 1 and 99 inclusive => Set the accessibility text
contents.value()) // to a pluralized notification count (e.g. 4 Unread Notifications).
: l10n_util::GetStringUTF8( // 2. |contents| is greater than 99 => Set the accessibility text to
IDS_BADGE_UNREAD_NOTIFICATIONS_UNSPECIFIED); // More than |kMaxBadgeContent| unread notifications, so the
// accessibility text matches what is displayed on the badge (e.g. More
// than 99 notifications).
// 3. |contents| doesn't have a value (i.e. the badge is set to 'flag') => Set
// the accessibility text to something less specific (e.g. Unread
// Notifications).
std::string badge_alt_string;
if (contents) {
uint64_t value = contents.value();
badge_alt_string = value <= badging::kMaxBadgeContent
// Case 1.
? l10n_util::GetPluralStringFUTF8(
IDS_BADGE_UNREAD_NOTIFICATIONS, value)
// Case 2.
: l10n_util::GetPluralStringFUTF8(
IDS_BADGE_UNREAD_NOTIFICATIONS_SATURATED,
badging::kMaxBadgeContent);
} else {
// Case 3.
badge_alt_string =
l10n_util::GetStringUTF8(IDS_BADGE_UNREAD_NOTIFICATIONS_UNSPECIFIED);
}
for (Browser* browser : *BrowserList::GetInstance()) { for (Browser* browser : *BrowserList::GetInstance()) {
if (!IsAppBrowser(browser, app_id)) if (!IsAppBrowser(browser, app_id))
......
...@@ -901,6 +901,9 @@ need to be translated for each locale.--> ...@@ -901,6 +901,9 @@ need to be translated for each locale.-->
<message name="IDS_SATURATED_BADGE_CONTENT" desc="The content to display when the application's badge is too large to display to indicate that the badge is more than a given maximum. This string should be as short as possible, preferably only one character beyond the content"> <message name="IDS_SATURATED_BADGE_CONTENT" desc="The content to display when the application's badge is too large to display to indicate that the badge is more than a given maximum. This string should be as short as possible, preferably only one character beyond the content">
<ph name="MAXIMUM_VALUE">$1<ex>99</ex></ph>+ <ph name="MAXIMUM_VALUE">$1<ex>99</ex></ph>+
</message> </message>
<message name="IDS_BADGE_UNREAD_NOTIFICATIONS_SATURATED" desc="The accessibility text which will be read by a screen reader when the notification count is too large to display (e.g. greater than 99).">
{MAX_UNREAD_NOTIFICATIONS, plural, =1 {More than 1 unread notification} other {More than # unread notifications}}
</message>
<message name="IDS_BADGE_UNREAD_NOTIFICATIONS_UNSPECIFIED" desc="The accessibility text which will be read by a screen reader when there are some unspecified number of notifications, or user attention is required"> <message name="IDS_BADGE_UNREAD_NOTIFICATIONS_UNSPECIFIED" desc="The accessibility text which will be read by a screen reader when there are some unspecified number of notifications, or user attention is required">
Unread Notifications Unread Notifications
</message> </message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment