Merge "Separate split layout shifting callback from layout changed callback" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6f26ef6d74
@@ -232,7 +232,7 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
||||
|
||||
if (mSplitLayout != null
|
||||
&& mSplitLayout.updateConfiguration(mRootTaskInfo.configuration)) {
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
}
|
||||
} else if (taskInfo.taskId == getTaskId1()) {
|
||||
mTaskInfo1 = taskInfo;
|
||||
@@ -313,13 +313,19 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanging(SplitLayout layout) {
|
||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t ->
|
||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(SplitLayout layout) {
|
||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t ->
|
||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutSizeChanged(SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyTaskChanges(wct, mTaskInfo1, mTaskInfo2);
|
||||
mSyncQueue.queue(wct);
|
||||
@@ -328,9 +334,9 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout) {
|
||||
public void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyLayoutShifted(wct, offsetX, offsetY, mTaskInfo1, mTaskInfo2);
|
||||
layout.applyLayoutOffsetTarget(wct, offsetX, offsetY, mTaskInfo1, mTaskInfo2);
|
||||
mController.getTaskOrganizer().applyTransaction(wct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,13 +291,13 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
void updateDivideBounds(int position) {
|
||||
updateBounds(position);
|
||||
mSplitWindowManager.setResizingSplits(true);
|
||||
mSplitLayoutHandler.onLayoutChanging(this);
|
||||
mSplitLayoutHandler.onLayoutSizeChanging(this);
|
||||
}
|
||||
|
||||
void setDividePosition(int position) {
|
||||
mDividePosition = position;
|
||||
updateBounds(mDividePosition);
|
||||
mSplitLayoutHandler.onLayoutChanged(this);
|
||||
mSplitLayoutHandler.onLayoutSizeChanged(this);
|
||||
mSplitWindowManager.setResizingSplits(false);
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
* Shift configuration bounds to prevent client apps get configuration changed or relaunch. And
|
||||
* restore shifted configuration bounds if it's no longer shifted.
|
||||
*/
|
||||
public void applyLayoutShifted(WindowContainerTransaction wct, int offsetX, int offsetY,
|
||||
public void applyLayoutOffsetTarget(WindowContainerTransaction wct, int offsetX, int offsetY,
|
||||
ActivityManager.RunningTaskInfo taskInfo1, ActivityManager.RunningTaskInfo taskInfo2) {
|
||||
if (offsetX == 0 && offsetY == 0) {
|
||||
wct.setBounds(taskInfo1.token, mBounds1);
|
||||
@@ -492,19 +492,43 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
/** Calls when dismissing split. */
|
||||
void onSnappedToDismiss(boolean snappedToEnd);
|
||||
|
||||
/** Calls when the bounds is changing due to animation or dragging divider bar. */
|
||||
void onLayoutChanging(SplitLayout layout);
|
||||
|
||||
/** Calls when the target bounds changed. */
|
||||
void onLayoutChanged(SplitLayout layout);
|
||||
/**
|
||||
* Calls when resizing the split bounds.
|
||||
*
|
||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||
* SurfaceControl, SurfaceControl)
|
||||
*/
|
||||
void onLayoutSizeChanging(SplitLayout layout);
|
||||
|
||||
/**
|
||||
* Notifies when the layout shifted. So the layout handler can shift configuration
|
||||
* bounds correspondingly to make sure client apps won't get configuration changed or
|
||||
* relaunch. If the layout is no longer shifted, layout handler should restore shifted
|
||||
* configuration bounds.
|
||||
* Calls when finish resizing the split bounds.
|
||||
*
|
||||
* @see #applyTaskChanges(WindowContainerTransaction, ActivityManager.RunningTaskInfo,
|
||||
* ActivityManager.RunningTaskInfo)
|
||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||
* SurfaceControl, SurfaceControl)
|
||||
*/
|
||||
void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout);
|
||||
void onLayoutSizeChanged(SplitLayout layout);
|
||||
|
||||
/**
|
||||
* Calls when re-positioning the split bounds. Like moving split bounds while showing IME
|
||||
* panel.
|
||||
*
|
||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||
* SurfaceControl, SurfaceControl)
|
||||
*/
|
||||
void onLayoutPositionChanging(SplitLayout layout);
|
||||
|
||||
/**
|
||||
* Notifies the target offset for shifting layout. So layout handler can shift configuration
|
||||
* bounds correspondingly to make sure client apps won't get configuration changed or
|
||||
* relaunched. If the layout is no longer shifted, layout handler should restore shifted
|
||||
* configuration bounds.
|
||||
*
|
||||
* @see #applyLayoutOffsetTarget(WindowContainerTransaction, int, int,
|
||||
* ActivityManager.RunningTaskInfo, ActivityManager.RunningTaskInfo)
|
||||
*/
|
||||
void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout);
|
||||
|
||||
/** Calls when user double tapped on the divider bar. */
|
||||
default void onDoubleTappedDivider() {
|
||||
@@ -674,9 +698,9 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
// changed or relaunch. This is required to make sure client apps will calculate
|
||||
// insets properly after layout shifted.
|
||||
if (mTargetYOffset == 0) {
|
||||
mSplitLayoutHandler.onLayoutShifted(0, 0, SplitLayout.this);
|
||||
mSplitLayoutHandler.setLayoutOffsetTarget(0, 0, SplitLayout.this);
|
||||
} else {
|
||||
mSplitLayoutHandler.onLayoutShifted(0, mTargetYOffset - mLastYOffset,
|
||||
mSplitLayoutHandler.setLayoutOffsetTarget(0, mTargetYOffset - mLastYOffset,
|
||||
SplitLayout.this);
|
||||
}
|
||||
}
|
||||
@@ -695,7 +719,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
public void onImePositionChanged(int displayId, int imeTop, SurfaceControl.Transaction t) {
|
||||
if (displayId != mDisplayId) return;
|
||||
onProgress(getProgress(imeTop));
|
||||
mSplitLayoutHandler.onLayoutChanging(SplitLayout.this);
|
||||
mSplitLayoutHandler.onLayoutPositionChanging(SplitLayout.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -703,7 +727,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
SurfaceControl.Transaction t) {
|
||||
if (displayId != mDisplayId || cancel) return;
|
||||
onProgress(1.0f);
|
||||
mSplitLayoutHandler.onLayoutChanging(SplitLayout.this);
|
||||
mSplitLayoutHandler.onLayoutPositionChanging(SplitLayout.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -713,7 +737,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
||||
if (!controlling && mImeShown) {
|
||||
reset();
|
||||
mSplitWindowManager.setInteractive(true);
|
||||
mSplitLayoutHandler.onLayoutChanging(SplitLayout.this);
|
||||
mSplitLayoutHandler.onLayoutPositionChanging(SplitLayout.this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
if (mSideStageListener.mVisible && updateBounds) {
|
||||
if (wct == null) {
|
||||
// onLayoutChanged builds/applies a wct with the contents of updateWindowBounds.
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
} else {
|
||||
updateWindowBounds(mSplitLayout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -805,13 +805,18 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanging(SplitLayout layout) {
|
||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
mSideStage.setOutlineVisibility(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(SplitLayout layout) {
|
||||
public void onLayoutSizeChanged(SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
updateWindowBounds(layout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -865,13 +870,13 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout) {
|
||||
public void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout) {
|
||||
final StageTaskListener topLeftStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
||||
final StageTaskListener bottomRightStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyLayoutShifted(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
layout.applyLayoutOffsetTarget(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
bottomRightStage.mRootTaskInfo);
|
||||
mTaskOrganizer.applyTransaction(wct);
|
||||
}
|
||||
@@ -903,7 +908,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
if (mSplitLayout != null
|
||||
&& mSplitLayout.updateConfiguration(mDisplayAreaInfo.configuration)
|
||||
&& mMainStage.isActive()) {
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -470,8 +470,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
|
||||
if (mSideStageListener.mVisible && updateBounds) {
|
||||
if (wct == null) {
|
||||
// onLayoutChanged builds/applies a wct with the contents of updateWindowBounds.
|
||||
onLayoutChanged(mSplitLayout);
|
||||
// onLayoutSizeChanged builds/applies a wct with the contents of updateWindowBounds.
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
} else {
|
||||
updateWindowBounds(mSplitLayout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -800,13 +800,18 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanging(SplitLayout layout) {
|
||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
||||
mSideStage.setOutlineVisibility(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChanged(SplitLayout layout) {
|
||||
public void onLayoutSizeChanged(SplitLayout layout) {
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
updateWindowBounds(layout, wct);
|
||||
updateUnfoldBounds();
|
||||
@@ -860,13 +865,13 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutShifted(int offsetX, int offsetY, SplitLayout layout) {
|
||||
public void setLayoutOffsetTarget(int offsetX, int offsetY, SplitLayout layout) {
|
||||
final StageTaskListener topLeftStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
||||
final StageTaskListener bottomRightStage =
|
||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||
layout.applyLayoutShifted(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
layout.applyLayoutOffsetTarget(wct, offsetX, offsetY, topLeftStage.mRootTaskInfo,
|
||||
bottomRightStage.mRootTaskInfo);
|
||||
mTaskOrganizer.applyTransaction(wct);
|
||||
}
|
||||
@@ -898,7 +903,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
if (mSplitLayout != null
|
||||
&& mSplitLayout.updateConfiguration(mDisplayAreaInfo.configuration)
|
||||
&& mMainStage.isActive()) {
|
||||
onLayoutChanged(mSplitLayout);
|
||||
onLayoutSizeChanged(mSplitLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,13 +95,13 @@ public class SplitLayoutTests extends ShellTestCase {
|
||||
@Test
|
||||
public void testUpdateDivideBounds() {
|
||||
mSplitLayout.updateDivideBounds(anyInt());
|
||||
verify(mSplitLayoutHandler).onLayoutChanging(any(SplitLayout.class));
|
||||
verify(mSplitLayoutHandler).onLayoutSizeChanging(any(SplitLayout.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetDividePosition() {
|
||||
mSplitLayout.setDividePosition(anyInt());
|
||||
verify(mSplitLayoutHandler).onLayoutChanged(any(SplitLayout.class));
|
||||
verify(mSplitLayoutHandler).onLayoutSizeChanged(any(SplitLayout.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -133,7 +133,7 @@ public class StageCoordinatorTests extends ShellTestCase {
|
||||
mStageCoordinator.setSideStagePosition(SPLIT_POSITION_TOP_OR_LEFT, null);
|
||||
clearInvocations(mMainUnfoldController, mSideUnfoldController);
|
||||
|
||||
mStageCoordinator.onLayoutChanged(mSplitLayout);
|
||||
mStageCoordinator.onLayoutSizeChanged(mSplitLayout);
|
||||
|
||||
verify(mMainUnfoldController).onLayoutChanged(mBounds2);
|
||||
verify(mSideUnfoldController).onLayoutChanged(mBounds1);
|
||||
@@ -145,7 +145,7 @@ public class StageCoordinatorTests extends ShellTestCase {
|
||||
mStageCoordinator.setSideStagePosition(SPLIT_POSITION_BOTTOM_OR_RIGHT, null);
|
||||
clearInvocations(mMainUnfoldController, mSideUnfoldController);
|
||||
|
||||
mStageCoordinator.onLayoutChanged(mSplitLayout);
|
||||
mStageCoordinator.onLayoutSizeChanged(mSplitLayout);
|
||||
|
||||
verify(mMainUnfoldController).onLayoutChanged(mBounds1);
|
||||
verify(mSideUnfoldController).onLayoutChanged(mBounds2);
|
||||
|
||||
Reference in New Issue
Block a user