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

Commit 74b5af35 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Fixes to all apps pull up work

b/28917826

- 2+ workspace page also slides up
- pull up touch interaction doesn't trigger only when yslop > xslop
- animation duration should be set independently when all apps button is used.
- workspace state is correctly set (drag and drop from the trays work)
- after lock screen, hotseat is positioned correctly
- Remove initial jump when sliding up
- Improved tuning on sliding
- Alpha value set differently on backbround and content of all apps

Still not fixed:
- Landscape
- Search edit text box styling
- All apps scroll bar

Change-Id: I817094b0f1ada5052ee604539459f556a99cadf1
parent b7c2e99f
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -248,13 +248,12 @@ public class LauncherStateTransitionAnimation {
        // Cancel the current animation
        cancelAnimation();

        if (!FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);
        }
        final View contentView = toView.getContentView();

        if (!animated || !initialized) {
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);

            toView.setTranslationX(0.0f);
            toView.setTranslationY(0.0f);
            toView.setScaleX(1.0f);
@@ -277,6 +276,9 @@ public class LauncherStateTransitionAnimation {
            return null;
        }
        if (animType == CIRCULAR_REVEAL) {
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);

            // Setup the reveal view animation
            final View revealView = toView.getRevealView();

@@ -421,9 +423,10 @@ public class LauncherStateTransitionAnimation {
                      cleanupAnimation();
                      pCb.onTransitionComplete();
                  }

            });
            mAllAppsController.animateToAllApps(animation);
            mAllAppsController.animateToAllApps(animation, revealDuration);
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);

            dispatchOnLauncherTransitionPrepare(fromView, animated, false);
            dispatchOnLauncherTransitionPrepare(toView, animated, false);
@@ -672,11 +675,9 @@ public class LauncherStateTransitionAnimation {

        boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages;

        if (!FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
        if (!animated || !initialized) {
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);
        }
        if (!animated || !initialized) {
            if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
                mAllAppsController.finishPullDown();
            }
@@ -697,6 +698,8 @@ public class LauncherStateTransitionAnimation {
            return null;
        }
        if (animType == CIRCULAR_REVEAL) {
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);
            final View revealView = fromView.getRevealView();
            final View contentView = fromView.getContentView();

@@ -876,7 +879,9 @@ public class LauncherStateTransitionAnimation {
                }

            });
            mAllAppsController.animateToWorkspace(animation);
            mAllAppsController.animateToWorkspace(animation, revealDuration);
            playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                    animated, initialized, animation, revealDuration, layerViews);

            // Dispatch the prepare transition signal
            dispatchOnLauncherTransitionPrepare(fromView, animated, false);
+1 −1
Original line number Diff line number Diff line
@@ -1971,7 +1971,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
        snapToPage(getPageNearestToCenterOfScreen(), PAGE_SNAP_ANIMATION_DURATION);
    }

    private static class ScrollInterpolator implements Interpolator {
    public static class ScrollInterpolator implements Interpolator {
        public ScrollInterpolator() {
        }

+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.allapps;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
@@ -450,6 +451,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
            mSearchInput.setLayoutParams(llp);

            lp.height = height;
            mSearchContainer.setBackground(null);
        }
        mSearchContainer.setLayoutParams(lp);
    }
+41 −27
Original line number Diff line number Diff line
@@ -8,12 +8,16 @@ import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import com.android.launcher3.CellLayout;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.PagedView;
import com.android.launcher3.util.TouchController;

/**
@@ -31,7 +35,10 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
    private static final String TAG = "AllAppsTrans";
    private static final boolean DBG = false;

    private static final float ANIMATION_DURATION = 500;
     private final Interpolator mAccelInterpolator = new AccelerateInterpolator(1f);

    private static final float ANIMATION_DURATION = 2000;
    private static final float FINAL_ALPHA = .6f;

    private AllAppsContainerView mAppsView;
    private Hotseat mHotseat;
@@ -48,7 +55,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
    private float mProgressTransY;   // numerator
    private float mTranslation = -1; // denominator

    private float mAnimationDuration;
    private long mAnimationDuration;
    private float mCurY;

    private AnimatorSet mCurrentAnimation;
@@ -84,8 +91,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
        }
        mAppsView = mLauncher.getAppsView();
        mHotseat = mLauncher.getHotseat();
        mWorkspaceCurPage = mLauncher.getWorkspace().getChildAt(
                mLauncher.getWorkspace().getCurrentPage());

        if (mHotseatBackground == null) {
            mHotseatBackground = mHotseat.getBackground();
@@ -97,21 +102,27 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
    public void onScrollStart(boolean start) {
        cancelAnimation();
        mCurrentAnimation = LauncherAnimUtils.createAnimatorSet();
        mCurY = mAppsView.getTranslationY();
        preparePull(start);

        mCurY = mAppsView.getTranslationY();
    }

    /**
     * @param start {@code true} if start of new drag.
     */
    public void preparePull(boolean start) {
        // TODO: create a method inside workspace to fetch this easily.
        mWorkspaceCurPage = mLauncher.getWorkspace().getChildAt(
                mLauncher.getWorkspace().getNextPage());
        mHotseat.setVisibility(View.VISIBLE);
        mHotseat.bringToFront();
        if (start) {
            if (!mLauncher.isAllAppsVisible()) {
                mHotseat.setBackground(null);
                mAppsView.setVisibility(View.VISIBLE);
                mAppsView.getContentView().setVisibility(View.VISIBLE);
                mAppsView.setAlpha(mHotseatAlpha);
                mAppsView.getContentView().setBackground(null);
                mAppsView.getRevealView().setVisibility(View.VISIBLE);
                mAppsView.getRevealView().setAlpha(mHotseatAlpha);
                mAppsView.setSearchBarVisible(false);

                if (mTranslation < 0) {
@@ -119,16 +130,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
                    setProgress(mTranslation);
                }
            } else {
                mLauncher.getWorkspace().setVisibility(View.VISIBLE);
                mLauncher.getWorkspace().setAlpha(1f);
                mLauncher.getWorkspace().onLauncherTransitionPrepare(mLauncher, false, false);
                mWorkspaceCurPage.setVisibility(View.VISIBLE);
                ((CellLayout) mWorkspaceCurPage).getShortcutsAndWidgets().setVisibility(View.VISIBLE);
                ((CellLayout) mWorkspaceCurPage).getShortcutsAndWidgets().setAlpha(1f);
                mAppsView.setSearchBarVisible(false);
                setLightStatusBar(false);
            }
        }
        mHotseat.setVisibility(View.VISIBLE);
        mHotseat.bringToFront();
    }

    private void setLightStatusBar(boolean enable) {
@@ -144,8 +153,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
        }
    }

    private final Interpolator mAlphaInterpolator = new DecelerateInterpolator(.5f);

    @Override
    public boolean onScroll(float displacement, float velocity) {
        if (mAppsView == null) {
@@ -163,9 +170,12 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
    public void setProgress(float progress) {
        mProgressTransY = progress;
        float alpha = calcAlphaAllApps(progress);
        float workspaceHotseatAlpha = Math.max(mHotseatAlpha, 1 - alpha);
        setTransAndAlpha(mAppsView, progress, Math.max(mHotseatAlpha, alpha));
        setTransAndAlpha(mWorkspaceCurPage, -mTranslation + progress, workspaceHotseatAlpha);
        float workspaceHotseatAlpha = 1 - alpha;

        mAppsView.getRevealView().setAlpha(Math.min(FINAL_ALPHA, Math.max(mHotseatAlpha, alpha)));
        mAppsView.getContentView().setAlpha(alpha);
        mAppsView.setTranslationY(progress);
        setTransAndAlpha(mWorkspaceCurPage, -mTranslation + progress, mAccelInterpolator.getInterpolation(workspaceHotseatAlpha));
        setTransAndAlpha(mHotseat, -mTranslation + progress, workspaceHotseatAlpha);
    }

@@ -174,7 +184,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
    }

    private float calcAlphaAllApps(float progress) {
        return mAlphaInterpolator.getInterpolation((mTranslation - progress)/mTranslation);
        return ((mTranslation - progress)/mTranslation);
    }

    private void setTransAndAlpha(View v, float transY, float alpha) {
@@ -212,11 +222,11 @@ public class AllAppsTransitionController implements TouchController, VerticalPul

    private void calculateDuration(float velocity, float disp) {
        // TODO: make these values constants after tuning.
        float velocityDivisor = Math.max(1, 0.75f * velocity);
        float velocityDivisor = Math.max(1.5f, Math.abs(0.25f * velocity));
        float travelDistance = Math.max(0.2f, disp / mTranslation);
        mAnimationDuration = Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
        if (true) { // MERONG
            Log.d(TAG, String.format("calculateDuration=%f, v=%f, d=%f", mAnimationDuration, velocity, disp));
        mAnimationDuration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
        if (DBG) {
            Log.d(TAG, String.format("calculateDuration=%d, v=%f, d=%f", mAnimationDuration, velocity, disp));
        }
    }

@@ -227,7 +237,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
     */
    private void showAppsView() {
        if (mLauncher.isAllAppsVisible()) {
            animateToAllApps(mCurrentAnimation);
            animateToAllApps(mCurrentAnimation, mAnimationDuration);
            mCurrentAnimation.start();
        } else {
            mLauncher.showAppsView(true /* animated */, true /* resetListToTop */,
@@ -244,17 +254,18 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
        if (mLauncher.isAllAppsVisible()) {
            mLauncher.showWorkspace(true /* animated */);
        } else {
            animateToWorkspace(mCurrentAnimation);
            animateToWorkspace(mCurrentAnimation, mAnimationDuration);
            mCurrentAnimation.start();
        }
    }

    public void animateToAllApps(AnimatorSet animationOut) {
    public void animateToAllApps(AnimatorSet animationOut, long duration) {
        if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
            return;
        }
        if (!mDetector.mScrolling) {
            preparePull(true);
            mAnimationDuration = duration;
        }
        mCurY = mAppsView.getTranslationY();
        final float fromAllAppsTop = mAppsView.getTranslationY();
@@ -262,7 +273,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul

        ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
                fromAllAppsTop, toAllAppsTop);
        driftAndAlpha.setDuration((long) mAnimationDuration);
        driftAndAlpha.setDuration(mAnimationDuration);
        driftAndAlpha.setInterpolator(new PagedView.ScrollInterpolator());
        animationOut.play(driftAndAlpha);

        animationOut.addListener(new AnimatorListenerAdapter() {
@@ -291,19 +303,21 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
        setLightStatusBar(true);
    }

    public void animateToWorkspace(AnimatorSet animationOut) {
    public void animateToWorkspace(AnimatorSet animationOut, long duration) {
        if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
            return;
        }
        if(!mDetector.mScrolling) {
            preparePull(true);
            mAnimationDuration = duration;
        }
        final float fromAllAppsTop = mAppsView.getTranslationY();
        final float toAllAppsTop = mTranslation;

        ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
                fromAllAppsTop, toAllAppsTop);
        driftAndAlpha.setDuration((long) mAnimationDuration);
        driftAndAlpha.setDuration(mAnimationDuration);
        driftAndAlpha.setInterpolator(new PagedView.ScrollInterpolator());
        animationOut.play(driftAndAlpha);

        animationOut.addListener(new AnimatorListenerAdapter() {
+26 −13
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ public class VerticalPullDetector {
    /**
     * The minimum release velocity in pixels per millisecond that triggers fling..
     */
    private static final float RELEASE_VELOCITY_PX_MS = 1.7f;
    private static final float RELEASE_VELOCITY_PX_MS = 1.0f;

    /**
     * The time constant used to calculate dampening in the low-pass filter of scroll velocity.
@@ -32,7 +32,7 @@ public class VerticalPullDetector {
    /* Scroll state, this is set to true during dragging and animation. */
    boolean mScrolling;


    float mDownX;
    float mDownY;
    float mDownMillis;

@@ -41,7 +41,8 @@ public class VerticalPullDetector {

    float mVelocity;
    float mLastDisplacement;
    float mDisplacement;
    float mDisplacementY;
    float mDisplacementX;

    /* scroll started during previous animation */
    boolean mSubtractSlop = true;
@@ -72,12 +73,18 @@ public class VerticalPullDetector {
    }

    private boolean shouldScrollStart() {
        if (mAllAppsVisible && mDisplacement > mTouchSlop && mAllAppsScrollAtTop) {
        float deltaY = Math.abs(mDisplacementY);
        float deltaX = Math.max(Math.abs(mDisplacementX), 1);
        if (mAllAppsVisible && mDisplacementY > mTouchSlop && mAllAppsScrollAtTop) {
            if (deltaY > deltaX) {
                return true;
            }
        if (!mAllAppsVisible && mDisplacement < -mTouchSlop) {
        }
        if (!mAllAppsVisible && mDisplacementY < -mTouchSlop) {
            if (deltaY > deltaX) {
                return true;
            }
        }
        return false;
    }

@@ -85,6 +92,7 @@ public class VerticalPullDetector {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mDownMillis = ev.getDownTime();
                mDownX = ev.getX();
                mDownY = ev.getY();
                mLastDisplacement = 0;
                mVelocity = 0;
@@ -94,7 +102,8 @@ public class VerticalPullDetector {
                }
                break;
            case MotionEvent.ACTION_MOVE:
                mDisplacement = computeDisplacement(ev);
                mDisplacementX = ev.getX() - mDownX;
                mDisplacementY = ev.getY() - mDownY;
                mVelocity = computeVelocity(ev, mVelocity);

                if (!mScrolling && shouldScrollStart()) {
@@ -117,7 +126,7 @@ public class VerticalPullDetector {
                break;
        }
        // Do house keeping.
        mLastDisplacement = mDisplacement;
        mLastDisplacement = mDisplacementY;

        mLastY = ev.getY();
        mLastMillis = ev.getEventTime();
@@ -138,13 +147,17 @@ public class VerticalPullDetector {
    }

    private boolean reportScroll() {
        float delta = mDisplacement - mLastDisplacement;
        float delta = mDisplacementY - mLastDisplacement;
        if (delta != 0) {
            if (DBG) {
                Log.d(TAG, String.format("onScroll disp=%.1f, velocity=%.1f",
                        mDisplacement, mVelocity));
                        mDisplacementY, mVelocity));
            }
            if (mDisplacementY > 0) {
                return mListener.onScroll(mDisplacementY - mTouchSlop, mVelocity);
            } else {
                return mListener.onScroll(mDisplacementY + mTouchSlop, mVelocity);
            }
            return mListener.onScroll(mDisplacement - (mSubtractSlop? mTouchSlop : 0), mVelocity);
        }
        return true;
    }
@@ -152,7 +165,7 @@ public class VerticalPullDetector {
    private void reportScrollEnd() {
        if (DBG) {
            Log.d(TAG, String.format("onScrolEnd disp=%.1f, velocity=%.1f",
                    mDisplacement, mVelocity));
                    mDisplacementY, mVelocity));
        }
        mListener.onScrollEnd(mVelocity, Math.abs(mVelocity) > RELEASE_VELOCITY_PX_MS);
    }