Commit 48b8bd54 authored by Xing Liu's avatar Xing Liu Committed by Chromium LUCI CQ

Read later: Announce checked state in bookmark UI.

Uses Android's accessibility API to announce checked state when tapping
on an item when the selection mode is enabled.

Bug: 1166721
Change-Id: Ifeb2a9ffa80b9a6eecfe1d639a47f4338972aff3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2639155Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845327}
parent 711430d8
......@@ -11,6 +11,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Checkable;
import androidx.annotation.Nullable;
......@@ -110,6 +111,19 @@ public abstract class SelectableItemViewBase<E> extends ViewLookupCachingFrameLa
setOnTouchListener(this);
setOnClickListener(this);
setOnLongClickListener(this);
setAccessibilityDelegate(new AccessibilityDelegate() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
// Announce checked state if selection mode is on. The actual read out from talkback
// is "checked/unchecked, {content description of this view.}"
boolean checkable = mSelectionDelegate != null
&& mSelectionDelegate.isSelectionEnabled() && mItem != null;
info.setCheckable(checkable);
info.setChecked(isChecked());
}
});
}
@Override
......
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