Commit 453473b4 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Download infobar : Fix for accessibility

The talkback doesn't announce the subsequent text updates to the infobar
with the default infobar implementation. With this CL we are trying to fix that.

Bug: 848135
Change-Id: I49c671fee841026129ed244df420e5e1fc25e75b
Reviewed-on: https://chromium-review.googlesource.com/1087759Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565752}
parent 64e23b8c
......@@ -110,6 +110,7 @@ public class DownloadInfoBarController implements OfflineContentProvider.Observe
public ContentId id;
public String message;
public String accessibilityMessage;
public String link;
public int icon;
......@@ -618,6 +619,8 @@ public class DownloadInfoBarController implements OfflineContentProvider.Observe
}
setForceReparent(info);
setAccessibilityMessage(
info, showAccelerating && infoBarState == DownloadInfoBarState.DOWNLOADING);
showInfoBar(infoBarState, info);
}
......@@ -627,6 +630,15 @@ public class DownloadInfoBarController implements OfflineContentProvider.Observe
mCurrentInfo == null ? null : mCurrentInfo.downloadCount);
}
private void setAccessibilityMessage(
DownloadProgressInfoBarData info, boolean showAccelerating) {
info.accessibilityMessage = info.message;
if (!showAccelerating) {
info.accessibilityMessage = info.accessibilityMessage + " "
+ getContext().getString(R.string.bottom_bar_screen_position);
}
}
private void clearEndTimerRunnable() {
mHandler.removeCallbacks(mEndTimerRunnable);
mEndTimerRunnable = null;
......
......@@ -8,8 +8,12 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.graphics.drawable.Animatable2Compat;
import android.support.graphics.drawable.AnimatedVectorDrawableCompat;
import android.support.v4.view.ViewCompat;
import android.view.View;
import android.widget.TextView;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadInfoBarController;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.components.offline_items_collection.ContentId;
......@@ -110,6 +114,11 @@ public class DownloadProgressInfoBar extends InfoBar {
layout.setMessage(mInfo.message);
layout.appendMessageLinkText(mInfo.link);
TextView messageView =
(TextView) layout.getMessageLayout().findViewById(R.id.infobar_message);
messageView.setContentDescription(mInfo.accessibilityMessage);
ViewCompat.setAccessibilityLiveRegion(messageView, View.ACCESSIBILITY_LIVE_REGION_POLITE);
if (!mInfo.hasAnimation) {
layout.getIcon().setImageResource(mInfo.icon);
return;
......@@ -151,6 +160,11 @@ public class DownloadProgressInfoBar extends InfoBar {
setLayoutProperties((InfoBarLayout) getView(), info);
}
@Override
public CharSequence getAccessibilityText() {
return null;
}
/**
* Creates and shows the {@link DownloadProgressInfoBar}.
* @param tab The tab that the {@link DownloadProgressInfoBar} should be shown in.
......
......@@ -12,6 +12,7 @@ import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
......@@ -865,6 +866,12 @@ public class InfoBarContainerLayout extends FrameLayout {
mFloatingBehavior.afterOnMeasure(getMeasuredHeight());
}
@Override
public void announceForAccessibility(CharSequence text) {
if (TextUtils.isEmpty(text)) return;
super.announceForAccessibility(text);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
......
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