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

Commit ca3168bd authored by Matthew Ng's avatar Matthew Ng
Browse files

Unminimize to save divider position after rotation

Holds the divider ratio in the divider state to persist after
configuration change while minimized. After unminimizing past
a configuration change, the previous position will estimate to
the closest snap target.

Test: manual - minimize, rotate, unminimize
Fixes: 34395958
Change-Id: I6ceffb9f5018b8009069f0aa0085f263d8982319
parent 3599e8a3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class Divider extends SystemUI {
    private void addDivider(Configuration configuration) {
        mView = (DividerView)
                LayoutInflater.from(mContext).inflate(R.layout.docked_stack_divider, null);
        mView.injectDependencies(mWindowManager, mDividerState);
        mView.setVisibility(mVisible ? View.VISIBLE : View.INVISIBLE);
        mView.setMinimizedDockStack(mMinimized, mHomeStackResizable);
        final int size = mContext.getResources().getDimensionPixelSize(
@@ -87,7 +88,6 @@ public class Divider extends SystemUI {
        final int width = landscape ? size : MATCH_PARENT;
        final int height = landscape ? MATCH_PARENT : size;
        mWindowManager.add(mView, width, height);
        mView.injectDependencies(mWindowManager, mDividerState);
    }

    private void removeDivider() {
+1 −0
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@ package com.android.systemui.stackdivider;
public class DividerState {
    public boolean animateAfterRecentsDrawn;
    public boolean growAfterRecentsDrawn;
    public float mRatioPositionBeforeMinimized;
}
+19 −17
Original line number Diff line number Diff line
@@ -364,6 +364,17 @@ public class DividerView extends FrameLayout implements OnTouchListener,
    public void injectDependencies(DividerWindowManager windowManager, DividerState dividerState) {
        mWindowManager = windowManager;
        mState = dividerState;

        // Set the previous position ratio before minimized state after attaching this divider
        if (mStableInsets.isEmpty()) {
            SystemServicesProxy.getInstance(mContext).getStableInsets(mStableInsets);
        }
        int position = (int) (mState.mRatioPositionBeforeMinimized *
                (isHorizontalDivision() ? mDisplayHeight : mDisplayWidth));
        mSnapAlgorithm = null;
        initializeSnapAlgorithm();
        mDividerPositionBeforeMinimized = mSnapAlgorithm.calculateNonDismissingSnapTarget(position)
                .position;
    }

    public WindowManagerProxy getWindowManagerProxy() {
@@ -719,19 +730,12 @@ public class DividerView extends FrameLayout implements OnTouchListener,
            mHandle.setAlpha(minimized ? 0f : 1f);
            mDockedStackMinimized = minimized;
        } else if (mDockedStackMinimized != minimized) {
            if (mStableInsets.isEmpty()) {
                SystemServicesProxy.getInstance(mContext).getStableInsets(mStableInsets);
            }
            mMinimizedSnapAlgorithm = null;
            mDockedStackMinimized = minimized;
            initializeSnapAlgorithm();
            if (mIsInMinimizeInteraction != minimized) {
                if (minimized) {
                    mIsInMinimizeInteraction = true;
                    mDividerPositionBeforeMinimized = DockedDividerUtils.calculateMiddlePosition(
                            isHorizontalDivision(), mStableInsets, mDisplayWidth, mDisplayHeight,
                            mDividerSize);

                    int position = mMinimizedSnapAlgorithm.getMiddleTarget().position;
                    resizeStack(position, position, mMinimizedSnapAlgorithm.getMiddleTarget());
                } else {
@@ -776,7 +780,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
            mIsInMinimizeInteraction = true;
            if (minimized && (mCurrentAnimator == null || !mCurrentAnimator.isRunning())
                    && (mDividerPositionBeforeMinimized <= 0 || !mAdjustedForIme)) {
                mDividerPositionBeforeMinimized = getCurrentPosition();
                savePositionBeforeMinimized();
            }
            mMinimizedSnapAlgorithm = null;
            mDockedStackMinimized = minimized;
@@ -836,8 +840,14 @@ public class DividerView extends FrameLayout implements OnTouchListener,
        // Only get new position if home stack is resizable, ime is open and not minimized
        // (including the animation)
        if (mHomeStackResizable && adjustedForIme && !mIsInMinimizeInteraction) {
            mDividerPositionBeforeMinimized = getCurrentPosition();
            savePositionBeforeMinimized();
        }
    }

    private void savePositionBeforeMinimized() {
        mDividerPositionBeforeMinimized = getCurrentPosition();
        mState.mRatioPositionBeforeMinimized = (float) mDividerPositionBeforeMinimized /
                (isHorizontalDivision() ? mDisplayHeight : mDisplayWidth);
    }

    private void resetBackground() {
@@ -1198,14 +1208,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,
                mDockSide, mDividerSize);
        mEntranceAnimationRunning = true;

        // Insets might not have been fetched yet, so fetch manually if needed.
        if (mStableInsets.isEmpty()) {
            SystemServicesProxy.getInstance(mContext).getStableInsets(mStableInsets);
            mSnapAlgorithm = null;
            mMinimizedSnapAlgorithm = null;
            initializeSnapAlgorithm();
        }

        resizeStack(position, mSnapAlgorithm.getMiddleTarget().position,
                mSnapAlgorithm.getMiddleTarget());
    }