Add directional accessibility page actions to PagedView
For PagedView, when isPageOrderFlipped is true, it means the LTR mode is
flipped. For the "recents" in launcher, isPageOrderFlipped is true.
However, this doesn't affect the directional page operations since
scrollLeft()/Right() already has correct Rtl considerations. See
b/78788182 for more information on the LTR mode.
Test: Tested with the "recents" in launcher. Verified that page left
action always move pages to the right (so that the next page from the
left side shows), and page right actions always move pages to the left
(so that the next page from the right side shows). Also tested with the
home screen 1/2, 2/2 paging.
Bug: 136277517
Change-Id: I965d651c37d258eaa8ea347d1ad6f698f9b590bf
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index d2b8d4e..bbb3915 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1562,12 +1562,20 @@
final boolean pagesFlipped = isPageOrderFlipped();
info.setScrollable(getPageCount() > 1);
if (getCurrentPage() < getPageCount() - 1) {
- info.addAction(pagesFlipped ? AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD
- : AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
+ info.addAction(pagesFlipped ?
+ AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD
+ : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
+ info.addAction(mIsRtl ?
+ AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT
+ : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT);
}
if (getCurrentPage() > 0) {
- info.addAction(pagesFlipped ? AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
- : AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
+ info.addAction(pagesFlipped ?
+ AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD
+ : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
+ info.addAction(mIsRtl ?
+ AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT
+ : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT);
}
// Accessibility-wise, PagedView doesn't support long click, so disabling it.
@@ -1607,8 +1615,21 @@
if (pagesFlipped ? scrollRight() : scrollLeft()) {
return true;
}
+ } break;
+ case android.R.id.accessibilityActionPageRight: {
+ if (!mIsRtl) {
+ return scrollRight();
+ } else {
+ return scrollLeft();
+ }
}
- break;
+ case android.R.id.accessibilityActionPageLeft: {
+ if (!mIsRtl) {
+ return scrollLeft();
+ } else {
+ return scrollRight();
+ }
+ }
}
return false;
}