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

Commit 3f99a144 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Fixing screen jump when going to spring_loaded mode in rtl" into ub-launcher3-master

parents 19795603 ce5a7e5e
Loading
Loading
Loading
Loading
+10 −19
Original line number Diff line number Diff line
@@ -2458,8 +2458,10 @@ public class Launcher extends Activity

        if (v instanceof CellLayout) {
            if (mWorkspace.isInOverviewMode()) {
                showWorkspace(mWorkspace.indexOfChild(v), true);
                mWorkspace.snapToPageFromOverView(mWorkspace.indexOfChild(v));
                showWorkspace(true);
            }
            return;
        }

        Object tag = v.getTag();
@@ -3257,26 +3259,17 @@ public class Launcher extends Activity
    }

    public void showWorkspace(boolean animated) {
        showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated, null);
        showWorkspace(animated, null);
    }

    public void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
        showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated,
                onCompleteRunnable);
    }

    protected void showWorkspace(int snapToPage, boolean animated) {
        showWorkspace(snapToPage, animated, null);
    }

    void showWorkspace(int snapToPage, boolean animated, Runnable onCompleteRunnable) {
        boolean changed = mState != State.WORKSPACE ||
                mWorkspace.getState() != Workspace.State.NORMAL;
        if (changed) {
            boolean wasInSpringLoadedMode = (mState != State.WORKSPACE);
            mWorkspace.setVisibility(View.VISIBLE);
            mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.NORMAL,
                    snapToPage, animated, onCompleteRunnable);
                    animated, onCompleteRunnable);

            // Show the search bar (only animate if we were showing the drop target bar in spring
            // loaded mode)
@@ -3307,8 +3300,7 @@ public class Launcher extends Activity
    void showOverviewMode(boolean animated) {
        mWorkspace.setVisibility(View.VISIBLE);
        mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.OVERVIEW,
                WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated,
                null /* onCompleteRunnable */);
                animated, null /* onCompleteRunnable */);
        mState = State.WORKSPACE;
    }

@@ -3384,11 +3376,11 @@ public class Launcher extends Activity
     * Updates the workspace and interaction state on state change, and return the animation to this
     * new state.
     */
    public Animator startWorkspaceStateChangeAnimation(Workspace.State toState, int toPage,
    public Animator startWorkspaceStateChangeAnimation(Workspace.State toState,
            boolean animated, boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
        Workspace.State fromState = mWorkspace.getState();
        Animator anim = mWorkspace.setStateWithAnimation(toState, toPage, animated,
                hasOverlaySearchBar, layerViews);
        Animator anim = mWorkspace.setStateWithAnimation(
                toState, animated, hasOverlaySearchBar, layerViews);
        updateInteraction(fromState, toState);
        return anim;
    }
@@ -3401,8 +3393,7 @@ public class Launcher extends Activity
        }

        mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.SPRING_LOADED,
                WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, true /* animated */,
                null /* onCompleteRunnable */);
                true /* animated */, null /* onCompleteRunnable */);
        mState = isAppsViewVisible() ? State.APPS_SPRING_LOADED : State.WIDGETS_SPRING_LOADED;
    }

+11 −15
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@ public class LauncherStateTransitionAnimation {
     */
    public void startAnimationToWidgets(final boolean animated) {
        final WidgetsContainerView toView = mLauncher.getWidgetsView();
        final Resources res = mLauncher.getResources();
        PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
            @Override
            public void onRevealViewVisible(View revealView, View contentView,
@@ -217,7 +216,7 @@ public class LauncherStateTransitionAnimation {
     * Starts and animation to the workspace from the current overlay view.
     */
    public void startAnimationToWorkspace(final Launcher.State fromState,
              final Workspace.State toWorkspaceState, final int toWorkspacePage,
              final Workspace.State toWorkspaceState,
              final boolean animated, final Runnable onCompleteRunnable) {
        if (toWorkspaceState != Workspace.State.NORMAL &&
                toWorkspaceState != Workspace.State.SPRING_LOADED &&
@@ -226,11 +225,9 @@ public class LauncherStateTransitionAnimation {
        }

        if (fromState == Launcher.State.APPS || fromState == Launcher.State.APPS_SPRING_LOADED) {
            startAnimationToWorkspaceFromAllApps(toWorkspaceState, toWorkspacePage,
                    animated, onCompleteRunnable);
            startAnimationToWorkspaceFromAllApps(toWorkspaceState, animated, onCompleteRunnable);
        } else {
            startAnimationToWorkspaceFromWidgets(toWorkspaceState, toWorkspacePage,
                    animated, onCompleteRunnable);
            startAnimationToWorkspaceFromWidgets(toWorkspaceState, animated, onCompleteRunnable);
        }
    }

@@ -261,7 +258,7 @@ public class LauncherStateTransitionAnimation {

        // Create the workspace animation.
        // NOTE: this call apparently also sets the state for the workspace if !animated
        Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState, -1,
        Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState,
                animated, overlaySearchBarView != null /* hasOverlaySearchBar */, layerViews);

        if (animated && initialized) {
@@ -447,7 +444,7 @@ public class LauncherStateTransitionAnimation {
     * Starts and animation to the workspace from the apps view.
     */
    private void startAnimationToWorkspaceFromAllApps(final Workspace.State toWorkspaceState,
            final int toWorkspacePage, final boolean animated, final Runnable onCompleteRunnable) {
            final boolean animated, final Runnable onCompleteRunnable) {
        AllAppsContainerView appsView = mLauncher.getAppsView();
        PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
            int[] mAllAppsToPanelDelta;
@@ -499,8 +496,8 @@ public class LauncherStateTransitionAnimation {
            }
        };
        // Only animate the search bar if animating to spring loaded mode from all apps
        startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage, appsView,
                appsView.getContentView(), appsView.getRevealView(), appsView.getSearchBarView(),
        startAnimationToWorkspaceFromOverlay(toWorkspaceState, appsView, appsView.getContentView(),
                appsView.getRevealView(), appsView.getSearchBarView(),
                animated, onCompleteRunnable, cb);
    }

@@ -508,9 +505,8 @@ public class LauncherStateTransitionAnimation {
     * Starts and animation to the workspace from the widgets view.
     */
    private void startAnimationToWorkspaceFromWidgets(final Workspace.State toWorkspaceState,
              final int toWorkspacePage, final boolean animated, final Runnable onCompleteRunnable) {
              final boolean animated, final Runnable onCompleteRunnable) {
        final WidgetsContainerView widgetsView = mLauncher.getWidgetsView();
        final Resources res = mLauncher.getResources();
        PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
            @Override
            public void onRevealViewVisible(View revealView, View contentView,
@@ -535,7 +531,7 @@ public class LauncherStateTransitionAnimation {
                };
            }
        };
        startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage, widgetsView,
        startAnimationToWorkspaceFromOverlay(toWorkspaceState, widgetsView,
                widgetsView.getContentView(), widgetsView.getRevealView(), null, animated,
                onCompleteRunnable, cb);
    }
@@ -544,7 +540,7 @@ public class LauncherStateTransitionAnimation {
     * Creates and starts a new animation to the workspace.
     */
    private void startAnimationToWorkspaceFromOverlay(final Workspace.State toWorkspaceState,
              final int toWorkspacePage, final View fromView, final View contentView,
              final View fromView, final View contentView,
              final View revealView, final View overlaySearchBarView, final boolean animated,
              final Runnable onCompleteRunnable, final PrivateTransitionCallbacks pCb) {
        final Resources res = mLauncher.getResources();
@@ -567,7 +563,7 @@ public class LauncherStateTransitionAnimation {
        // Create the workspace animation.
        // NOTE: this call apparently also sets the state for the workspace if !animated
        Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState,
                toWorkspacePage, animated, overlaySearchBarView != null /* hasOverlaySearchBar */,
                animated, overlaySearchBarView != null /* hasOverlaySearchBar */,
                layerViews);

        if (animated && initialized) {
+22 −6
Original line number Diff line number Diff line
@@ -1820,6 +1820,16 @@ public class Workspace extends PagedView
        updateChildrenLayersEnabled(false);
    }

    @Override
    protected void getVisiblePages(int[] range) {
        super.getVisiblePages(range);
        if (mState == State.OVERVIEW || mState == State.SPRING_LOADED) {
            // In overview mode, make sure that the two side pages are visible.
            range[0] = Math.min(range[0], Math.max(getCurrentPage() - 1, numCustomPages()));
            range[1] = Math.max(range[0], Math.min(getCurrentPage() + 1, getPageCount() - 1));
        }
    }

    protected void onWallpaperTap(MotionEvent ev) {
        final int[] position = mTempXY;
        getLocationOnScreen(position);
@@ -1940,6 +1950,10 @@ public class Workspace extends PagedView
        return mState == State.OVERVIEW;
    }

    public void snapToPageFromOverView(int whichPage) {
        mStateTransitionAnimation.snapToPageFromOverView(whichPage);
    }

    int getOverviewModeTranslationY() {
        DeviceProfile grid = mLauncher.getDeviceProfile();
        Rect overviewBar = grid.getOverviewModeButtonBarRect();
@@ -1957,15 +1971,19 @@ public class Workspace extends PagedView
     * Sets the current workspace {@link State}, returning an animation transitioning the workspace
     * to that new state.
     */
    public Animator setStateWithAnimation(State toState, int toPage, boolean animated,
    public Animator setStateWithAnimation(State toState, boolean animated,
            boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
        // Create the animation to the new state
        Animator workspaceAnim =  mStateTransitionAnimation.getAnimationToState(mState,
                toState, toPage, animated, hasOverlaySearchBar, layerViews);
                toState, animated, hasOverlaySearchBar, layerViews);

        // 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.
            invalidate();
        }

        return workspaceAnim;
    }
@@ -2574,7 +2592,7 @@ public class Workspace extends PagedView
            }
        }

        int snapScreen = WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE;
        int snapScreen = -1;
        boolean resizeOnDrop = false;
        if (d.dragSource != this) {
            final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
@@ -2735,9 +2753,7 @@ public class Workspace extends PagedView
                    animateWidgetDrop(info, parent, d.dragView,
                            onCompleteRunnable, animationType, cell, false);
                } else {
                    int duration = snapScreen < 0 ?
                            WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE :
                                    ADJACENT_SCREEN_DROP_DURATION;
                    int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
                    mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
                            onCompleteRunnable, this);
                }
+8 −11
Original line number Diff line number Diff line
@@ -174,7 +174,6 @@ public class WorkspaceStateTransitionAnimation {

    public static final String TAG = "WorkspaceStateTransitionAnimation";

    public static final int SCROLL_TO_CURRENT_PAGE = -1;
    @Thunk static final int BACKGROUND_FADE_OUT_DURATION = 350;

    final @Thunk Launcher mLauncher;
@@ -216,16 +215,18 @@ public class WorkspaceStateTransitionAnimation {
        mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
    }

    public void snapToPageFromOverView(int whichPage) {
        mWorkspace.snapToPage(whichPage, mOverviewTransitionTime, mZoomInInterpolator);
    }

    public AnimatorSet getAnimationToState(Workspace.State fromState, Workspace.State toState,
            int toPage, boolean animated, boolean hasOverlaySearchBar,
            HashMap<View, Integer> layerViews) {
            boolean animated, boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
        AccessibilityManager am = (AccessibilityManager)
                mLauncher.getSystemService(Context.ACCESSIBILITY_SERVICE);
        final boolean accessibilityEnabled = am.isEnabled();
        TransitionStates states = new TransitionStates(fromState, toState);
        int duration = getAnimationDuration(states);
        animateWorkspace(states, toPage, animated, duration, layerViews,
                accessibilityEnabled);
        animateWorkspace(states, animated, duration, layerViews, accessibilityEnabled);
        animateSearchBar(states, animated, duration, hasOverlaySearchBar, layerViews,
                accessibilityEnabled);
        animateBackgroundGradient(states, animated, BACKGROUND_FADE_OUT_DURATION);
@@ -265,7 +266,7 @@ public class WorkspaceStateTransitionAnimation {
    /**
     * Starts a transition animation for the workspace.
     */
    private void animateWorkspace(final TransitionStates states, int toPage, final boolean animated,
    private void animateWorkspace(final TransitionStates states, final boolean animated,
                                  final int duration, final HashMap<View, Integer> layerViews,
                                  final boolean accessibilityEnabled) {
        // Reinitialize animation arrays for the current workspace state
@@ -305,11 +306,7 @@ public class WorkspaceStateTransitionAnimation {
            }
        }

        if (toPage == SCROLL_TO_CURRENT_PAGE) {
            toPage = mWorkspace.getPageNearestToCenterOfScreen();
        }
        mWorkspace.snapToPage(toPage, duration, mZoomInInterpolator);

        int toPage = mWorkspace.getPageNearestToCenterOfScreen();
        for (int i = 0; i < childCount; i++) {
            final CellLayout cl = (CellLayout) mWorkspace.getChildAt(i);
            boolean isCurrentPage = (i == toPage);