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
This commit is contained in:
yingleiw
2019-08-02 16:14:27 -07:00
committed by Yinglei Wang
parent 22edac9bf5
commit 02cc848896

View File

@@ -1562,12 +1562,20 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
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 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
if (pagesFlipped ? scrollRight() : scrollLeft()) {
return true;
}
} break;
case android.R.id.accessibilityActionPageRight: {
if (!mIsRtl) {
return scrollRight();
} else {
return scrollLeft();
}
}
case android.R.id.accessibilityActionPageLeft: {
if (!mIsRtl) {
return scrollLeft();
} else {
return scrollRight();
}
}
break;
}
return false;
}