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

Commit 49cb49b1 authored by Pat Manning's avatar Pat Manning
Browse files

End drag touch event when crossing task drag threshold, and only when task is...

End drag touch event when crossing task drag threshold, and only when task is going up (drag to dismiss)

Test: manual
Fix: 188618115
Bug: 188618115
Change-Id: I51d157e224eaeee34ed131e4945bb92d6baf18cd
parent 23cf59bf
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -45,8 +45,9 @@

    <!-- These speeds are in dp/s -->
    <dimen name="max_task_dismiss_drag_velocity">2.25dp</dimen>
    <dimen name="default_task_dismiss_drag_velocity">1.75dp</dimen>
    <dimen name="default_task_dismiss_drag_velocity_grid">0.75dp</dimen>
    <dimen name="default_task_dismiss_drag_velocity">1.5dp</dimen>
    <dimen name="default_task_dismiss_drag_velocity_grid">1dp</dimen>
    <dimen name="default_task_dismiss_drag_velocity_grid_focus_task">5dp</dimen>

    <dimen name="recents_page_spacing">16dp</dimen>
    <dimen name="recents_clear_all_deadzone_vertical_margin">70dp</dimen>
+36 −12
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;
@@ -72,6 +73,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
    private float mProgressMultiplier;
    private float mEndDisplacement;
    private FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck();
    private Float mOverrideVelocity = null;

    private TaskView mTaskBeingDragged;

@@ -268,6 +270,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
            mCurrentAnimation.pause();
        }
        mFlingBlockCheck.unblockFling();
        mOverrideVelocity = null;
    }

    @Override
@@ -283,19 +286,36 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
            mFlingBlockCheck.onEvent();
        }

        // Once halfway through task dismissal interpolation, switch from reversible dragging-task
        // animation to playing the remaining task translation animations
        if (isGoingUp) {
            if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) {
            // Halve the value as we are animating the drag across the full length for only the
            // first half of the progress
                // Halve the value when dismissing, as we are animating the drag across the full
                // length for only the first half of the progress
                mCurrentAnimation.setPlayFraction(
                        Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1));
            } else {
            float dragVelocity = -mTaskBeingDragged.getResources().getDimension(
                    mRecentsView.showAsGrid() ? R.dimen.default_task_dismiss_drag_velocity_grid
                            : R.dimen.default_task_dismiss_drag_velocity);
            onDragEnd(dragVelocity);
            return true;
                // Set mOverrideVelocity to control task dismiss velocity in onDragEnd
                int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity;
                if (mRecentsView.showAsGrid()) {
                    if (mTaskBeingDragged.isFocusedTask()) {
                        velocityDimenId =
                                R.dimen.default_task_dismiss_drag_velocity_grid_focus_task;
                    } else {
                        velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid;
                    }
                }
                mOverrideVelocity = -mTaskBeingDragged.getResources().getDimension(velocityDimenId);

                // Once halfway through task dismissal interpolation, switch from reversible
                // dragging-task animation to playing the remaining task translation animations
                final long now = SystemClock.uptimeMillis();
                MotionEvent upAction = MotionEvent.obtain(now, now,
                        MotionEvent.ACTION_UP, 0.0f, 0.0f, 0);
                mDetector.onTouchEvent(upAction);
                upAction.recycle();
            }
        } else {
            mCurrentAnimation.setPlayFraction(
                    Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1));
        }

        return true;
@@ -303,6 +323,10 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>

    @Override
    public void onDragEnd(float velocity) {
        if (mOverrideVelocity != null) {
            velocity = mOverrideVelocity;
            mOverrideVelocity = null;
        }
        // Limit velocity, as very large scalar values make animations play too quickly
        float maxTaskDismissDragVelocity = mTaskBeingDragged.getResources().getDimension(
                R.dimen.max_task_dismiss_drag_velocity);