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

Commit 1907cd47 authored by Winson Chung's avatar Winson Chung
Browse files

Adding fallback transition for animating in/out of affiliate groups.

parent 69b07859
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -213,6 +213,9 @@
    <!-- The height of the lock-to-app button. -->
    <!-- The height of the lock-to-app button. -->
    <dimen name="recents_task_view_lock_to_app_button_height">48dp</dimen>
    <dimen name="recents_task_view_lock_to_app_button_height">48dp</dimen>


    <!-- The amount to offset when animating into an affiliate group. -->
    <dimen name="recents_task_view_affiliate_group_enter_offset">64dp</dimen>

    <!-- The height of a task view bar. -->
    <!-- The height of a task view bar. -->
    <dimen name="recents_task_bar_height">56dp</dimen>
    <dimen name="recents_task_bar_height">56dp</dimen>


+3 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,7 @@ public class RecentsConfiguration {
    public int taskViewTranslationZIncrementPx;
    public int taskViewTranslationZIncrementPx;
    public int taskViewRoundedCornerRadiusPx;
    public int taskViewRoundedCornerRadiusPx;
    public int taskViewHighlightPx;
    public int taskViewHighlightPx;
    public int taskViewAffiliateGroupEnterOffsetPx;


    /** Task bar colors */
    /** Task bar colors */
    public int taskBarViewDefaultBackgroundColor;
    public int taskBarViewDefaultBackgroundColor;
@@ -210,6 +211,8 @@ public class RecentsConfiguration {
        taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min);
        taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min);
        taskViewTranslationZIncrementPx =
        taskViewTranslationZIncrementPx =
                res.getDimensionPixelSize(R.dimen.recents_task_view_z_increment);
                res.getDimensionPixelSize(R.dimen.recents_task_view_z_increment);
        taskViewAffiliateGroupEnterOffsetPx =
                res.getDimensionPixelSize(R.dimen.recents_task_view_affiliate_group_enter_offset);


        // Task bar colors
        // Task bar colors
        taskBarViewDefaultBackgroundColor =
        taskBarViewDefaultBackgroundColor =
+12 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,18 @@ public class TaskGrouping {
        return mTaskKeyIndices.get(t.key);
        return mTaskKeyIndices.get(t.key);
    }
    }


    /** Returns whether a task is in this grouping. */
    public boolean containsTask(Task t) {
        return mTaskKeyIndices.containsKey(t.key);
    }

    /** Returns whether one task is above another in the group.  If they are not in the same group,
     * this returns false. */
    public boolean isTaskAboveTask(Task t, Task below) {
        return mTaskKeyIndices.containsKey(t.key) && mTaskKeyIndices.containsKey(below.key) &&
                mTaskKeyIndices.get(t.key) > mTaskKeyIndices.get(below.key);
    }

    /** Returns the number of tasks in this group. */
    /** Returns the number of tasks in this group. */
    public int getTaskCount() { return mTaskKeys.size(); }
    public int getTaskCount() { return mTaskKeys.size(); }


+1 −1
Original line number Original line Diff line number Diff line
@@ -449,7 +449,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
        if (tv == null) {
        if (tv == null) {
            post(launchRunnable);
            post(launchRunnable);
        } else {
        } else {
            stackView.animateOnLaunchingTask(tv, launchRunnable);
            stackView.startLaunchTaskAnimation(tv, launchRunnable);
        }
        }
    }
    }


+54 −22
Original line number Original line Diff line number Diff line
@@ -495,20 +495,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        }
        }
    }
    }


    /** Animates a task view in this stack as it launches. */
    public void animateOnLaunchingTask(TaskView tv, final Runnable r) {
        // Hide each of the task bar dismiss buttons
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            TaskView t = (TaskView) getChildAt(i);
            if (t == tv) {
                t.startLaunchTaskAnimation(r, true);
            } else {
                t.startLaunchTaskAnimation(null, false);
            }
        }
    }

    /** Focuses the task at the specified index in the stack */
    /** Focuses the task at the specified index in the stack */
    void focusTask(int taskIndex, boolean scrollToNewPosition) {
    void focusTask(int taskIndex, boolean scrollToNewPosition) {
        if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
        if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
@@ -664,13 +650,28 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal


    /** Handler for the first layout. */
    /** Handler for the first layout. */
    void onFirstLayout() {
    void onFirstLayout() {
        // Prepare the first view for its enter animation
        int offscreenY = mStackAlgorithm.mViewRect.bottom -
        int offscreenY = mStackAlgorithm.mViewRect.bottom -
                (mStackAlgorithm.mTaskRect.top - mStackAlgorithm.mViewRect.top);
                (mStackAlgorithm.mTaskRect.top - mStackAlgorithm.mViewRect.top);

        // Find the launch target task
        Task launchTargetTask = null;
        int childCount = getChildCount();
        int childCount = getChildCount();
        for (int i = childCount - 1; i >= 0; i--) {
        for (int i = childCount - 1; i >= 0; i--) {
            TaskView tv = (TaskView) getChildAt(i);
            TaskView tv = (TaskView) getChildAt(i);
            tv.prepareEnterRecentsAnimation(tv.getTask().isLaunchTarget, offscreenY);
            Task task = tv.getTask();
            if (task.isLaunchTarget) {
                launchTargetTask = task;
                break;
            }
        }

        // Prepare the first view for its enter animation
        for (int i = childCount - 1; i >= 0; i--) {
            TaskView tv = (TaskView) getChildAt(i);
            Task task = tv.getTask();
            boolean occludesLaunchTarget = (launchTargetTask != null) &&
                    launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
            tv.prepareEnterRecentsAnimation(task.isLaunchTarget, occludesLaunchTarget, offscreenY);
        }
        }


        // If the enter animation started already and we haven't completed a layout yet, do the
        // If the enter animation started already and we haven't completed a layout yet, do the
@@ -698,8 +699,19 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        }
        }


        if (mStack.getTaskCount() > 0) {
        if (mStack.getTaskCount() > 0) {
            // Animate all the task views into view
            // Find the launch target task
            Task launchTargetTask = null;
            int childCount = getChildCount();
            int childCount = getChildCount();
            for (int i = childCount - 1; i >= 0; i--) {
                TaskView tv = (TaskView) getChildAt(i);
                Task task = tv.getTask();
                if (task.isLaunchTarget) {
                    launchTargetTask = task;
                    break;
                }
            }

            // Animate all the task views into view
            for (int i = childCount - 1; i >= 0; i--) {
            for (int i = childCount - 1; i >= 0; i--) {
                TaskView tv = (TaskView) getChildAt(i);
                TaskView tv = (TaskView) getChildAt(i);
                Task task = tv.getTask();
                Task task = tv.getTask();
@@ -707,6 +719,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                ctx.currentStackViewIndex = i;
                ctx.currentStackViewIndex = i;
                ctx.currentStackViewCount = childCount;
                ctx.currentStackViewCount = childCount;
                ctx.currentTaskRect = mStackAlgorithm.mTaskRect;
                ctx.currentTaskRect = mStackAlgorithm.mTaskRect;
                ctx.currentTaskOccludesLaunchTarget = (launchTargetTask != null) &&
                        launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
                mStackAlgorithm.getStackTransform(task, getStackScroll(), ctx.currentTaskTransform);
                mStackAlgorithm.getStackTransform(task, getStackScroll(), ctx.currentTaskTransform);
                tv.startEnterRecentsAnimation(ctx);
                tv.startEnterRecentsAnimation(ctx);
            }
            }
@@ -717,11 +731,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                public void run() {
                public void run() {
                    // Start dozing
                    // Start dozing
                    mUIDozeTrigger.startDozing();
                    mUIDozeTrigger.startDozing();
                    // Request an update of the task views after the animation in to 
                    // relayout the fullscreen view back to its normal size
                    if (mConfig.launchedFromAppWithScreenshot) {
                        requestSynchronizeStackViewsWithModel();
                    }
                }
                }
            });
            });
        }
        }
@@ -742,6 +751,24 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        ctx.postAnimationTrigger.addLastDecrementRunnable(mReturnAllViewsToPoolRunnable);
        ctx.postAnimationTrigger.addLastDecrementRunnable(mReturnAllViewsToPoolRunnable);
    }
    }


    /** Animates a task view in this stack as it launches. */
    public void startLaunchTaskAnimation(TaskView tv, final Runnable r) {
        Task launchTargetTask = tv.getTask();
        int offscreenTranslationY = mStackAlgorithm.mViewRect.bottom -
                (mStackAlgorithm.mTaskRect.top - mStackAlgorithm.mViewRect.top);
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            TaskView t = (TaskView) getChildAt(i);
            if (t == tv) {
                t.startLaunchTaskAnimation(r, true, true);
            } else {
                boolean occludesLaunchTarget = launchTargetTask.group.isTaskAboveTask(t.getTask(),
                        launchTargetTask);
                t.startLaunchTaskAnimation(null, false, occludesLaunchTarget);
            }
        }
    }

    @Override
    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        super.onScrollChanged(l, t, oldl, oldt);
@@ -988,6 +1015,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        invalidate(mStackAlgorithm.mStackRect);
        invalidate(mStackAlgorithm.mStackRect);
    }
    }


    @Override
    public void onTaskViewFullScreenTransitionCompleted() {
        requestSynchronizeStackViewsWithModel();
    }

    /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/
    /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/


    @Override
    @Override
Loading