Commit 4a82dff2 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Fix weird/incorrect accessibility text when the dse icon is enabled

Accessibility text should provide the user with a description of what
interaction with the given UI element will involve. The dse icon
is purely cosmetric so it doesn't need an accessibility desicrption
unless the underlying button actually does something. This change
turns off the important for accessibility flag when there's no
description of the button available. There will be no description
available when no interaction with the button is possible.

Bug: 995059
Change-Id: Ifed72d4f63d8ad58a615a583221d1a63940b72e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1799683
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695888}
parent 4175f565
...@@ -315,6 +315,9 @@ class StatusMediator { ...@@ -315,6 +315,9 @@ class StatusMediator {
* - not shown if URL is focused. * - not shown if URL is focused.
*/ */
private void updateLocationBarIcon() { private void updateLocationBarIcon() {
// Update the accessibility description before continuing since we need it either way.
mModel.set(StatusProperties.STATUS_ICON_DESCRIPTION_RES, getAccessibilityDescriptionRes());
// When the search engine logo should be shown, but the engine isn't Google. In this case, // When the search engine logo should be shown, but the engine isn't Google. In this case,
// we download the icon on the fly. // we download the icon on the fly.
boolean showFocused = mUrlHasFocus && mShowStatusIconWhenUrlFocused; boolean showFocused = mUrlHasFocus && mShowStatusIconWhenUrlFocused;
...@@ -358,7 +361,6 @@ class StatusMediator { ...@@ -358,7 +361,6 @@ class StatusMediator {
int icon = 0; int icon = 0;
int tint = 0; int tint = 0;
int description = 0;
int toast = 0; int toast = 0;
mIsSecurityButtonShown = false; mIsSecurityButtonShown = false;
...@@ -367,13 +369,11 @@ class StatusMediator { ...@@ -367,13 +369,11 @@ class StatusMediator {
icon = mFirstSuggestionIsSearchQuery ? R.drawable.omnibox_search icon = mFirstSuggestionIsSearchQuery ? R.drawable.omnibox_search
: R.drawable.ic_omnibox_page; : R.drawable.ic_omnibox_page;
tint = mNavigationIconTintRes; tint = mNavigationIconTintRes;
description = R.string.accessibility_toolbar_btn_site_info;
} }
} else if (mSecurityIconRes != 0) { } else if (mSecurityIconRes != 0) {
mIsSecurityButtonShown = true; mIsSecurityButtonShown = true;
icon = mSecurityIconRes; icon = mSecurityIconRes;
tint = mSecurityIconTintRes; tint = mSecurityIconTintRes;
description = mSecurityIconDescriptionRes;
toast = R.string.menu_page_info; toast = R.string.menu_page_info;
} }
...@@ -384,7 +384,21 @@ class StatusMediator { ...@@ -384,7 +384,21 @@ class StatusMediator {
mModel.set(StatusProperties.STATUS_ICON_RES, icon); mModel.set(StatusProperties.STATUS_ICON_RES, icon);
mModel.set(StatusProperties.STATUS_ICON_TINT_RES, tint); mModel.set(StatusProperties.STATUS_ICON_TINT_RES, tint);
mModel.set(StatusProperties.STATUS_ICON_DESCRIPTION_RES, description);
mModel.set(StatusProperties.STATUS_ICON_ACCESSIBILITY_TOAST_RES, toast); mModel.set(StatusProperties.STATUS_ICON_ACCESSIBILITY_TOAST_RES, toast);
} }
/** Return the resource id for the accessibility description or 0 if none apply. */
private int getAccessibilityDescriptionRes() {
if (mUrlHasFocus) {
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo()) {
return 0;
} else if (mShowStatusIconWhenUrlFocused) {
return R.string.accessibility_toolbar_btn_site_info;
}
} else if (mSecurityIconRes != 0) {
return mSecurityIconDescriptionRes;
}
return 0;
}
} }
...@@ -281,10 +281,13 @@ public class StatusView extends LinearLayout { ...@@ -281,10 +281,13 @@ public class StatusView extends LinearLayout {
*/ */
void setStatusIconDescription(@StringRes int descriptionRes) { void setStatusIconDescription(@StringRes int descriptionRes) {
String description = null; String description = null;
int importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_NO;
if (descriptionRes != 0) { if (descriptionRes != 0) {
description = getResources().getString(descriptionRes); description = getResources().getString(descriptionRes);
importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_YES;
} }
mIconView.setContentDescription(description); mIconView.setContentDescription(description);
mIconView.setImportantForAccessibility(importantForAccessibility);
} }
/** /**
......
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