Commit 6cde412b authored by Theresa's avatar Theresa Committed by Commit Bot

Fix accessibility support for MD incognito NTP

Use TextViewWithClickableSpan for the subtitle text so that it responds
to accessibility events when the learn more link is appended to the end.
Also update the XML to make the root view focusable instead of the
scroll view, which fixes an issue where focus was previously going to a
child of the ScrollView instead of the container.

BUG=894844,757017

Change-Id: I737d3aa8cbe03064caa95065a6ce07ba41e6194e
Reviewed-on: https://chromium-review.googlesource.com/c/1278797
Commit-Queue: Theresa <twellington@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599287}
parent bb14f009
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ntp_content" android:id="@+id/ntp_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:contentDescription="@string/accessibility_new_incognito_tab_page" >
<org.chromium.chrome.browser.ntp.NewTabPageScrollView <org.chromium.chrome.browser.ntp.NewTabPageScrollView
android:id="@+id/ntp_scrollview" android:id="@+id/ntp_scrollview"
...@@ -17,10 +20,7 @@ ...@@ -17,10 +20,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fadingEdgeLength="9dp" android:fadingEdgeLength="9dp"
android:fillViewport="false" android:fillViewport="false"
android:focusable="true" android:requiresFadingEdge="vertical" >
android:focusableInTouchMode="true"
android:requiresFadingEdge="vertical"
android:contentDescription="@string/accessibility_new_incognito_tab_page" >
<LinearLayout <LinearLayout
android:id="@+id/new_tab_incognito_container" android:id="@+id/new_tab_incognito_container"
......
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ntp_content" android:id="@+id/ntp_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:contentDescription="@string/accessibility_new_incognito_tab_page" >
<org.chromium.chrome.browser.ntp.NewTabPageScrollView <org.chromium.chrome.browser.ntp.NewTabPageScrollView
android:id="@+id/ntp_scrollview" android:id="@+id/ntp_scrollview"
...@@ -17,10 +20,7 @@ ...@@ -17,10 +20,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fadingEdgeLength="9dp" android:fadingEdgeLength="9dp"
android:fillViewport="false" android:fillViewport="false"
android:focusable="true" android:requiresFadingEdge="vertical" >
android:focusableInTouchMode="true"
android:requiresFadingEdge="vertical"
android:contentDescription="@string/accessibility_new_incognito_tab_page" >
<LinearLayout <LinearLayout
android:id="@+id/new_tab_incognito_container" android:id="@+id/new_tab_incognito_container"
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
android:text="@string/new_tab_otr_title" android:text="@string/new_tab_otr_title"
android:textAppearance="@style/WhiteHeadline" /> android:textAppearance="@style/WhiteHeadline" />
<TextView <org.chromium.ui.widget.TextViewWithClickableSpans
android:id="@+id/new_tab_incognito_subtitle" android:id="@+id/new_tab_incognito_subtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -78,8 +78,6 @@ ...@@ -78,8 +78,6 @@
android:id="@+id/learn_more" android:id="@+id/learn_more"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="@string/learn_more" android:text="@string/learn_more"
android:textAppearance="@style/TextAppearance.IncognitoNewTabLearnMoreLinkModern" android:textAppearance="@style/TextAppearance.IncognitoNewTabLearnMoreLinkModern"
android:lineSpacingExtra="@dimen/md_incognito_ntp_line_spacing" /> android:lineSpacingExtra="@dimen/md_incognito_ntp_line_spacing" />
......
...@@ -54,7 +54,7 @@ public class IncognitoNewTabPageView extends FrameLayout { ...@@ -54,7 +54,7 @@ public class IncognitoNewTabPageView extends FrameLayout {
mScrollView = (NewTabPageScrollView) findViewById(R.id.ntp_scrollview); mScrollView = (NewTabPageScrollView) findViewById(R.id.ntp_scrollview);
mScrollView.setBackgroundColor( mScrollView.setBackgroundColor(
ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_bg_incognito)); ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_bg_incognito));
mScrollView.setContentDescription(getResources().getText( setContentDescription(getResources().getText(
ChromeFeatureList.isEnabled(ChromeFeatureList.INCOGNITO_STRINGS) ChromeFeatureList.isEnabled(ChromeFeatureList.INCOGNITO_STRINGS)
? R.string.accessibility_new_private_tab_page ? R.string.accessibility_new_private_tab_page
: R.string.accessibility_new_incognito_tab_page)); : R.string.accessibility_new_incognito_tab_page));
......
...@@ -239,7 +239,6 @@ public class IncognitoNewTabPageViewMD extends IncognitoNewTabPageView { ...@@ -239,7 +239,6 @@ public class IncognitoNewTabPageViewMD extends IncognitoNewTabPageView {
mContext.getResources().getString(R.string.new_tab_otr_subtitle); mContext.getResources().getString(R.string.new_tab_otr_subtitle);
boolean learnMoreInSubtitle = mWidthDp > WIDE_LAYOUT_THRESHOLD_DP; boolean learnMoreInSubtitle = mWidthDp > WIDE_LAYOUT_THRESHOLD_DP;
mSubtitle.setClickable(learnMoreInSubtitle);
mLearnMore.setVisibility(learnMoreInSubtitle ? View.GONE : View.VISIBLE); mLearnMore.setVisibility(learnMoreInSubtitle ? View.GONE : View.VISIBLE);
if (!learnMoreInSubtitle) { if (!learnMoreInSubtitle) {
......
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