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

Commit a3074925 authored by Alex Chau's avatar Alex Chau
Browse files

Removed onBackPressed handling in SplitSCreenSelectState

- So it'll have exact same behavior as OverviewState to exit overview when going back
- Also removed RecentsView.cancelSplitSelect as it's longer needed

Fix: 181707736
Test: manual
Change-Id: Ide4dfc64680ecc9adfe245ae2de1463735b0490e
parent 79350ef1
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ public final class RecentsViewStateController extends
            builder.add(mRecentsView.createSplitSelectInitAnimation().buildAnim());
            mRecentsView.applySplitPrimaryScrollOffset();
        } else if (!isSplitSelectionState(toState) && isSplitSelectionState(currentState)) {
            builder.add(mRecentsView.cancelSplitSelect(true).buildAnim());
            mRecentsView.resetSplitPrimaryScrollOffset();
        }

+0 −5
Original line number Diff line number Diff line
@@ -30,11 +30,6 @@ public class SplitScreenSelectState extends OverviewState {
        super(id);
    }

    @Override
    public void onBackPressed(Launcher launcher) {
        launcher.getStateManager().goToState(OVERVIEW);
    }

    @Override
    public int getVisibleElements(Launcher launcher) {
        return SPLIT_PLACHOLDER_VIEW;
+0 −106
Original line number Diff line number Diff line
@@ -1123,9 +1123,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            // Reset the running task when leaving overview since it can still have a reference to
            // its thumbnail
            mTmpRunningTasks = null;
            if (mSplitSelectStateController.isSplitSelectActive()) {
                cancelSplitSelect(false);
            }
            // Remove grouped tasks and recycle once we exit overview
            int taskCount = getTaskViewCount();
            for (int i = 0; i < taskCount; i++) {
@@ -3940,109 +3937,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        pendingAnimation.buildAnim().start();
    }

    public PendingAnimation cancelSplitSelect(boolean animate) {
        SplitSelectStateController splitController = mSplitSelectStateController;
        @StagePosition int stagePosition = splitController.getActiveSplitStagePosition();
        Rect initialBounds = splitController.getInitialBounds();
        splitController.resetState();
        int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext());
        PendingAnimation pendingAnim = new PendingAnimation(duration);
        mSplitToast.cancel();
        mSplitUnsupportedToast.cancel();
        if (!animate) {
            resetFromSplitSelectionState();
            return pendingAnim;
        }

        addViewInLayout(mSplitHiddenTaskView, mSplitHiddenTaskViewIndex,
                mSplitHiddenTaskView.getLayoutParams());
        mSplitHiddenTaskView.setAlpha(0);
        int[] oldScroll = new int[getChildCount()];
        getPageScrolls(oldScroll, false,
                view -> view.getVisibility() != GONE && view != mSplitHiddenTaskView);

        int[] newScroll = new int[getChildCount()];
        getPageScrolls(newScroll, false, SIMPLE_SCROLL_LOGIC);

        boolean needsCurveUpdates = false;
        for (int i = mSplitHiddenTaskViewIndex; i >= 0; i--) {
            View child = getChildAt(i);
            if (child == mSplitHiddenTaskView) {
                TaskView taskView = (TaskView) child;

                int dir = mOrientationHandler.getSplitTaskViewDismissDirection(stagePosition,
                        mActivity.getDeviceProfile());
                FloatProperty<TaskView> dismissingTaskViewTranslate;
                Rect hiddenBounds = new Rect(taskView.getLeft(), taskView.getTop(),
                        taskView.getRight(), taskView.getBottom());
                int distanceDelta = 0;
                if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_SECONDARY_NEGATIVE) {
                    dismissingTaskViewTranslate = taskView
                            .getSecondaryDissmissTranslationProperty();
                    distanceDelta = initialBounds.top - hiddenBounds.top;
                    taskView.layout(initialBounds.left, hiddenBounds.top, initialBounds.right,
                            hiddenBounds.bottom);
                } else {
                    dismissingTaskViewTranslate = taskView
                            .getPrimaryDismissTranslationProperty();
                    distanceDelta = initialBounds.left - hiddenBounds.left;
                    taskView.layout(hiddenBounds.left, initialBounds.top, hiddenBounds.right,
                            initialBounds.bottom);
                    if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_POSITIVE) {
                        distanceDelta *= -1;
                    }
                }
                pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView,
                        dismissingTaskViewTranslate,
                        distanceDelta));
                pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, ALPHA, 1));
            } else {
                // If insertion is on last index (furthest from clear all), we directly add the view
                // else we translate all views to the right of insertion index further right,
                // ignore views to left
                if (showAsGrid()) {
                    // TODO(b/186800707) handle more elegantly for grid
                    continue;
                }
                int scrollDiff = newScroll[i] - oldScroll[i];
                if (scrollDiff != 0) {
                    FloatProperty translationProperty = child instanceof TaskView
                            ? ((TaskView) child).getPrimaryDismissTranslationProperty()
                            : mOrientationHandler.getPrimaryViewTranslate();

                    ResourceProvider rp = DynamicResource.provider(mActivity);
                    SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_END)
                            .setDampingRatio(
                                    rp.getFloat(R.dimen.dismiss_task_trans_x_damping_ratio))
                            .setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_x_stiffness));
                    pendingAnim.add(ObjectAnimator.ofFloat(child, translationProperty, scrollDiff)
                            .setDuration(duration), ACCEL, sp);
                    needsCurveUpdates = true;
                }
            }
        }

        if (needsCurveUpdates) {
            pendingAnim.addOnFrameCallback(this::updateCurveProperties);
        }

        pendingAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                // TODO(b/186800707) Figure out how to undo for grid view
                //  Need to handle cases where dismissed task is
                //  * Top Row
                //  * Bottom Row
                //  * Focused Task
                updateGridProperties();
                resetFromSplitSelectionState();
                updateScrollSynchronously();
            }
        });

        return pendingAnim;
    }

    /** TODO(b/181707736) More gracefully handle exiting split selection state */
    private void resetFromSplitSelectionState() {
        if (!mActivity.getDeviceProfile().overviewShowAsGrid) {