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

Commit d2ad9798 authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "All apps motion" into sc-dev

parents de268a51 54a44d4c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@
    <dimen name="all_apps_header_tab_height">48dp</dimen>
    <dimen name="all_apps_tabs_indicator_height">2dp</dimen>
    <dimen name="all_apps_header_top_padding">36dp</dimen>
    <dimen name="all_apps_header_bottom_padding">16dp</dimen>
    <dimen name="all_apps_header_bottom_padding">6dp</dimen>
    <dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
    <dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
    <dimen name="all_apps_tabs_vertical_padding">6dp</dimen>
+14 −17
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCU
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
@@ -81,10 +83,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
        ScrimView.ScrimDrawingController {

    public static final float PULL_MULTIPLIER = .02f;
    public static final float FLING_VELOCITY_MULTIPLIER = 2000f;

    // Starts the springs after at least 25% of the animation has passed.
    public static final float FLING_ANIMATION_THRESHOLD = 0.25f;
    public static final float FLING_VELOCITY_MULTIPLIER = 1200f;

    private final Paint mHeaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

@@ -645,20 +644,18 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
    /**
     * Adds an update listener to {@param animator} that adds springs to the animation.
     */
    public void addSpringFromFlingUpdateListener(ValueAnimator animator, float velocity) {
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            boolean shouldSpring = true;

    public void addSpringFromFlingUpdateListener(ValueAnimator animator,
            float velocity /* release velocity */,
            float progress /* portion of the distance to travel*/) {
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                if (shouldSpring
                        && valueAnimator.getAnimatedFraction() >= FLING_ANIMATION_THRESHOLD) {
                    absorbSwipeUpVelocity(Math.max(100, Math.abs(
                            Math.round(velocity * FLING_VELOCITY_MULTIPLIER))));
                    // calculate the velocity of using the not user controlled interpolator
                    // of when the container reach the end.
                    shouldSpring = false;
                }
            public void onAnimationStart(Animator animator) {
                float distance = (float) ((1 - progress) * getHeight()); // px
                float settleVelocity = Math.min(0, distance
                        / (AllAppsTransitionController.INTERP_COEFF * animator.getDuration())
                        + velocity);
                absorbSwipeUpVelocity(Math.max(1000, Math.abs(
                        Math.round(settleVelocity * FLING_VELOCITY_MULTIPLIER))));
            }
        });
    }
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ import com.android.launcher3.views.ScrimView;
 */
public class AllAppsTransitionController
        implements StateHandler<LauncherState>, OnDeviceProfileChangeListener {
    // This constant should match the second derivative of the animator interpolator.
    public static final float INTERP_COEFF = 1.7f;
    private static final float CONTENT_VISIBLE_MAX_THRESHOLD = 0.5f;

    public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PROGRESS =
+1 −3
Original line number Diff line number Diff line
@@ -335,12 +335,10 @@ public abstract class AbstractStateChangeTouchController
        mCurrentAnimation.dispatchOnStart();
        if (targetState == LauncherState.ALL_APPS && !UNSTABLE_SPRINGS.get()) {
            if (mAllAppsOvershootStarted) {

                mLauncher.getAppsView().onRelease();
                mAllAppsOvershootStarted = false;

            } else {
                mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
                mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity, progress);
            }
        }
        anim.start();