Avoid duplicate accessibility announcement upon switching to -1st page
Since -1st window already has accessible description, no need to
announce "Page X of Y" for it.
Bug: 74210311
Test: Manual
Change-Id: I5cbfd763778b5f7049be732a750df4501b5419e0
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 79993c1..15bf76d 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -424,6 +424,13 @@
return computeScrollHelper(true);
}
+ protected void announcePageForAccessibility() {
+ if (isAccessibilityEnabled(getContext())) {
+ // Notify the user when the page changes
+ announceForAccessibility(getCurrentPageDescription());
+ }
+ }
+
protected boolean computeScrollHelper(boolean shouldInvalidate) {
if (mScroller.computeScrollOffset()) {
// Don't bother scrolling if the page does not need to be moved
@@ -452,9 +459,8 @@
pageEndTransition();
}
- if (isAccessibilityEnabled(getContext())) {
- // Notify the user when the page changes
- announceForAccessibility(getCurrentPageDescription());
+ if (canAnnouncePageDescription()) {
+ announcePageForAccessibility();
}
}
return false;
@@ -1535,6 +1541,10 @@
return getCurrentPageDescription();
}
+ protected boolean canAnnouncePageDescription() {
+ return true;
+ }
+
protected String getCurrentPageDescription() {
return getContext().getString(R.string.default_scroll_format,
getNextPage() + 1, getChildCount());