From f6c2e87747c9dcef6d8aae74a129a4672527accd Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 7 Jul 2023 13:37:24 -0700 Subject: [PATCH] Dismiss split select when tapping on home button Bug: 276361926 Test: Initate split, dismiss whenever home is pressed, doesn't dismiss when all apps dragged down Flag: ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE Change-Id: Idc95123e27963c3913d04c6eb27f0e4c9b1eb401 --- .../BaseRecentsViewStateController.java | 2 +- .../uioverrides/QuickstepLauncher.java | 9 ++++++- .../util/SplitAnimationController.kt | 27 +++++++++++++++---- .../quickstep/views/LauncherRecentsView.java | 4 +++ src/com/android/launcher3/Launcher.java | 8 ++++++ 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java index 9fcadeaf3d..d78ca88249 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java @@ -111,7 +111,7 @@ public abstract class BaseRecentsViewStateController && !toState.overviewUi; if (mRecentsView.isSplitSelectionActive() && exitingOverview) { setter.add(mRecentsView.getSplitSelectController().getSplitAnimationController() - .animateAwayPlaceholder(mLauncher)); + .createPlaceholderDismissAnim(mLauncher)); setter.setViewAlpha( mRecentsView.getSplitInstructionsView(), 0, diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 3b53e8a7b6..7ce87a31bc 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -549,7 +549,7 @@ public class QuickstepLauncher extends Launcher { list.add(getDragController()); Consumer splitAnimator = animatorSet -> { AnimatorSet anim = mSplitSelectStateController.getSplitAnimationController() - .animateAwayPlaceholder(QuickstepLauncher.this); + .createPlaceholderDismissAnim(QuickstepLauncher.this); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -1000,6 +1000,13 @@ public class QuickstepLauncher extends Launcher { return mSplitToWorkspaceController; } + @Override + protected void handleSplitAnimationGoingToHome() { + super.handleSplitAnimationGoingToHome(); + mSplitSelectStateController.getSplitAnimationController() + .playPlaceholderDismissAnim(this); + } + public T getActionsView() { return (T) mActionsView; } diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index 2e8af4c64b..5740991a4a 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -17,6 +17,8 @@ package com.android.quickstep.util +import android.animation.Animator +import android.animation.AnimatorListenerAdapter import android.animation.AnimatorSet import android.animation.ObjectAnimator import android.graphics.Bitmap @@ -185,17 +187,32 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC } } + /** Does not play any animation if user is not currently in split selection state. */ + fun playPlaceholderDismissAnim(launcher: Launcher) { + if (!splitSelectStateController.isSplitSelectActive) { + return + } - fun animateAwayPlaceholder(mLauncher: Launcher) : AnimatorSet { + val anim = createPlaceholderDismissAnim(launcher) + anim.addListener(object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + splitSelectStateController.resetState() + } + }) + anim.start() + } + + /** Returns [AnimatorSet] which slides initial split placeholder view offscreen. */ + fun createPlaceholderDismissAnim(launcher: Launcher) : AnimatorSet { val animatorSet = AnimatorSet() - val recentsView : RecentsView<*, *> = mLauncher.getOverviewPanel() + val recentsView : RecentsView<*, *> = launcher.getOverviewPanel() val floatingTask: FloatingTaskView = splitSelectStateController.firstFloatingTaskView ?: return animatorSet // We are in split selection state currently, transitioning to another state - val dragLayer: DragLayer = mLauncher.dragLayer + val dragLayer: DragLayer = launcher.dragLayer val onScreenRectF = RectF() - Utilities.getBoundsForViewInDragLayer(mLauncher.dragLayer, floatingTask, + Utilities.getBoundsForViewInDragLayer(launcher.dragLayer, floatingTask, Rect(0, 0, floatingTask.width, floatingTask.height), false, null, onScreenRectF) // Get the part of the floatingTask that intersects with the DragLayer (i.e. the @@ -214,7 +231,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC floatingTask, onScreenRectF, floatingTask.stagePosition, - mLauncher.deviceProfile + launcher.deviceProfile ))) return animatorSet } diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 3ee900999e..828d466b5e 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -86,6 +86,10 @@ public class LauncherRecentsView extends RecentsView if (mLauncherCallbacks != null) { mLauncherCallbacks.onHomeIntent(internalStateHandled); } + if (FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE.get()) { + handleSplitAnimationGoingToHome(); + } mOverlayManager.hideOverlay(isStarted() && !isForceInvisible()); handleGestureContract(intent); } else if (Intent.ACTION_ALL_APPS.equals(intent.getAction())) { @@ -1695,6 +1698,11 @@ public class Launcher extends StatefulActivity TraceHelper.INSTANCE.endSection(); } + /** Handle animating away split placeholder view when user taps on home button */ + protected void handleSplitAnimationGoingToHome() { + // Overridden + } + protected void toggleAllAppsFromIntent(boolean alreadyOnHome) { if (getStateManager().isInStableState(ALL_APPS)) { getStateManager().goToState(NORMAL, alreadyOnHome);