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
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -22,4 +22,5 @@ package com.android.systemui.stackdivider;
|
||||
public class DividerState {
|
||||
public boolean animateAfterRecentsDrawn;
|
||||
public boolean growAfterRecentsDrawn;
|
||||
public float mRatioPositionBeforeMinimized;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user