Commit 43f293db authored by Mark Schillaci's avatar Mark Schillaci Committed by Commit Bot

Announce selected tab in accessibility tab switcher on Android

This CL updates the content description for the title of
AccessibilityTabModelListItem's to use an alternate
description for the currently selected tab that appends
the word 'selected'.

e.g.: 'Homepage, tab, selected, 1 of 4'
vs. current: 'Homepage, tab, 1 of 4'

The current accessibility tab switcher does not give a
clear indication to the user which tab is open.


AX-Relnotes: Currently open tab now reads 'selected' when viewing list of open tabs with a screen reader.
Bug: 1122171
Change-Id: I0fd5768e73437f18d3c49e7f821f4a02189c06e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462296
Commit-Queue: Mark Schillaci <mschillaci@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarMei Liang <meiliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815780}
parent 13d5680b
......@@ -139,7 +139,8 @@ public class AccessibilityTabModelAdapter extends BaseAdapter {
}
listItem.setTab(TabModelUtils.getTabById(mUndoneTabModel, tabId),
mActualTabModel.supportsPendingClosures());
mActualTabModel.supportsPendingClosures(),
TabModelUtils.getCurrentTab(mUndoneTabModel).getId() == tabId);
listItem.setListeners(mInternalListener, mCanScrollListener);
listItem.resetState();
......
......@@ -86,6 +86,7 @@ public class AccessibilityTabModelListItem extends FrameLayout implements OnClic
private Tab mTab;
private boolean mCanUndo;
private boolean mIsSelected;
private AccessibilityTabModelListItemListener mListener;
private final GestureDetector mSwipeGestureDetector;
private final int mDefaultHeight;
......@@ -269,12 +270,14 @@ public class AccessibilityTabModelListItem extends FrameLayout implements OnClic
* Sets the {@link Tab} this {@link View} will represent in the list.
* @param tab The {@link Tab} to represent.
* @param canUndo Whether or not closing this {@link Tab} can be undone.
* @param isSelected Whether or not the {@link Tab} is the currently selected one.
*/
public void setTab(Tab tab, boolean canUndo) {
public void setTab(Tab tab, boolean canUndo, boolean isSelected) {
if (mTab != null) mTab.removeObserver(mTabObserver);
mTab = tab;
tab.addObserver(mTabObserver);
mCanUndo = canUndo;
mIsSelected = isSelected;
updateTabText();
updateFavicon();
}
......@@ -315,11 +318,11 @@ public class AccessibilityTabModelListItem extends FrameLayout implements OnClic
if (!title.equals(mTitleView.getText())) mTitleView.setText(title);
String accessibilityString =
getContext().getString(R.string.accessibility_tabstrip_tab, title);
String accessibilityString = mIsSelected
? getContext().getString(R.string.accessibility_tabstrip_tab_selected, title)
: getContext().getString(R.string.accessibility_tabstrip_tab, title);
if (!accessibilityString.equals(getContentDescription())) {
setContentDescription(
getContext().getString(R.string.accessibility_tabstrip_tab, title));
setContentDescription(accessibilityString);
mCloseButton.setContentDescription(
getContext().getString(R.string.accessibility_tabstrip_btn_close_tab, title));
}
......
......@@ -1851,6 +1851,9 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_TABSTRIP_TAB" desc="Content description for the tab title.">
<ph name="TAB_TITLE">%1$s<ex>Welcome to Facebook</ex></ph>, tab
</message>
<message name="IDS_ACCESSIBILITY_TABSTRIP_TAB_SELECTED" desc="Content description for the tab title of the currently selected tab.">
<ph name="TAB_TITLE">%1$s<ex>Welcome to Facebook</ex></ph>, tab, selected
</message>
<message name="IDS_ACCESSIBILITY_TABSTRIP_BTN_CLOSE_TAB" desc="Content description for the close tab button.">
Close <ph name="TAB_TITLE">%1$s<ex>Google</ex></ph> tab
</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