diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index e9010d2a46..d731d3698e 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1039,6 +1039,17 @@ public abstract class RecentsView= start && taskEnd <= end; + } + /** * Returns true if the task is in expected scroll position. * @@ -4939,6 +4959,62 @@ public abstract class RecentsView= 0) { + // Find the next page that is not fully visible. + TaskView taskView = getTaskViewAt(targetPage); + while ((taskView == null || isTaskViewFullyVisible(taskView)) && targetPage - 1 >= 0) { + taskView = getTaskViewAt(--targetPage); + } + // Target a scroll where targetPage is on left of screen but still fully visible. + int lastTaskEnd = (mIsRtl + ? mLastComputedGridSize.left + : mLastComputedGridSize.right) + + (mIsRtl ? mPageSpacing : -mPageSpacing); + int normalTaskEnd = mIsRtl + ? mLastComputedGridTaskSize.left + : mLastComputedGridTaskSize.right; + int targetScroll = getScrollForPage(targetPage) + normalTaskEnd - lastTaskEnd; + // Find a page that is close to targetScroll while not over it. + while (targetPage - 1 >= 0 + && (mIsRtl + ? getScrollForPage(targetPage - 1) < targetScroll + : getScrollForPage(targetPage - 1) > targetScroll)) { + targetPage--; + } + snapToPage(targetPage); + return true; + } + + return mAllowOverScroll; + } + + @Override + public boolean scrollRight() { + if (!showAsGrid()) { + return super.scrollRight(); + } + + int targetPage = getNextPage(); + if (targetPage < getChildCount()) { + // Find the next page that is not fully visible. + TaskView taskView = getTaskViewAt(targetPage); + while ((taskView != null && isTaskViewFullyVisible(taskView)) + && targetPage + 1 < getChildCount()) { + taskView = getTaskViewAt(++targetPage); + } + snapToPage(targetPage); + return true; + } + return mAllowOverScroll; + } + @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 1ce7ebec4d..2c14f07779 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1749,20 +1749,23 @@ public abstract class PagedView extends ViewGrou public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); final boolean pagesFlipped = isPageOrderFlipped(); - int offset = (mAllowOverScroll ? 0 : 1); - info.setScrollable(getPageCount() > offset); - if (getCurrentPage() < getPageCount() - offset) { + info.setScrollable(getPageCount() > 0); + int primaryScroll = mOrientationHandler.getPrimaryScroll(this); + if (getCurrentPage() < getPageCount() - getPanelCount() + || (getCurrentPage() == getPageCount() - getPanelCount() + && primaryScroll != getScrollForPage(getPageCount() - getPanelCount()))) { info.addAction(pagesFlipped ? - AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD - : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD); + 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() >= offset) { + if (getCurrentPage() > 0 + || (getCurrentPage() == 0 && primaryScroll != getScrollForPage(0))) { info.addAction(pagesFlipped ? - AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD - : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); + AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD + : AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD); info.addAction(mIsRtl ? AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT : AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT); @@ -1807,16 +1810,16 @@ public abstract class PagedView extends ViewGrou } break; case android.R.id.accessibilityActionPageRight: { if (!mIsRtl) { - return scrollRight(); + return scrollRight(); } else { - return scrollLeft(); + return scrollLeft(); } } case android.R.id.accessibilityActionPageLeft: { if (!mIsRtl) { - return scrollLeft(); + return scrollLeft(); } else { - return scrollRight(); + return scrollRight(); } } }