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

Commit cabbaf98 authored by Jon Miranda's avatar Jon Miranda
Browse files

Fix bug where floating icon and workspace icon visible at the same time.

- Add a signal for the animation to be "cancelled"
- Allow the workspace view to be attached to a spring during the animatoin
  (but kept hidden) to prevent any jumpy movement

Bug: 137215697
Change-Id: Ie6868a7f45fefaee5366c8d30bb323fe042e9156
parent ddf64806
Loading
Loading
Loading
Loading
+60 −24
Original line number Diff line number Diff line
@@ -871,7 +871,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    @UiThread
    private InputConsumer createNewInputProxyHandler() {
        endRunningWindowAnim();
        endRunningWindowAnim(true /* cancel */);
        endLauncherTransitionController();
        if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            // Hide the task view, if not already hidden
@@ -883,11 +883,15 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
                ? InputConsumer.NO_OP : new OverviewInputConsumer(activity, null, true);
    }

    private void endRunningWindowAnim() {
    private void endRunningWindowAnim(boolean cancel) {
        if (mRunningWindowAnim != null) {
            if (cancel) {
                mRunningWindowAnim.cancel();
            } else {
                mRunningWindowAnim.end();
            }
        }
    }

    private GestureEndTarget calculateEndTarget(PointF velocity, float endVelocity, boolean isFling,
            boolean isCancel) {
@@ -1177,7 +1181,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
        // We want the window alpha to be 0 once this threshold is met, so that the
        // FolderIconView can be seen morphing into the icon shape.
        final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
        anim.addOnUpdateListener((currentRect, progress) -> {
        anim.addOnUpdateListener(new RectFSpringAnim.OnUpdateListener() {
            @Override
            public void onUpdate(RectF currentRect, float progress) {
                homeAnim.setPlayFraction(progress);

                float alphaProgress = ACCEL_1_5.getInterpolation(progress);
@@ -1198,6 +1204,14 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
                }

                updateSysUiFlags(Math.max(progress, mCurrentShift.value));
            }

            @Override
            public void onCancel() {
                if (isFloatingIconView) {
                    ((FloatingIconView) floatingView).fastFinish();
                }
            }
        });
        anim.addAnimatorListener(new AnimationSuccessListener() {
            @Override
@@ -1306,7 +1320,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
    }

    private void invalidateHandler() {
        endRunningWindowAnim();
        endRunningWindowAnim(false /* cancel */);

        if (mGestureEndCallback != null) {
            mGestureEndCallback.run();
@@ -1471,12 +1485,34 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
    private interface RunningWindowAnim {
        void end();

        void cancel();

        static RunningWindowAnim wrap(Animator animator) {
            return animator::end;
            return new RunningWindowAnim() {
                @Override
                public void end() {
                    animator.end();
                }

                @Override
                public void cancel() {
                    animator.cancel();
                }
            };
        }

        static RunningWindowAnim wrap(RectFSpringAnim rectFSpringAnim) {
            return rectFSpringAnim::end;
            return new RunningWindowAnim() {
                @Override
                public void end() {
                    rectFSpringAnim.end();
                }

                @Override
                public void cancel() {
                    rectFSpringAnim.cancel();
                }
            };
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -225,7 +225,18 @@ public class RectFSpringAnim {
        }
    }

    public void cancel() {
        if (mAnimsStarted) {
            for (OnUpdateListener onUpdateListener : mOnUpdateListeners) {
                onUpdateListener.onCancel();
            }
        }
        end();
    }

    public interface OnUpdateListener {
        void onUpdate(RectF currentRect, float progress);

        void onCancel();
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -134,10 +134,6 @@ public class StaggeredWorkspaceAnim {
     * @param totalRows Total number of rows.
     */
    private void addStaggeredAnimationForView(View v, int row, int totalRows) {
        if (v == mViewToIgnore) {
            return;
        }

        // Invert the rows, because we stagger starting from the bottom of the screen.
        int invertedRow = totalRows - row;
        // Add 1 to the inverted row so that the bottom most row has a start delay.
@@ -149,6 +145,10 @@ public class StaggeredWorkspaceAnim {
        springTransY.setStartDelay(startDelay);
        mAnimators.add(springTransY);

        if (v == mViewToIgnore) {
            return;
        }

        v.setAlpha(0);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(v, View.ALPHA, 0f, 1f);
        alpha.setInterpolator(LINEAR);
+2 −3
Original line number Diff line number Diff line
@@ -656,8 +656,7 @@ public class FloatingIconView extends View implements
        canvas.restoreToCount(count);
    }

    public void onListenerViewClosed() {
        // Fast finish here.
    public void fastFinish() {
        if (mEndRunnable != null) {
            mEndRunnable.run();
            mEndRunnable = null;
@@ -757,7 +756,7 @@ public class FloatingIconView extends View implements
        view.setVisibility(INVISIBLE);
        parent.addView(view);
        dragLayer.addView(view.mListenerView);
        view.mListenerView.setListener(view::onListenerViewClosed);
        view.mListenerView.setListener(view::fastFinish);

        view.mEndRunnable = () -> {
            view.mEndRunnable = null;