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

Commit 50448630 authored by Winson's avatar Winson
Browse files

Tweaking enter from/exit to home animations.

Change-Id: Idedf00457055b6f0268c0f93a0a14c6a553e1168
parent be8e696a
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -159,18 +159,6 @@
         in from the bottom of the screen. -->
    <integer name="recents_enter_from_home_transition_duration">100</integer>

    <!-- The duration for animating the task from the bottom of the screen when transitioning
     from home. -->
    <integer name="recents_task_enter_from_home_duration">225</integer>

    <!-- The stagger for each task when animating the task from the bottom of the screen when 
     transitioning from home. -->
    <integer name="recents_task_enter_from_home_stagger_delay">12</integer>

    <!-- The duration of the animation of the tasks to the bottom of the screen when leaving
     Recents to go back to the Launcher. -->
    <integer name="recents_task_exit_to_home_duration">225</integer>

    <!-- The min animation duration for animating the nav bar scrim in. -->
    <integer name="recents_nav_bar_scrim_enter_duration">400</integer>

+3 −5
Original line number Diff line number Diff line
@@ -531,8 +531,7 @@ public class RecentsView extends FrameLayout {

    public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
        // Hide the history button
        int taskViewExitToHomeDuration = getResources().getInteger(
                R.integer.recents_task_exit_to_home_duration);
        int taskViewExitToHomeDuration = TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION;
        hideHistoryButton(taskViewExitToHomeDuration, false /* translate */);
        animateBackgroundScrim(0f, taskViewExitToHomeDuration);
    }
@@ -647,9 +646,8 @@ public class RecentsView extends FrameLayout {
    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        if (!launchState.launchedFromAppWithThumbnail && mStack.getTaskCount() > 0) {
            int taskViewEnterFromHomeDuration = getResources().getInteger(
                    R.integer.recents_task_enter_from_home_duration);
            animateBackgroundScrim(DEFAULT_SCRIM_ALPHA, taskViewEnterFromHomeDuration);
            animateBackgroundScrim(DEFAULT_SCRIM_ALPHA,
                    TaskStackAnimationHelper.ENTER_FROM_HOME_TRANSLATION_DURATION);
        }
    }

+48 −19
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Path;
import android.graphics.RectF;
import android.view.View;
import android.view.animation.PathInterpolator;

import com.android.systemui.Interpolators;
import com.android.systemui.R;
@@ -63,6 +65,22 @@ public class TaskStackAnimationHelper {
                ReferenceCountedTrigger postAnimationTrigger);
    }

    private static final int FRAME_OFFSET_MS = 16;

    public static final int ENTER_FROM_HOME_ALPHA_DURATION = 100;
    public static final int ENTER_FROM_HOME_TRANSLATION_DURATION = 333;
    private static final PathInterpolator ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR =
            new PathInterpolator(0, 0, 0, 1f);
    private static final PathInterpolator ENTER_FROM_HOME_ALPHA_INTERPOLATOR =
            new PathInterpolator(0, 0, 0.2f, 1f);

    public static final int EXIT_TO_HOME_ALPHA_DURATION = 100;
    public static final int EXIT_TO_HOME_TRANSLATION_DURATION = 150;
    private static final PathInterpolator EXIT_TO_HOME_TRANSLATION_INTERPOLATOR =
            new PathInterpolator(0.8f, 0, 0.6f, 1f);
    private static final PathInterpolator EXIT_TO_HOME_ALPHA_INTERPOLATOR =
            new PathInterpolator(0.4f, 0, 1f, 1f);

    private TaskStackView mStackView;

    private TaskViewTransform mTmpTransform = new TaskViewTransform();
@@ -157,15 +175,12 @@ public class TaskStackAnimationHelper {
                R.integer.recents_task_enter_from_app_duration);
        int taskViewEnterFromAffiliatedAppDuration = res.getInteger(
                R.integer.recents_task_enter_from_affiliated_app_duration);
        int taskViewEnterFromHomeDuration = res.getInteger(
                R.integer.recents_task_enter_from_home_duration);
        int taskViewEnterFromHomeStaggerDelay = res.getInteger(
                R.integer.recents_task_enter_from_home_stagger_delay);

        // Create enter animations for each of the views from front to back
        List<TaskView> taskViews = mStackView.getTaskViews();
        int taskViewCount = taskViews.size();
        for (int i = taskViewCount - 1; i >= 0; i--) {
            int taskIndexFromFront = taskViewCount - i - 1;
            final TaskView tv = taskViews.get(i);
            Task task = tv.getTask();
            boolean currentTaskOccludesLaunchTarget = false;
@@ -202,14 +217,16 @@ public class TaskStackAnimationHelper {

            } else if (launchState.launchedFromHome) {
                // Animate the tasks up
                int frontIndex = (taskViewCount - i - 1);
                int delay = frontIndex * taskViewEnterFromHomeStaggerDelay;
                int duration = taskViewEnterFromHomeDuration +
                        frontIndex * taskViewEnterFromHomeStaggerDelay;

                AnimationProps taskAnimation = new AnimationProps(delay,
                        duration, Interpolators.DECELERATE_QUINT,
                        postAnimationTrigger.decrementOnAnimationEnd());
                AnimationProps taskAnimation = new AnimationProps()
                        .setStartDelay(AnimationProps.ALPHA, taskIndexFromFront * FRAME_OFFSET_MS)
                        .setDuration(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_DURATION)
                        .setDuration(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_DURATION -
                                (taskIndexFromFront * FRAME_OFFSET_MS))
                        .setInterpolator(AnimationProps.BOUNDS,
                                ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR)
                        .setInterpolator(AnimationProps.ALPHA,
                                ENTER_FROM_HOME_ALPHA_INTERPOLATOR)
                        .setListener(postAnimationTrigger.decrementOnAnimationEnd());
                postAnimationTrigger.increment();
                mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
            }
@@ -221,7 +238,6 @@ public class TaskStackAnimationHelper {
     */
    public void startExitToHomeAnimation(boolean animated,
            ReferenceCountedTrigger postAnimationTrigger) {
        Resources res = mStackView.getResources();
        TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
        TaskStackViewScroller stackScroller = mStackView.getScroller();
        TaskStack stack = mStackView.getStack();
@@ -232,19 +248,32 @@ public class TaskStackAnimationHelper {
        }

        int offscreenY = stackLayout.mStackRect.bottom;
        int taskViewExitToHomeDuration = res.getInteger(
                R.integer.recents_task_exit_to_home_duration);

        // Create the animations for each of the tasks
        List<TaskView> taskViews = mStackView.getTaskViews();
        int taskViewCount = taskViews.size();
        for (int i = 0; i < taskViewCount; i++) {
            int taskIndexFromFront = taskViewCount - i - 1;
            TaskView tv = taskViews.get(i);
            Task task = tv.getTask();
            AnimationProps taskAnimation = new AnimationProps(
                    animated ? taskViewExitToHomeDuration : 0, Interpolators.FAST_OUT_LINEAR_IN,
                    postAnimationTrigger.decrementOnAnimationEnd());

            // Animate the tasks down
            AnimationProps taskAnimation;
            if (animated) {
                taskAnimation = new AnimationProps()
                        .setStartDelay(AnimationProps.ALPHA, i * FRAME_OFFSET_MS)
                        .setDuration(AnimationProps.ALPHA, EXIT_TO_HOME_ALPHA_DURATION)
                        .setDuration(AnimationProps.BOUNDS, EXIT_TO_HOME_TRANSLATION_DURATION +
                                (taskIndexFromFront * FRAME_OFFSET_MS))
                        .setInterpolator(AnimationProps.BOUNDS,
                                EXIT_TO_HOME_TRANSLATION_INTERPOLATOR)
                        .setInterpolator(AnimationProps.ALPHA,
                                EXIT_TO_HOME_ALPHA_INTERPOLATOR)
                        .setListener(postAnimationTrigger.decrementOnAnimationEnd());
                postAnimationTrigger.increment();
            } else {
                taskAnimation = AnimationProps.IMMEDIATE;
            }

            stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
                    null);
+1 −2
Original line number Diff line number Diff line
@@ -1558,8 +1558,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        mAnimationHelper.startExitToHomeAnimation(event.animated, event.getAnimationTrigger());

        // Dismiss the freeform workspace background
        int taskViewExitToHomeDuration = getResources().getInteger(
                R.integer.recents_task_exit_to_home_duration);
        int taskViewExitToHomeDuration = TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION;
        animateFreeformWorkspaceBackgroundAlpha(0, new AnimationProps(taskViewExitToHomeDuration,
                Interpolators.FAST_OUT_SLOW_IN));
    }