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

Commit 7ab650cb authored by Winson Chung's avatar Winson Chung
Browse files

Adding start delay to the task view transforms.

- Adding slight delay to task bar buttons to allow touch feedback to show

Change-Id: I9f31ca378541fc34c7b741840c7f038340684b13
parent c6543afd
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -46,9 +46,7 @@
    <color name="keyguard_overflow_content_color">#ff686868</color>

    <!-- The default recents task bar background color. -->
    <color name="recents_task_bar_default_background_color">#e6444444</color>
    <!-- The default recents task bar text color. -->
    <color name="recents_task_bar_default_text_color">#ffeeeeee</color>
    <color name="recents_task_bar_default_background_color">#ffe6e6e6</color>
    <!-- The recents task bar light text color to be drawn on top of dark backgrounds. -->
    <color name="recents_task_bar_light_text_color">#ffeeeeee</color>
    <!-- The recents task bar dark text color to be drawn on top of light backgrounds. -->
+0 −3
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ public class RecentsConfiguration {

    /** Task bar colors */
    public int taskBarViewDefaultBackgroundColor;
    public int taskBarViewDefaultTextColor;
    public int taskBarViewLightTextColor;
    public int taskBarViewDarkTextColor;
    public int taskBarViewHighlightColor;
@@ -202,8 +201,6 @@ public class RecentsConfiguration {
        // Task bar colors
        taskBarViewDefaultBackgroundColor =
                res.getColor(R.color.recents_task_bar_default_background_color);
        taskBarViewDefaultTextColor =
                res.getColor(R.color.recents_task_bar_default_text_color);
        taskBarViewLightTextColor =
                res.getColor(R.color.recents_task_bar_light_text_color);
        taskBarViewDarkTextColor =
+7 −9
Original line number Diff line number Diff line
@@ -151,16 +151,14 @@ class TaskBarView extends FrameLayout {
        mActivityDescription.setText(t.activityLabel);
        // Try and apply the system ui tint
        int tint = t.colorPrimary;
        if (Constants.DebugFlags.App.EnableTaskBarThemeColors && tint != 0) {
        if (!Constants.DebugFlags.App.EnableTaskBarThemeColors || tint == 0) {
            tint = mConfig.taskBarViewDefaultBackgroundColor;
        }
        setBackgroundColor(tint);
        mActivityDescription.setTextColor(Utilities.getIdealColorForBackgroundColor(tint,
                mConfig.taskBarViewLightTextColor, mConfig.taskBarViewDarkTextColor));
        mDismissButton.setImageDrawable(Utilities.getIdealResourceForBackgroundColor(tint,
                mLightDismissDrawable, mDarkDismissDrawable));
        } else {
            setBackgroundColor(mConfig.taskBarViewDefaultBackgroundColor);
            mActivityDescription.setTextColor(mConfig.taskBarViewDefaultTextColor);
        }
    }

    /** Unbinds the bar view from the task */
+12 −16
Original line number Diff line number Diff line
@@ -973,7 +973,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    int getExitTransformsForFilterAnimation(ArrayList<Task> curTasks,
                        ArrayList<TaskViewTransform> curTaskTransforms,
                        ArrayList<Task> tasks, ArrayList<TaskViewTransform> taskTransforms,
                        HashMap<TaskView, Pair<Integer, TaskViewTransform>> childViewTransformsOut,
                        HashMap<TaskView, TaskViewTransform> childViewTransformsOut,
                        ArrayList<TaskView> childrenToRemoveOut) {
        // Animate all of the existing views out of view (if they are not in the visible range in
        // the new stack) or to their final positions in the new stack
@@ -1003,9 +1003,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                        (int) tv.getTranslationY()));
            }

            int startDelay = offset *
                    Constants.Values.TaskStackView.FilterStartDelay;
            childViewTransformsOut.put(tv, new Pair(startDelay, toTransform));
            toTransform.startDelay = offset * Constants.Values.TaskStackView.FilterStartDelay;
            childViewTransformsOut.put(tv, toTransform);
            offset++;
        }
        return mConfig.filteringCurrentViewsAnimDuration;
@@ -1017,7 +1016,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
     */
    int getEnterTransformsForFilterAnimation(ArrayList<Task> tasks,
                         ArrayList<TaskViewTransform> taskTransforms,
                         HashMap<TaskView, Pair<Integer, TaskViewTransform>> childViewTransformsOut) {
                         HashMap<TaskView, TaskViewTransform> childViewTransformsOut) {
        int offset = 0;
        int movement = 0;
        int taskCount = tasks.size();
@@ -1035,9 +1034,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                    tv.prepareTaskTransformForFilterTaskHidden(fromTransform);
                    tv.updateViewPropertiesToTaskTransform(fromTransform, 0);

                    int startDelay = offset *
                            Constants.Values.TaskStackView.FilterStartDelay;
                    childViewTransformsOut.put(tv, new Pair(startDelay, toTransform));
                    toTransform.startDelay = offset * Constants.Values.TaskStackView.FilterStartDelay;
                    childViewTransformsOut.put(tv, toTransform);

                    // Use the movement of the new views to calculate the duration of the animation
                    movement = Math.max(movement,
@@ -1057,8 +1055,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        // Calculate the transforms to animate out all the existing views if they are not in the
        // new visible range (or to their final positions in the stack if they are)
        final ArrayList<TaskView> childrenToRemove = new ArrayList<TaskView>();
        final HashMap<TaskView, Pair<Integer, TaskViewTransform>> childViewTransforms =
                new HashMap<TaskView, Pair<Integer, TaskViewTransform>>();
        final HashMap<TaskView, TaskViewTransform> childViewTransforms =
                new HashMap<TaskView, TaskViewTransform>();
        int duration = getExitTransformsForFilterAnimation(curTasks, curTaskTransforms, tasks,
                taskTransforms, childViewTransforms, childrenToRemove);

@@ -1073,10 +1071,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal

        // Animate all the views to their final transforms
        for (final TaskView tv : childViewTransforms.keySet()) {
            Pair<Integer, TaskViewTransform> t = childViewTransforms.get(tv);
            TaskViewTransform t = childViewTransforms.get(tv);
            tv.animate().cancel();
            tv.animate()
                    .setStartDelay(t.first)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
@@ -1093,15 +1090,14 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                                    int duration = getEnterTransformsForFilterAnimation(tasks,
                                            taskTransforms, childViewTransforms);
                                    for (final TaskView tv : childViewTransforms.keySet()) {
                                        Pair<Integer, TaskViewTransform> t = childViewTransforms.get(tv);
                                        tv.animate().setStartDelay(t.first);
                                        tv.updateViewPropertiesToTaskTransform(t.second, duration);
                                        TaskViewTransform t = childViewTransforms.get(tv);
                                        tv.updateViewPropertiesToTaskTransform(t, duration);
                                    }
                                }
                            }
                        }
                    });
            tv.updateViewPropertiesToTaskTransform(t.second, duration);
            tv.updateViewPropertiesToTaskTransform(t, duration);
        }
    }

+20 −13
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
            if (useLayers) {
                anim.withLayer();
            }
            anim.setStartDelay(0)
            anim.setStartDelay(toTransform.startDelay)
                .setDuration(duration)
                .setInterpolator(mConfig.fastOutSlowInInterpolator)
                .start();
@@ -248,6 +248,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
        // Fade the view out and slide it away
        toTransform.alpha = 0f;
        toTransform.translationY += 200;
        toTransform.translationZ = 0;
    }

    /**
@@ -585,12 +586,16 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
    }

    @Override
    public void onClick(View v) {
    public void onClick(final View v) {
        // We purposely post the handler delayed to allow for the touch feedback to draw
        final TaskView tv = this;
        postDelayed(new Runnable() {
            @Override
            public void run() {
                if (v == mBarView.mApplicationIcon) {
            mCb.onTaskIconClicked(this);
                    mCb.onTaskIconClicked(tv);
                } else if (v == mBarView.mDismissButton) {
                    // Animate out the view and call the callback
            final TaskView tv = this;
                    startDeleteTaskAnimation(new Runnable() {
                        @Override
                        public void run() {
@@ -599,6 +604,8 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
                    });
                }
            }
        }, 125);
    }

    @Override
    public boolean onLongClick(View v) {
Loading