Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6c2e877 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

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
parent 5e2a2564
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
                && !toState.overviewUi;
        if (mRecentsView.isSplitSelectionActive() && exitingOverview) {
            setter.add(mRecentsView.getSplitSelectController().getSplitAnimationController()
                    .animateAwayPlaceholder(mLauncher));
                    .createPlaceholderDismissAnim(mLauncher));
            setter.setViewAlpha(
                    mRecentsView.getSplitInstructionsView(),
                    0,
+8 −1
Original line number Diff line number Diff line
@@ -549,7 +549,7 @@ public class QuickstepLauncher extends Launcher {
        list.add(getDragController());
        Consumer<AnimatorSet> 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 extends OverviewActionsView> T getActionsView() {
        return (T) mActionsView;
    }
+22 −5
Original line number Diff line number Diff line
@@ -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
        }

        val anim = createPlaceholderDismissAnim(launcher)
        anim.addListener(object : AnimatorListenerAdapter() {
            override fun onAnimationEnd(animation: Animator) {
                splitSelectStateController.resetState()
            }
        })
        anim.start()
    }

    fun animateAwayPlaceholder(mLauncher: Launcher) : AnimatorSet {
    /** 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
    }
+4 −0
Original line number Diff line number Diff line
@@ -86,6 +86,10 @@ public class LauncherRecentsView extends RecentsView<QuickstepLauncher, Launcher
        StateManager stateManager = mActivity.getStateManager();
        animated &= stateManager.shouldAnimateStateChange();
        stateManager.goToState(NORMAL, animated);
        if (FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE.get()) {
            mSplitSelectStateController.getSplitAnimationController()
                    .playPlaceholderDismissAnim(mActivity);
        }
        AbstractFloatingView.closeAllOpenViews(mActivity, animated);
    }

+8 −0
Original line number Diff line number Diff line
@@ -1682,6 +1682,9 @@ public class Launcher extends StatefulActivity<LauncherState>
            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<LauncherState>
        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);