diff options
author | Vadim Tryshev <vadimt@google.com> | 2018-05-25 19:55:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-25 19:55:39 +0000 |
commit | 5c17a390d235fdafb51cfe4a8d508edc5f7a5a67 (patch) | |
tree | 683b6cff4a53ef7f4af7242033659a8ab1350d25 | |
parent | 30d2fc748da430fd48fe19acb220841115979e70 (diff) | |
parent | 528b9e0615e9427eda667599b387a67ff1a393a8 (diff) | |
download | android_packages_apps_Trebuchet-5c17a390d235fdafb51cfe4a8d508edc5f7a5a67.tar.gz android_packages_apps_Trebuchet-5c17a390d235fdafb51cfe4a8d508edc5f7a5a67.tar.bz2 android_packages_apps_Trebuchet-5c17a390d235fdafb51cfe4a8d508edc5f7a5a67.zip |
Merge "Reporting range of visible tasks" into ub-launcher3-edmonton
-rw-r--r-- | quickstep/src/com/android/quickstep/views/RecentsView.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 31 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 25 |
3 files changed, 39 insertions, 26 deletions
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index dee15d0d7..02cdd3a7c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1307,10 +1307,11 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl super.onInitializeAccessibilityEvent(event); if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) { - final int visiblePageNumber = getChildCount() - getCurrentPage() - 1; - event.setFromIndex(visiblePageNumber); - event.setToIndex(visiblePageNumber); - event.setItemCount(getChildCount()); + final int childCount = getChildCount(); + final int[] visibleTasks = getVisibleChildrenRange(); + event.setFromIndex(childCount - visibleTasks[1] - 1); + event.setToIndex(childCount - visibleTasks[0] - 1); + event.setItemCount(childCount); } } diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 5cc2e8fc5..62b581f83 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -152,6 +152,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou // Similar to the platform implementation of isLayoutValid(); protected boolean mIsLayoutValid; + private int[] mTmpIntPair = new int[2]; + public PagedView(Context context) { this(context, null); } @@ -1600,4 +1602,33 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou boolean shouldIncludeView(View view); } + + public int[] getVisibleChildrenRange() { + float visibleLeft = 0; + float visibleRight = visibleLeft + getMeasuredWidth(); + float scaleX = getScaleX(); + if (scaleX < 1 && scaleX > 0) { + float mid = getMeasuredWidth() / 2; + visibleLeft = mid - ((mid - visibleLeft) / scaleX); + visibleRight = mid + ((visibleRight - mid) / scaleX); + } + + int leftChild = -1; + int rightChild = -1; + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getPageAt(i); + + float left = child.getLeft() + child.getTranslationX() - getScrollX(); + if (left <= visibleRight && (left + child.getMeasuredWidth()) >= visibleLeft) { + if (leftChild == -1) { + leftChild = i; + } + rightChild = i; + } + } + mTmpIntPair[0] = leftChild; + mTmpIntPair[1] = rightChild; + return mTmpIntPair; + } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 06eb82e3e..66fb3c6b3 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1381,28 +1381,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator> if (mChildrenLayersEnabled) { final int screenCount = getChildCount(); - float visibleLeft = 0; - float visibleRight = visibleLeft + getMeasuredWidth(); - float scaleX = getScaleX(); - if (scaleX < 1 && scaleX > 0) { - float mid = getMeasuredWidth() / 2; - visibleLeft = mid - ((mid - visibleLeft) / scaleX); - visibleRight = mid + ((visibleRight - mid) / scaleX); - } - - int leftScreen = -1; - int rightScreen = -1; - for (int i = 0; i < screenCount; i++) { - final View child = getPageAt(i); - - float left = child.getLeft() + child.getTranslationX() - getScrollX(); - if (left <= visibleRight && (left + child.getMeasuredWidth()) >= visibleLeft) { - if (leftScreen == -1) { - leftScreen = i; - } - rightScreen = i; - } - } + final int[] visibleScreens = getVisibleChildrenRange(); + int leftScreen = visibleScreens[0]; + int rightScreen = visibleScreens[1]; if (mForceDrawAdjacentPages) { // In overview mode, make sure that the two side pages are visible. leftScreen = Utilities.boundToRange(getCurrentPage() - 1, 0, rightScreen); |