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

Commit 5bce6619 authored by Jonathan Miranda's avatar Jonathan Miranda Committed by Android (Google) Code Review
Browse files

Merge "Use AllAppsTransitionController to animate the hotseat & scrim." into ub-launcher3-master

parents d17862c4 701b0f52
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -37,6 +37,4 @@
    <!-- Launcher app transition -->
    <dimen name="content_trans_y">25dp</dimen>
    <dimen name="workspace_trans_y">80dp</dimen>

    <dimen name="shelf_min_value">-2.857dp</dimen>
</resources>
+26 −27
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.launcher3;

import static com.android.launcher3.views.AllAppsScrim.SCRIM_PROGRESS;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.systemui.shared.recents.utilities.Utilities.getNextFrameNumber;
import static com.android.systemui.shared.recents.utilities.Utilities.getSurface;
import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously;
@@ -40,9 +40,9 @@ import android.view.animation.Interpolator;
import android.widget.ImageView;

import com.android.launcher3.InsettableFrameLayout.LayoutParams;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.views.AllAppsScrim;
import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
@@ -62,14 +62,16 @@ public class LauncherAppTransitionManager {

    private static final int CLOSING_TRANSITION_DURATION_MS = 350;

    // Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
    private static final float ALL_APPS_PROGRESS_START = 1.3059858f;
    private static final float ALL_APPS_PROGRESS_SLIDE_END = 0.99581414f;

    private final DragLayer mDragLayer;
    private final Launcher mLauncher;
    private final DeviceProfile mDeviceProfile;

    private final float mContentTransY;
    private final float mWorkspaceTransY;
    // The smallest y-value the shelf will reach on screen, before overshooting back down to 0.
    private final float mShelfMinValue;

    private ImageView mFloatingView;
    private boolean mIsRtl;
@@ -84,7 +86,6 @@ public class LauncherAppTransitionManager {
        Resources res = launcher.getResources();
        mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y);
        mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y);
        mShelfMinValue = res.getDimensionPixelSize(R.dimen.shelf_min_value);
    }

    /**
@@ -477,31 +478,29 @@ public class LauncherAppTransitionManager {
            workspaceAnimator.setDuration(333);
            workspaceAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);

            // Animate the shelf
            AllAppsScrim allAppsScrim = mLauncher.findViewById(R.id.all_apps_scrim);
            View hotseat = mLauncher.getHotseat();
            final float endY = mShelfMinValue;
            int startY = hotseat.getMeasuredHeight()
                    + (allAppsScrim.getShadowBitmap().getHeight() / 2);
            hotseat.setTranslationY(startY);
            allAppsScrim.setTranslationY(startY);

            AnimatorSet hotseatSlideIn = new AnimatorSet();
            hotseatSlideIn.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, startY, endY));
            hotseatSlideIn.play(ObjectAnimator.ofFloat(allAppsScrim, SCRIM_PROGRESS, startY, endY));
            hotseatSlideIn.setStartDelay(150);
            hotseatSlideIn.setDuration(317);
            hotseatSlideIn.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);

            AnimatorSet hotseatOvershoot = new AnimatorSet();
            hotseatOvershoot.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, endY, 0));
            hotseatOvershoot.play(ObjectAnimator.ofFloat(allAppsScrim, SCRIM_PROGRESS, endY, 0));
            hotseatOvershoot.setDuration(153);
            hotseatOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
            // Animate the shelf in two parts: slide in, and overeshoot.
            AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
            // The shelf will start offscreen
            final float startY = ALL_APPS_PROGRESS_START;
            // And will end slightly pulled up, so that there is something to overshoot back to 1f.
            final float slideEnd = ALL_APPS_PROGRESS_SLIDE_END;

            allAppsController.setProgress(startY);

            Animator allAppsSlideIn =
                    ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, startY, slideEnd);
            allAppsSlideIn.setStartDelay(150);
            allAppsSlideIn.setDuration(317);
            allAppsSlideIn.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);

            Animator allAppsOvershoot =
                    ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, slideEnd, 1f);
            allAppsOvershoot.setDuration(153);
            allAppsOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);

            AnimatorSet resumeLauncherAnimation = new AnimatorSet();
            resumeLauncherAnimation.play(workspaceAnimator);
            resumeLauncherAnimation.playSequentially(hotseatSlideIn, hotseatOvershoot);
            resumeLauncherAnimation.playSequentially(allAppsSlideIn, allAppsOvershoot);
            return resumeLauncherAnimation;
        }
    }
+4 −3
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ import com.android.launcher3.views.AllAppsScrim;
public class AllAppsTransitionController
        implements SearchUiManager.OnScrollRangeChangeListener, LauncherStateManager.StateHandler {

    private static final Property<AllAppsTransitionController, Float> PROGRESS =
            new Property<AllAppsTransitionController, Float>(Float.class, "progress") {
    public static final Property<AllAppsTransitionController, Float> ALL_APPS_PROGRESS =
            new Property<AllAppsTransitionController, Float>(Float.class, "allAppsProgress") {

        @Override
        public Float get(AllAppsTransitionController controller) {
@@ -164,7 +164,8 @@ public class AllAppsTransitionController
        }

        Interpolator interpolator = config.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
        ObjectAnimator anim = ObjectAnimator.ofFloat(this, PROGRESS, mProgress, targetProgress);
        ObjectAnimator anim =
                ObjectAnimator.ofFloat(this, ALL_APPS_PROGRESS, mProgress, targetProgress);
        anim.setDuration(config.duration);
        anim.setInterpolator(interpolator);
        anim.addListener(getProgressAnimatorListener());
+5 −29
Original line number Diff line number Diff line
@@ -61,25 +61,11 @@ public class AllAppsScrim extends View implements OnChangeListener, Insettable {

    private final NinePatchDrawHelper mShadowHelper = new NinePatchDrawHelper();

    private float mProgress;
    private int mFillAlpha;

    private float mDrawHeight;
    private float mDrawOffsetY;

    public static final Property<AllAppsScrim, Float> SCRIM_PROGRESS =
            new Property<AllAppsScrim, Float>(Float.class, "allAppsScrimProgress") {
                @Override
                public Float get(AllAppsScrim allAppsScrim) {
                    return allAppsScrim.getProgress();
                }

                @Override
                public void set(AllAppsScrim allAppsScrim, Float progress) {
                    allAppsScrim.setProgress(progress);
                }
            };

    public AllAppsScrim(Context context) {
        this(context, null);
    }
@@ -174,23 +160,17 @@ public class AllAppsScrim extends View implements OnChangeListener, Insettable {

    public void setProgress(float translateY, float alpha) {
        int newAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
        if (newAlpha != mFillAlpha) {
            mFillAlpha = newAlpha;
            mFillPaint.setAlpha(mFillAlpha);
            invalidateDrawRect();
        }

        setProgress(translateY);
    }

    public void setProgress(float translateY) {
        // Negative translation means the scrim is moving up. For negative translation, we change
        // draw offset as it requires redraw (since more area of the scrim needs to be shown). For
        // position translation, we simply translate the scrim down as it avoids invalidate and
        // hence could be optimized by the platform.
        float drawOffsetY = Math.min(translateY, 0);

        if (drawOffsetY != mDrawOffsetY) {
        if (newAlpha != mFillAlpha || drawOffsetY != mDrawOffsetY) {
            invalidateDrawRect();

            mFillAlpha = newAlpha;
            mFillPaint.setAlpha(mFillAlpha);
            mDrawOffsetY = drawOffsetY;
            invalidateDrawRect();
        }
@@ -198,10 +178,6 @@ public class AllAppsScrim extends View implements OnChangeListener, Insettable {
        setTranslationY(Math.max(translateY, 0));
    }

    public float getProgress() {
        return mProgress;
    }

    private void invalidateDrawRect() {
        mDrawRect.top = (int) (getHeight()
                + mDrawOffsetY - mDrawHeight + mPadding.top - mShadowBlur - 0.5f);