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

Commit 8aa99594 authored by Winson's avatar Winson
Browse files

Starting the dismiss animation in parallel with the gesture.

- Introduces notion of ignored tasks for the purposes of layout in 
  TaskStackView.  This can be used during drag and drop, and while 
  dismissing to calculate the state of the stack without the task that
  the user is currently interacting with.
- Fixing minor layout issue when the front/back task transforms are 
  improperly calculated when there is a single task
- Fixing minor issue when the anchor task is calculated incorrectly when
  dismissing task views

Change-Id: I1eb0864a52e53562e4d573a6ed4f8a5a1615aff9
parent b7a73360
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@

    <!-- Recents: The relative range of visible tasks from the current scroll position
         while the stack is focused. -->
    <item name="recents_layout_focused_range_min" format="float" type="integer">-4</item>
    <item name="recents_layout_focused_range_min" format="float" type="integer">-3</item>
    <item name="recents_layout_focused_range_max" format="float" type="integer">3</item>

    <!-- Recents: The relative range of visible tasks from the current scroll position
+1 −1
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@

    <!-- Recents: The relative range of visible tasks from the current scroll position
         while the stack is focused. -->
    <item name="recents_layout_focused_range_min" format="float" type="integer">-4</item>
    <item name="recents_layout_focused_range_min" format="float" type="integer">-3</item>
    <item name="recents_layout_focused_range_max" format="float" type="integer">3</item>

    <!-- Recents: The relative range of visible tasks from the current scroll position
+11 −2
Original line number Diff line number Diff line
@@ -367,6 +367,7 @@ public class SwipeHelper implements Gefingerpoken {
        }
        anim.addListener(new AnimatorListenerAdapter() {
            public void onAnimationEnd(Animator animation) {
                updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed);
                mCallback.onChildDismissed(view);
                if (endAction != null) {
                    endAction.run();
@@ -381,9 +382,17 @@ public class SwipeHelper implements Gefingerpoken {
                updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed);
            }
        });
        prepareDismissAnimation(animView, anim);
        anim.start();
    }

    /**
     * Called to update the dismiss animation.
     */
    protected void prepareDismissAnimation(View view, Animator anim) {
        // Do nothing
    }

    public void snapChild(final View view, float velocity) {
        final View animView = mCallback.getChildContentView(view);
        final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(animView);
@@ -401,14 +410,14 @@ public class SwipeHelper implements Gefingerpoken {
                mCallback.onChildSnappedBack(animView);
            }
        });
        updateSnapBackAnimation(anim);
        prepareSnapBackAnimation(animView, anim);
        anim.start();
    }

    /**
     * Called to update the snap back animation.
     */
    protected void updateSnapBackAnimation(Animator anim) {
    protected void prepareSnapBackAnimation(View view, Animator anim) {
        // Do nothing
    }

+3 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.TaskViewAnimation;

import java.util.ArrayList;
import java.util.Calendar;
@@ -268,8 +269,8 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd

    public void onTaskRemoved(Task task, int position) {
        // Since this is removed from the history, we need to update the stack as well to ensure
        // that the model is correct
        mStack.removeTask(task);
        // that the model is correct. Since the stack is hidden, we can update it immediately.
        mStack.removeTask(task, TaskViewAnimation.IMMEDIATE);
        removeTaskRow(position);
        if (mRows.isEmpty()) {
            dismissHistory();
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.systemui.recents.misc;

import android.animation.TypeEvaluator;
import android.graphics.RectF;

/**
 * This evaluator can be used to perform type interpolation between <code>RectF</code> values.
 */
public class RectFEvaluator implements TypeEvaluator<RectF> {

    private RectF mRect = new RectF();

    /**
     * This function returns the result of linearly interpolating the start and
     * end Rect values, with <code>fraction</code> representing the proportion
     * between the start and end values. The calculation is a simple parametric
     * calculation on each of the separate components in the Rect objects
     * (left, top, right, and bottom).
     *
     * <p>The object returned will be the <code>reuseRect</code> passed into the constructor.</p>
     *
     * @param fraction   The fraction from the starting to the ending values
     * @param startValue The start Rect
     * @param endValue   The end Rect
     * @return A linear interpolation between the start and end values, given the
     *         <code>fraction</code> parameter.
     */
    @Override
    public RectF evaluate(float fraction, RectF startValue, RectF endValue) {
        float left = startValue.left + ((endValue.left - startValue.left) * fraction);
        float top = startValue.top + ((endValue.top - startValue.top) * fraction);
        float right = startValue.right + ((endValue.right - startValue.right) * fraction);
        float bottom = startValue.bottom + ((endValue.bottom - startValue.bottom) * fraction);
        mRect.set(left, top, right, bottom);
        return mRect;
    }
}
Loading