From a4cb0f02de08baf3ad1b8c3f0d0f9be523ee53aa Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Sun, 21 Mar 2021 00:23:07 +0100 Subject: [PATCH] Fix staggered animation on right panel home screen Recently we have added support for multiple panels on the home screen but the current StaggeredWorkspaceAnim logic only supports animation for the leftmost panel. Test: manual Bug: 183032642 Change-Id: I539e1c1a26292b75801eb3070e22f0fbde1ebc7e --- .../util/StaggeredWorkspaceAnim.java | 50 ++++++++++++------- src/com/android/launcher3/PagedView.java | 2 +- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java index 3faf72a006..ce0ad77da3 100644 --- a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java +++ b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java @@ -83,34 +83,25 @@ public class StaggeredWorkspaceAnim { DeviceProfile grid = launcher.getDeviceProfile(); Workspace workspace = launcher.getWorkspace(); - CellLayout cellLayout = (CellLayout) workspace.getChildAt(workspace.getCurrentPage()); - ShortcutAndWidgetContainer currentPage = cellLayout.getShortcutsAndWidgets(); Hotseat hotseat = launcher.getHotseat(); + // Hotseat and QSB takes up two additional rows. + int totalRows = grid.inv.numRows + (grid.isVerticalBarLayout() ? 0 : 2); + + // Add animation for all the visible workspace pages + workspace.getVisiblePages() + .forEach(page -> addAnimationForPage((CellLayout) page, totalRows)); + boolean workspaceClipChildren = workspace.getClipChildren(); boolean workspaceClipToPadding = workspace.getClipToPadding(); - boolean cellLayoutClipChildren = cellLayout.getClipChildren(); - boolean cellLayoutClipToPadding = cellLayout.getClipToPadding(); boolean hotseatClipChildren = hotseat.getClipChildren(); boolean hotseatClipToPadding = hotseat.getClipToPadding(); workspace.setClipChildren(false); workspace.setClipToPadding(false); - cellLayout.setClipChildren(false); - cellLayout.setClipToPadding(false); hotseat.setClipChildren(false); hotseat.setClipToPadding(false); - // Hotseat and QSB takes up two additional rows. - int totalRows = grid.inv.numRows + (grid.isVerticalBarLayout() ? 0 : 2); - - // Set up springs on workspace items. - for (int i = currentPage.getChildCount() - 1; i >= 0; i--) { - View child = currentPage.getChildAt(i); - CellLayout.LayoutParams lp = ((CellLayout.LayoutParams) child.getLayoutParams()); - addStaggeredAnimationForView(child, lp.cellY + lp.cellVSpan, totalRows); - } - // Set up springs for the hotseat and qsb. ViewGroup hotseatIcons = hotseat.getShortcutsAndWidgets(); if (grid.isVerticalBarLayout()) { @@ -155,14 +146,37 @@ public class StaggeredWorkspaceAnim { public void onAnimationEnd(Animator animation) { workspace.setClipChildren(workspaceClipChildren); workspace.setClipToPadding(workspaceClipToPadding); - cellLayout.setClipChildren(cellLayoutClipChildren); - cellLayout.setClipToPadding(cellLayoutClipToPadding); hotseat.setClipChildren(hotseatClipChildren); hotseat.setClipToPadding(hotseatClipToPadding); } }); } + private void addAnimationForPage(CellLayout page, int totalRows) { + ShortcutAndWidgetContainer itemsContainer = page.getShortcutsAndWidgets(); + + boolean pageClipChildren = page.getClipChildren(); + boolean pageClipToPadding = page.getClipToPadding(); + + page.setClipChildren(false); + page.setClipToPadding(false); + + // Set up springs on workspace items. + for (int i = itemsContainer.getChildCount() - 1; i >= 0; i--) { + View child = itemsContainer.getChildAt(i); + CellLayout.LayoutParams lp = ((CellLayout.LayoutParams) child.getLayoutParams()); + addStaggeredAnimationForView(child, lp.cellY + lp.cellVSpan, totalRows); + } + + mAnimators.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + page.setClipChildren(pageClipChildren); + page.setClipToPadding(pageClipToPadding); + } + }); + } + /** * Setup workspace with 0 duration to prepare for our staggered animation. */ diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 72eff620d7..65fde8659a 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -307,7 +307,7 @@ public abstract class PagedView extends ViewGrou /** * Returns the currently visible pages. */ - protected Iterable getVisiblePages() { + public Iterable getVisiblePages() { int panelCount = getPanelCount(); List visiblePages = new ArrayList<>(panelCount); for (int i = mCurrentPage; i < mCurrentPage + panelCount; i++) {