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

Commit 0d07b6d0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Handle split selection when animation is disabled" into sc-v2-dev am: 3a6a0f5a

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16512483

Change-Id: I2a6f38c2786d835f002086407b44ec39ec145272
parents 1dc16ded 3a6a0f5a
Loading
Loading
Loading
Loading
+0 −13
Original line number Original line Diff line number Diff line
@@ -29,12 +29,9 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.TASK_PRIMARY_SPLIT_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_SPLIT_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;


import android.util.FloatProperty;
import android.util.FloatProperty;
import android.util.Pair;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;


@@ -43,7 +40,6 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;


/**
/**
@@ -100,15 +96,6 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR));
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR));
        setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f,
        setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f,
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));
        PagedOrientationHandler orientationHandler =
                ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
        Pair<FloatProperty, FloatProperty> taskViewsFloat =
                orientationHandler.getSplitSelectTaskOffset(
                        TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION,
                        mLauncher.getDeviceProfile());
        setter.setFloat(mRecentsView, taskViewsFloat.first,
                toState.getSplitSelectTranslation(mLauncher), LINEAR);
        setter.setFloat(mRecentsView, taskViewsFloat.second, 0, LINEAR);


        setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
        setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
                config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
                config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
+49 −15
Original line number Original line Diff line number Diff line
@@ -23,13 +23,17 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_AC
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.quickstep.views.RecentsView.TASK_MODALNESS;
import static com.android.quickstep.views.RecentsView.TASK_MODALNESS;
import static com.android.quickstep.views.RecentsView.TASK_PRIMARY_SPLIT_TRANSLATION;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_SPLIT_TRANSLATION;
import static com.android.quickstep.views.TaskView.FLAG_UPDATE_ALL;
import static com.android.quickstep.views.TaskView.FLAG_UPDATE_ALL;


import android.annotation.TargetApi;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Build;
import android.util.FloatProperty;
import android.util.FloatProperty;
import android.util.Pair;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
@@ -37,6 +41,7 @@ import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.quickstep.views.ClearAllButton;
import com.android.quickstep.views.ClearAllButton;
import com.android.quickstep.views.LauncherRecentsView;
import com.android.quickstep.views.LauncherRecentsView;
@@ -67,11 +72,7 @@ public final class RecentsViewStateController extends
        // DepthController to prevent optimizations which might occlude the layers behind
        // DepthController to prevent optimizations which might occlude the layers behind
        mLauncher.getDepthController().setHasContentBehindLauncher(state.overviewUi);
        mLauncher.getDepthController().setHasContentBehindLauncher(state.overviewUi);


        if (isSplitSelectionState(state)) {
        handleSplitSelectionState(state, null);
            mRecentsView.applySplitPrimaryScrollOffset();
        } else {
            mRecentsView.resetSplitPrimaryScrollOffset();
        }
    }
    }


    @Override
    @Override
@@ -92,27 +93,60 @@ public final class RecentsViewStateController extends
        builder.addListener(AnimatorListeners.forSuccessCallback(() ->
        builder.addListener(AnimatorListeners.forSuccessCallback(() ->
                mLauncher.getDepthController().setHasContentBehindLauncher(toState.overviewUi)));
                mLauncher.getDepthController().setHasContentBehindLauncher(toState.overviewUi)));


        // Create or dismiss split screen select animations
        handleSplitSelectionState(toState, builder);

        setAlphas(builder, config, toState);
        builder.setFloat(mRecentsView, FULLSCREEN_PROGRESS,
                toState.getOverviewFullscreenProgress(), LINEAR);
    }

    /**
     * Create or dismiss split screen select animations.
     * @param builder if null then this will run the split select animations right away, otherwise
     *                will add animations to builder.
     */
    private void handleSplitSelectionState(@NonNull LauncherState toState,
            @Nullable PendingAnimation builder) {
        LauncherState currentState = mLauncher.getStateManager().getState();
        LauncherState currentState = mLauncher.getStateManager().getState();
        if (isSplitSelectionState(toState) && !isSplitSelectionState(currentState)) {
        boolean animate = builder != null;
            builder.add(mRecentsView.createSplitSelectInitAnimation().buildAnim());
        PagedOrientationHandler orientationHandler =
                ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
        Pair<FloatProperty, FloatProperty> taskViewsFloat =
                orientationHandler.getSplitSelectTaskOffset(
                        TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION,
                        mLauncher.getDeviceProfile());

        if (isSplitSelectionState(currentState, toState)) {
            // Animation to "dismiss" selected taskView
            PendingAnimation splitSelectInitAnimation =
                    mRecentsView.createSplitSelectInitAnimation();
            // Add properties to shift remaining taskViews to get out of placeholder view
            splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.first,
                    toState.getSplitSelectTranslation(mLauncher), LINEAR);
            splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.second, 0, LINEAR);

            if (!animate && isSplitSelectionState(currentState, toState)) {
                splitSelectInitAnimation.buildAnim().start();
            } else if (animate &&
                    isSplitSelectionState(currentState, toState)) {
                builder.add(splitSelectInitAnimation.buildAnim());
            }
            }
        if (isSplitSelectionState(toState)) {
        }

        if (isSplitSelectionState(currentState, toState)) {
            mRecentsView.applySplitPrimaryScrollOffset();
            mRecentsView.applySplitPrimaryScrollOffset();
        } else {
        } else {
            mRecentsView.resetSplitPrimaryScrollOffset();
            mRecentsView.resetSplitPrimaryScrollOffset();
        }
        }

        setAlphas(builder, config, toState);
        builder.setFloat(mRecentsView, FULLSCREEN_PROGRESS,
                toState.getOverviewFullscreenProgress(), LINEAR);
    }
    }


    /**
    /**
     * @return true if {@param toState} is {@link LauncherState#OVERVIEW_SPLIT_SELECT}
     * @return true if {@param toState} is {@link LauncherState#OVERVIEW_SPLIT_SELECT}
     *          and {@param fromState} is not {@link LauncherState#OVERVIEW_SPLIT_SELECT}
     */
     */
    private boolean isSplitSelectionState(@NonNull LauncherState toState) {
    private boolean isSplitSelectionState(@NonNull LauncherState fromState,
        return toState == OVERVIEW_SPLIT_SELECT;
            @NonNull LauncherState toState) {
        return fromState != OVERVIEW_SPLIT_SELECT && toState == OVERVIEW_SPLIT_SELECT;
    }
    }


    private void setAlphas(PropertySetter propertySetter, StateAnimationConfig config,
    private void setAlphas(PropertySetter propertySetter, StateAnimationConfig config,
+1 −0
Original line number Original line Diff line number Diff line
@@ -242,6 +242,7 @@ public interface TaskShortcutFactory {
        }
        }
    }
    }


    /** @Deprecated */
    TaskShortcutFactory SPLIT_SCREEN = new MultiWindowFactory(R.drawable.ic_split_screen,
    TaskShortcutFactory SPLIT_SCREEN = new MultiWindowFactory(R.drawable.ic_split_screen,
            R.string.recent_task_option_split_screen, LAUNCHER_SYSTEM_SHORTCUT_SPLIT_SCREEN_TAP) {
            R.string.recent_task_option_split_screen, LAUNCHER_SYSTEM_SHORTCUT_SPLIT_SCREEN_TAP) {


+0 −7
Original line number Original line Diff line number Diff line
@@ -64,7 +64,6 @@ public class SplitSelectStateController {
    private @StagePosition int mStagePosition;
    private @StagePosition int mStagePosition;
    private Task mInitialTask;
    private Task mInitialTask;
    private Task mSecondTask;
    private Task mSecondTask;
    private Rect mInitialBounds;
    private boolean mRecentsAnimationRunning;
    private boolean mRecentsAnimationRunning;
    /** If not null, this is the TaskView we want to launch from */
    /** If not null, this is the TaskView we want to launch from */
    @Nullable
    @Nullable
@@ -86,7 +85,6 @@ public class SplitSelectStateController {
            Rect initialBounds) {
            Rect initialBounds) {
        mInitialTask = task;
        mInitialTask = task;
        mStagePosition = stagePosition;
        mStagePosition = stagePosition;
        mInitialBounds = initialBounds;
    }
    }


    /**
    /**
@@ -229,7 +227,6 @@ public class SplitSelectStateController {
        mInitialTask = null;
        mInitialTask = null;
        mSecondTask = null;
        mSecondTask = null;
        mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
        mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
        mInitialBounds = null;
        mRecentsAnimationRunning = false;
        mRecentsAnimationRunning = false;
        mLaunchingTaskView = null;
        mLaunchingTaskView = null;
    }
    }
@@ -241,8 +238,4 @@ public class SplitSelectStateController {
    public boolean isSplitSelectActive() {
    public boolean isSplitSelectActive() {
        return mInitialTask != null && mSecondTask == null;
        return mInitialTask != null && mSecondTask == null;
    }
    }

    public Rect getInitialBounds() {
        return mInitialBounds;
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -3994,7 +3994,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    }
    }


    /** TODO(b/181707736) More gracefully handle exiting split selection state */
    /** TODO(b/181707736) More gracefully handle exiting split selection state */
    private void resetFromSplitSelectionState() {
    protected void resetFromSplitSelectionState() {
        if (mSplitHiddenTaskViewIndex == -1) {
        if (mSplitHiddenTaskViewIndex == -1) {
            return;
            return;
        }
        }