From b42e124f5b189eb28d7dd2694ef6dab77985aa07 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 8 Mar 2022 16:37:35 -0800 Subject: [PATCH] Never look for matching view in All Apps when swiping up to go home. The swiping up gesture will never return an app in All Apps, so we can ignore All Apps state in those cases. This fixes an edge case where user swipes up and launcher state is still in All Apps. This causes us to animate the icon to where it would be in All Apps, even though by the time the animation starts we are actually in Normal state. Bug: 222124240 Test: open app from all apps then quickly swipe up to go home Change-Id: I756a870660a397d6629aec82e4f5ec4914ed0669 --- .../com/android/launcher3/QuickstepTransitionManager.java | 4 ++-- .../src/com/android/quickstep/LauncherSwipeHandlerV2.java | 3 ++- src/com/android/launcher3/Launcher.java | 7 +++++-- src/com/android/launcher3/views/FloatingSurfaceView.java | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index c4a3fb5572..8644a1238f 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1288,8 +1288,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener } } - return mLauncher.getFirstMatchForAppClose(launchCookieItemId, - packageName, UserHandle.of(runningTaskTarget.taskInfo.userId)); + return mLauncher.getFirstMatchForAppClose(launchCookieItemId, packageName, + UserHandle.of(runningTaskTarget.taskInfo.userId), true /* supportsAllAppsState */); } private @NonNull RectF getDefaultWindowTargetRect() { diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index af6cb847db..bc7a6ae449 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -233,7 +233,8 @@ public class LauncherSwipeHandlerV2 extends return mActivity.getFirstMatchForAppClose(launchCookieItemId, runningTaskView.getTask().key.getComponent().getPackageName(), - UserHandle.of(runningTaskView.getTask().key.userId)); + UserHandle.of(runningTaskView.getTask().key.userId), + false /* supportsAllAppsState */); } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8fb2f53ec6..9bb815c823 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2743,8 +2743,11 @@ public class Launcher extends StatefulActivity implements Launche * @param preferredItemId The id of the preferred item to match to if it exists. * @param packageName The package name of the app to match. * @param user The user of the app to match. + * @param supportsAllAppsState If true and we are in All Apps state, looks for view in All Apps. + * Else we only looks on the workspace. */ - public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user) { + public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user, + boolean supportsAllAppsState) { final ItemInfoMatcher preferredItem = (info, cn) -> info != null && info.id == preferredItemId; final ItemInfoMatcher packageAndUserAndApp = (info, cn) -> @@ -2755,7 +2758,7 @@ public class Launcher extends StatefulActivity implements Launche && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName); - if (isInState(LauncherState.ALL_APPS)) { + if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) { return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), preferredItem, packageAndUserAndApp); } else { diff --git a/src/com/android/launcher3/views/FloatingSurfaceView.java b/src/com/android/launcher3/views/FloatingSurfaceView.java index 7f54d6dce5..19c28b4c72 100644 --- a/src/com/android/launcher3/views/FloatingSurfaceView.java +++ b/src/com/android/launcher3/views/FloatingSurfaceView.java @@ -159,7 +159,8 @@ public class FloatingSurfaceView extends AbstractFloatingView implements return; } View icon = mLauncher.getFirstMatchForAppClose(-1, - mContract.componentName.getPackageName(), mContract.user); + mContract.componentName.getPackageName(), mContract.user, + false /* supportsAllAppsState */); boolean iconChanged = mIcon != icon; if (iconChanged) {