From 35d23a62f01027f741e883ee2f227b72c281970f Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Tue, 30 Mar 2021 13:31:23 +0200 Subject: [PATCH] Fix app close animation for two panel home Change getFirstMatchForAppClose to check all the visible pages not just the page with the currentPage index. Test: manual Bug: 183606840 Change-Id: If5280797f821f7d10f82376aeef5e8eb4d352e2a --- src/com/android/launcher3/Hotseat.java | 3 ++- src/com/android/launcher3/Workspace.java | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index 4049ed6882..15e12d697c 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -29,6 +29,7 @@ import android.widget.FrameLayout; import androidx.annotation.Nullable; +import java.util.Arrays; import java.util.function.Consumer; /** @@ -226,7 +227,7 @@ public class Hotseat extends CellLayout implements Insettable { * Returns the first View for which the given itemOperator returns true, or null. */ public View getFirstItemMatch(Workspace.ItemOperator itemOperator) { - return mWorkspace.getFirstMatch(new CellLayout[] { this }, itemOperator); + return mWorkspace.getFirstMatch(Arrays.asList(this), itemOperator); } /** diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index bd173481b7..f645489502 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2968,8 +2968,10 @@ public class Workspace extends PagedView * @param user The user of the app to match. */ public View getFirstMatchForAppClose(String packageName, UserHandle user) { - final int curPage = getCurrentPage(); - final CellLayout currentPage = (CellLayout) getPageAt(curPage); + List cellLayouts = new ArrayList<>(getPanelCount() + 1); + cellLayouts.add(getHotseat()); + getVisiblePages().forEach(page -> cellLayouts.add((CellLayout) page)); + final Workspace.ItemOperator packageAndUser = (ItemInfo info, View view) -> info != null && info.getTargetComponent() != null && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName) @@ -2990,13 +2992,11 @@ public class Workspace extends PagedView // Order: App icons, app in folder. Items in hotseat get returned first. if (ADAPTIVE_ICON_WINDOW_ANIM.get()) { - return getFirstMatch(new CellLayout[] { getHotseat(), currentPage }, - packageAndUserAndApp, packageAndUserAndAppInFolder); + return getFirstMatch(cellLayouts, packageAndUserAndApp, packageAndUserAndAppInFolder); } else { // Do not use Folder as a criteria, since it'll cause a crash when trying to draw // FolderAdaptiveIcon as the background. - return getFirstMatch(new CellLayout[] { getHotseat(), currentPage }, - packageAndUserAndApp); + return getFirstMatch(cellLayouts, packageAndUserAndApp); } } @@ -3030,7 +3030,7 @@ public class Workspace extends PagedView * @param operators List of operators, in order starting from best matching operator. * @return */ - View getFirstMatch(CellLayout[] cellLayouts, final ItemOperator... operators) { + View getFirstMatch(Iterable cellLayouts, final ItemOperator... operators) { // This array is filled with the first match for each operator. final View[] matches = new View[operators.length]; // For efficiency, the outer loop should be CellLayout.