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

Commit f898b970 authored by Tony Wickham's avatar Tony Wickham
Browse files

Call onLauncherTransitionPrepare() and End() from pinch.

This makes the pinch transition more consistent with other transitions.
One immediate benefit of this is that it updates adjacent overview
panels during pinch, regardless of whether they are completely visible.

Previously the adjacent panels' alphas weren't always reset to 0.
Specifically, if you made a small pinch from workspace, which
canceled and went back to workspace, adjacent pages retained a
slightly visible panel.

Bug: 27676309
Change-Id: I7e79fddec31cd649e0811e4524b9a9a501c627f9
parent 8f7ead3e
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -524,11 +524,13 @@ public class LauncherStateTransitionAnimation {
        // Cancel the current animation
        cancelAnimation();

        boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages;

        playCommonTransitionAnimations(toWorkspaceState, fromWorkspace, null,
                animated, animated, animation, revealDuration, layerViews);

        if (animated) {
            dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, true);
            dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, multiplePagesVisible);

            final AnimatorSet stateAnimation = animation;
            final Runnable startAnimRunnable = new Runnable() {
@@ -577,7 +579,7 @@ public class LauncherStateTransitionAnimation {
            fromWorkspace.post(startAnimRunnable);
            mCurrentAnimation = animation;
        } else /* if (!animated) */ {
            dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, true);
            dispatchOnLauncherTransitionPrepare(fromWorkspace, animated, multiplePagesVisible);
            dispatchOnLauncherTransitionStart(fromWorkspace, animated, true);
            dispatchOnLauncherTransitionEnd(fromWorkspace, animated, true);

@@ -615,6 +617,8 @@ public class LauncherStateTransitionAnimation {
        // Cancel the current animation
        cancelAnimation();

        boolean multiplePagesVisible = toWorkspaceState.hasMultipleVisiblePages;

        playCommonTransitionAnimations(toWorkspaceState, fromView, toView,
                animated, initialized, animation, revealDuration, layerViews);

@@ -725,8 +729,8 @@ public class LauncherStateTransitionAnimation {
                }
            }

            dispatchOnLauncherTransitionPrepare(fromView, animated, true);
            dispatchOnLauncherTransitionPrepare(toView, animated, true);
            dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible);
            dispatchOnLauncherTransitionPrepare(toView, animated, multiplePagesVisible);

            animation.addListener(new AnimatorListenerAdapter() {
                @Override
@@ -789,10 +793,10 @@ public class LauncherStateTransitionAnimation {
            return animation;
        } else /* if (!(animated && initialized)) */ {
            fromView.setVisibility(View.GONE);
            dispatchOnLauncherTransitionPrepare(fromView, animated, true);
            dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible);
            dispatchOnLauncherTransitionStart(fromView, animated, true);
            dispatchOnLauncherTransitionEnd(fromView, animated, true);
            dispatchOnLauncherTransitionPrepare(toView, animated, true);
            dispatchOnLauncherTransitionPrepare(toView, animated, multiplePagesVisible);
            dispatchOnLauncherTransitionStart(toView, animated, true);
            dispatchOnLauncherTransitionEnd(toView, animated, true);
            pCb.onTransitionComplete();
@@ -809,10 +813,11 @@ public class LauncherStateTransitionAnimation {
    /**
     * Dispatches the prepare-transition event to suitable views.
     */
    void dispatchOnLauncherTransitionPrepare(View v, boolean animated, boolean toWorkspace) {
    void dispatchOnLauncherTransitionPrepare(View v, boolean animated,
            boolean multiplePagesVisible) {
        if (v instanceof LauncherTransitionable) {
            ((LauncherTransitionable) v).onLauncherTransitionPrepare(mLauncher, animated,
                    toWorkspace);
                    multiplePagesVisible);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ package com.android.launcher3;
 * An interface to get callbacks during a launcher transition.
 */
public interface LauncherTransitionable {
    void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean toWorkspace);
    void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean multiplePagesVisible);
    void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace);
    void onLauncherTransitionStep(Launcher l, float t);
    void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace);
+14 −17
Original line number Diff line number Diff line
@@ -51,10 +51,10 @@ public class PinchAnimationManager {
    private static final int THRESHOLD_ANIM_DURATION = 150;
    private static final LinearInterpolator INTERPOLATOR = new LinearInterpolator();

    private static int INDEX_PAGE_INDICATOR = 0;
    private static int INDEX_HOTSEAT = 1;
    private static int INDEX_OVERVIEW_PANEL_BUTTONS = 2;
    private static int INDEX_SCRIM = 3;
    private static final int INDEX_PAGE_INDICATOR = 0;
    private static final int INDEX_HOTSEAT = 1;
    private static final int INDEX_OVERVIEW_PANEL_BUTTONS = 2;
    private static final int INDEX_SCRIM = 3;

    private final Animator[] mAnimators = new Animator[4];

@@ -107,6 +107,7 @@ public class PinchAnimationManager {
            public void onAnimationEnd(Animator animation) {
                mIsAnimating = false;
                thresholdManager.reset();
                mWorkspace.onLauncherTransitionEnd(mLauncher, false, true);
            }
        });
        animator.setDuration(duration).start();
@@ -129,10 +130,6 @@ public class PinchAnimationManager {
        mWorkspace.setScaleY(interpolatedScale);
        mWorkspace.setTranslationY(interpolatedTranslationY);
        setOverviewPanelsAlpha(1f - interpolatedProgress, 0);

        // Make sure adjacent pages, except custom content page, are visible while scaling.
        mWorkspace.setCustomContentVisibility(View.INVISIBLE);
        mWorkspace.invalidate();
    }

    /**
@@ -168,7 +165,7 @@ public class PinchAnimationManager {
            // Passing threshold 3 ends the pinch and snaps to the new state.
            if (startState == OVERVIEW && goingTowards == NORMAL) {
                mLauncher.showWorkspace(true);
                mWorkspace.snapToPage(mWorkspace.getPageNearestToCenterOfScreen());
                mWorkspace.snapToPage(mWorkspace.getCurrentPage());
            } else if (startState == NORMAL && goingTowards == OVERVIEW) {
                mLauncher.showOverviewMode(true);
            }
+2 −2
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
        mInterpolator = mWorkspace.isInOverviewMode() ? new LogDecelerateInterpolator(100, 0)
                : new LogAccelerateInterpolator(100, 0);
        mPinchStarted = true;
        mWorkspace.onLauncherTransitionPrepare(mLauncher, false, true);
        return true;
    }

@@ -137,6 +138,7 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
                    mThresholdManager);
        } else {
            mThresholdManager.reset();
            mWorkspace.onLauncherTransitionEnd(mLauncher, false, true);
        }
        mPinchStarted = false;
        mPinchCanceled = false;
@@ -206,6 +208,4 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
        mPreviousTimeMillis = System.currentTimeMillis();
        return false;
    }


}
 No newline at end of file
+16 −15
Original line number Diff line number Diff line
@@ -179,18 +179,21 @@ public class Workspace extends PagedView
    // in all apps or customize mode)

    enum State {
        NORMAL          (SearchDropTargetBar.State.SEARCH_BAR, false),
        NORMAL_HIDDEN   (SearchDropTargetBar.State.INVISIBLE_TRANSLATED, false),
        SPRING_LOADED   (SearchDropTargetBar.State.DROP_TARGET, false),
        OVERVIEW        (SearchDropTargetBar.State.INVISIBLE, true),
        OVERVIEW_HIDDEN (SearchDropTargetBar.State.INVISIBLE, true);
        NORMAL          (SearchDropTargetBar.State.SEARCH_BAR, false, false),
        NORMAL_HIDDEN   (SearchDropTargetBar.State.INVISIBLE_TRANSLATED, false, false),
        SPRING_LOADED   (SearchDropTargetBar.State.DROP_TARGET, false, true),
        OVERVIEW        (SearchDropTargetBar.State.INVISIBLE, true, true),
        OVERVIEW_HIDDEN (SearchDropTargetBar.State.INVISIBLE, true, false);

        public final SearchDropTargetBar.State searchDropTargetBarState;
        public final boolean shouldUpdateWidget;
        public final boolean hasMultipleVisiblePages;

        State(SearchDropTargetBar.State searchBarState, boolean shouldUpdateWidget) {
        State(SearchDropTargetBar.State searchBarState, boolean shouldUpdateWidget,
                boolean hasMultipleVisiblePages) {
            searchDropTargetBarState = searchBarState;
            this.shouldUpdateWidget = shouldUpdateWidget;
            this.hasMultipleVisiblePages = hasMultipleVisiblePages;
        }
    }

@@ -1921,11 +1924,6 @@ public class Workspace extends PagedView
        // Update the current state
        mState = toState;
        updateAccessibilityFlags();
        if (mState == State.OVERVIEW || mState == State.SPRING_LOADED) {
            // Redraw pages, as we might want to draw pages which were not visible.
            mForceDrawAdjacentPages = true;
            invalidate(); // This will call dispatchDraw(), which calls getVisiblePages().
        }

        if (shouldNotifyWidgetChange) {
            mLauncher.notifyWidgetProvidersChanged();
@@ -1978,12 +1976,15 @@ public class Workspace extends PagedView
    }

    @Override
    public void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean toWorkspace) {
    public void onLauncherTransitionPrepare(Launcher l, boolean animated,
            boolean multiplePagesVisible) {
        mIsSwitchingState = true;
        mTransitionProgress = 0;

        // Invalidate here to ensure that the pages are rendered during the state change transition.
        invalidate();
        if (multiplePagesVisible) {
            mForceDrawAdjacentPages = true;
        }
        invalidate(); // This will call dispatchDraw(), which calls getVisiblePages().

        updateChildrenLayersEnabled(false);
        hideCustomContentIfNecessary();
Loading