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

Commit 610af375 authored by Jon Miranda's avatar Jon Miranda Committed by Jonathan Miranda
Browse files

Add springs when user clicks on caret / all apps snaps to top.

Bug: 65373058
Change-Id: I9cc5c4c98fd3e5b53d597c4493f2dcef6d9be94a
parent 20218280
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -424,6 +424,9 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
        // The amount by which each adjacent rows' stiffness will differ.
        private static final float ROW_STIFFNESS_COEFFICIENT = 50f;

        // The percentage by which we multiply each row to create the row factor.
        private static final float ROW_PERCENTAGE = 0.3f;

        @Override
        public SpringAnimation initialize(ViewHolder vh) {
            return SpringAnimationHandler.forView(vh.itemView, DynamicAnimation.TRANSLATION_Y, 0);
@@ -462,7 +465,7 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
         * effect.
         */
        private void calculateSpringValues(SpringAnimation spring, int row, int col) {
            float rowFactor = (1 + row) * 0.5f;
            float rowFactor = (1 + row) * ROW_PERCENTAGE;
            float colFactor = getColumnFactor(col, mAppsPerRow);

            float minValue = DEFAULT_MIN_VALUE_PX * (rowFactor + colFactor);
+20 −0
Original line number Diff line number Diff line
@@ -394,6 +394,11 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect
        animationOut.play(driftAndAlpha);

        animationOut.addListener(new AnimatorListenerAdapter() {
            // Spring values used when the user has not flung all apps.
            private final float MAX_RELEASE_VELOCITY = 10000;
            // The delay (as a % of the animation duration) to start the springs.
            private final float DELAY = 0.3f;

            boolean canceled = false;

            @Override
@@ -401,6 +406,21 @@ public class AllAppsTransitionController implements TouchController, SwipeDetect
                canceled = true;
            }

            @Override
            public void onAnimationStart(Animator animation) {
                // Add springs for cases where the user has not flung.
                // ie. clicking on the caret, releasing all apps so it snaps up.
                mAppsView.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (!canceled && !mSpringAnimationHandler.isRunning()) {
                            float velocity = mProgress * MAX_RELEASE_VELOCITY;
                            mSpringAnimationHandler.animateToPositionWithVelocity(0, 1, velocity);
                        }
                    }
                }, (long) (mAnimationDuration * DELAY));
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (canceled) {