diff options
| author | 2017-06-02 21:39:46 +0000 | |
|---|---|---|
| committer | 2017-06-02 21:39:51 +0000 | |
| commit | 412652b001e86cc85b77409f4234809cf053c9f8 (patch) | |
| tree | 86b2e542672d8a6d4c23c3322e5ada629d870e6c | |
| parent | f3ddbb68e99ad592078c0ea5dd4f076024509e3b (diff) | |
| parent | ca3168bd9ec99668e02087f35833a4807f439c1e (diff) | |
Merge "Unminimize to save divider position after rotation"
3 files changed, 21 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java index 0b09accf2db1..f750815d663f 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java @@ -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() { diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java index 353a9749eb25..3a5c61e6d7f0 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java @@ -22,4 +22,5 @@ package com.android.systemui.stackdivider; public class DividerState { public boolean animateAfterRecentsDrawn; public boolean growAfterRecentsDrawn; + public float mRatioPositionBeforeMinimized; } diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java index 9e2ec571faa8..2bda1dfb5f88 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java @@ -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,10 +840,16 @@ 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() { mBackground.setPivotX(mBackground.getWidth() / 2); mBackground.setPivotY(mBackground.getHeight() / 2); @@ -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()); } |