Merge "Implement center aligned parallax resizng effect" into tm-dev
This commit is contained in:
@@ -131,7 +131,7 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
|||||||
mDisplayController.getDisplayContext(mRootTaskInfo.displayId),
|
mDisplayController.getDisplayContext(mRootTaskInfo.displayId),
|
||||||
mRootTaskInfo.configuration, this /* layoutChangeListener */,
|
mRootTaskInfo.configuration, this /* layoutChangeListener */,
|
||||||
mParentContainerCallbacks, mDisplayImeController, mController.getTaskOrganizer(),
|
mParentContainerCallbacks, mDisplayImeController, mController.getTaskOrganizer(),
|
||||||
true /* applyDismissingParallax */);
|
SplitLayout.PARALLAX_DISMISSING);
|
||||||
mDisplayInsetsController.addInsetsChangedListener(mRootTaskInfo.displayId, mSplitLayout);
|
mDisplayInsetsController.addInsetsChangedListener(mRootTaskInfo.displayId, mSplitLayout);
|
||||||
|
|
||||||
final WindowContainerToken token1 = task1.token;
|
final WindowContainerToken token1 = task1.token;
|
||||||
@@ -327,13 +327,15 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
|||||||
@Override
|
@Override
|
||||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||||
mSyncQueue.runInSync(t ->
|
mSyncQueue.runInSync(t ->
|
||||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2,
|
||||||
|
true /* applyResizingOffset */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||||
mSyncQueue.runInSync(t ->
|
mSyncQueue.runInSync(t ->
|
||||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2,
|
||||||
|
true /* applyResizingOffset */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -342,7 +344,8 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.SplitLayou
|
|||||||
layout.applyTaskChanges(wct, mTaskInfo1, mTaskInfo2);
|
layout.applyTaskChanges(wct, mTaskInfo1, mTaskInfo2);
|
||||||
mSyncQueue.queue(wct);
|
mSyncQueue.queue(wct);
|
||||||
mSyncQueue.runInSync(t ->
|
mSyncQueue.runInSync(t ->
|
||||||
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2));
|
layout.applySurfaceChanges(t, mTaskLeash1, mTaskLeash2, mDimLayer1, mDimLayer2,
|
||||||
|
false /* applyResizingOffset */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ import java.io.PrintWriter;
|
|||||||
*/
|
*/
|
||||||
public final class SplitLayout implements DisplayInsetsController.OnInsetsChangedListener {
|
public final class SplitLayout implements DisplayInsetsController.OnInsetsChangedListener {
|
||||||
|
|
||||||
|
public static final int PARALLAX_NONE = 0;
|
||||||
|
public static final int PARALLAX_DISMISSING = 1;
|
||||||
|
public static final int PARALLAX_ALIGN_CENTER = 2;
|
||||||
|
|
||||||
private final int mDividerWindowWidth;
|
private final int mDividerWindowWidth;
|
||||||
private final int mDividerInsets;
|
private final int mDividerInsets;
|
||||||
private final int mDividerSize;
|
private final int mDividerSize;
|
||||||
@@ -87,7 +91,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
private final SplitWindowManager mSplitWindowManager;
|
private final SplitWindowManager mSplitWindowManager;
|
||||||
private final DisplayImeController mDisplayImeController;
|
private final DisplayImeController mDisplayImeController;
|
||||||
private final ImePositionProcessor mImePositionProcessor;
|
private final ImePositionProcessor mImePositionProcessor;
|
||||||
private final DismissingEffectPolicy mDismissingEffectPolicy;
|
private final ResizingEffectPolicy mSurfaceEffectPolicy;
|
||||||
private final ShellTaskOrganizer mTaskOrganizer;
|
private final ShellTaskOrganizer mTaskOrganizer;
|
||||||
private final InsetsState mInsetsState = new InsetsState();
|
private final InsetsState mInsetsState = new InsetsState();
|
||||||
|
|
||||||
@@ -105,7 +109,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
SplitLayoutHandler splitLayoutHandler,
|
SplitLayoutHandler splitLayoutHandler,
|
||||||
SplitWindowManager.ParentContainerCallbacks parentContainerCallbacks,
|
SplitWindowManager.ParentContainerCallbacks parentContainerCallbacks,
|
||||||
DisplayImeController displayImeController, ShellTaskOrganizer taskOrganizer,
|
DisplayImeController displayImeController, ShellTaskOrganizer taskOrganizer,
|
||||||
boolean applyDismissingParallax) {
|
int parallaxType) {
|
||||||
mContext = context.createConfigurationContext(configuration);
|
mContext = context.createConfigurationContext(configuration);
|
||||||
mOrientation = configuration.orientation;
|
mOrientation = configuration.orientation;
|
||||||
mRotation = configuration.windowConfiguration.getRotation();
|
mRotation = configuration.windowConfiguration.getRotation();
|
||||||
@@ -115,7 +119,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
parentContainerCallbacks);
|
parentContainerCallbacks);
|
||||||
mTaskOrganizer = taskOrganizer;
|
mTaskOrganizer = taskOrganizer;
|
||||||
mImePositionProcessor = new ImePositionProcessor(mContext.getDisplayId());
|
mImePositionProcessor = new ImePositionProcessor(mContext.getDisplayId());
|
||||||
mDismissingEffectPolicy = new DismissingEffectPolicy(applyDismissingParallax);
|
mSurfaceEffectPolicy = new ResizingEffectPolicy(parallaxType);
|
||||||
|
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
mDividerSize = resources.getDimensionPixelSize(R.dimen.split_divider_bar_width);
|
mDividerSize = resources.getDimensionPixelSize(R.dimen.split_divider_bar_width);
|
||||||
@@ -281,7 +285,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
}
|
}
|
||||||
DockedDividerUtils.sanitizeStackBounds(mBounds1, true /** topLeft */);
|
DockedDividerUtils.sanitizeStackBounds(mBounds1, true /** topLeft */);
|
||||||
DockedDividerUtils.sanitizeStackBounds(mBounds2, false /** topLeft */);
|
DockedDividerUtils.sanitizeStackBounds(mBounds2, false /** topLeft */);
|
||||||
mDismissingEffectPolicy.applyDividerPosition(position, isLandscape);
|
mSurfaceEffectPolicy.applyDividerPosition(position, isLandscape);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inflates {@link DividerView} on the root surface. */
|
/** Inflates {@link DividerView} on the root surface. */
|
||||||
@@ -486,7 +490,8 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
|
|
||||||
/** Apply recorded surface layout to the {@link SurfaceControl.Transaction}. */
|
/** Apply recorded surface layout to the {@link SurfaceControl.Transaction}. */
|
||||||
public void applySurfaceChanges(SurfaceControl.Transaction t, SurfaceControl leash1,
|
public void applySurfaceChanges(SurfaceControl.Transaction t, SurfaceControl leash1,
|
||||||
SurfaceControl leash2, SurfaceControl dimLayer1, SurfaceControl dimLayer2) {
|
SurfaceControl leash2, SurfaceControl dimLayer1, SurfaceControl dimLayer2,
|
||||||
|
boolean applyResizingOffset) {
|
||||||
final SurfaceControl dividerLeash = getDividerLeash();
|
final SurfaceControl dividerLeash = getDividerLeash();
|
||||||
if (dividerLeash != null) {
|
if (dividerLeash != null) {
|
||||||
mTempRect.set(getRefDividerBounds());
|
mTempRect.set(getRefDividerBounds());
|
||||||
@@ -506,7 +511,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDismissingEffectPolicy.adjustDismissingSurface(t, leash1, leash2, dimLayer1, dimLayer2);
|
mSurfaceEffectPolicy.adjustDimSurface(t, dimLayer1, dimLayer2);
|
||||||
|
if (applyResizingOffset) {
|
||||||
|
mSurfaceEffectPolicy.adjustRootSurface(t, leash1, leash2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Apply recorded task layout to the {@link WindowContainerTransaction}. */
|
/** Apply recorded task layout to the {@link WindowContainerTransaction}. */
|
||||||
@@ -590,7 +598,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
* Calls when resizing the split bounds.
|
* Calls when resizing the split bounds.
|
||||||
*
|
*
|
||||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||||
* SurfaceControl, SurfaceControl)
|
* SurfaceControl, SurfaceControl, boolean)
|
||||||
*/
|
*/
|
||||||
void onLayoutSizeChanging(SplitLayout layout);
|
void onLayoutSizeChanging(SplitLayout layout);
|
||||||
|
|
||||||
@@ -600,7 +608,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
* @see #applyTaskChanges(WindowContainerTransaction, ActivityManager.RunningTaskInfo,
|
* @see #applyTaskChanges(WindowContainerTransaction, ActivityManager.RunningTaskInfo,
|
||||||
* ActivityManager.RunningTaskInfo)
|
* ActivityManager.RunningTaskInfo)
|
||||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||||
* SurfaceControl, SurfaceControl)
|
* SurfaceControl, SurfaceControl, boolean)
|
||||||
*/
|
*/
|
||||||
void onLayoutSizeChanged(SplitLayout layout);
|
void onLayoutSizeChanged(SplitLayout layout);
|
||||||
|
|
||||||
@@ -609,7 +617,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
* panel.
|
* panel.
|
||||||
*
|
*
|
||||||
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
* @see #applySurfaceChanges(SurfaceControl.Transaction, SurfaceControl, SurfaceControl,
|
||||||
* SurfaceControl, SurfaceControl)
|
* SurfaceControl, SurfaceControl, boolean)
|
||||||
*/
|
*/
|
||||||
void onLayoutPositionChanging(SplitLayout layout);
|
void onLayoutPositionChanging(SplitLayout layout);
|
||||||
|
|
||||||
@@ -637,21 +645,25 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
* Calculates and applies proper dismissing parallax offset and dimming value to hint users
|
* Calculates and applies proper dismissing parallax offset and dimming value to hint users
|
||||||
* dismissing gesture.
|
* dismissing gesture.
|
||||||
*/
|
*/
|
||||||
private class DismissingEffectPolicy {
|
private class ResizingEffectPolicy {
|
||||||
/** Indicates whether to offset splitting bounds to hint dismissing progress or not. */
|
/** Indicates whether to offset splitting bounds to hint dismissing progress or not. */
|
||||||
private final boolean mApplyParallax;
|
private final int mParallaxType;
|
||||||
|
|
||||||
|
int mShrinkSide = DOCKED_INVALID;
|
||||||
|
|
||||||
// The current dismissing side.
|
// The current dismissing side.
|
||||||
int mDismissingSide = DOCKED_INVALID;
|
int mDismissingSide = DOCKED_INVALID;
|
||||||
|
|
||||||
// The parallax offset to hint the dismissing side and progress.
|
// The parallax offset to hint the dismissing side and progress.
|
||||||
final Point mDismissingParallaxOffset = new Point();
|
final Point mParallaxOffset = new Point();
|
||||||
|
|
||||||
// The dimming value to hint the dismissing side and progress.
|
// The dimming value to hint the dismissing side and progress.
|
||||||
float mDismissingDimValue = 0.0f;
|
float mDismissingDimValue = 0.0f;
|
||||||
|
final Rect mContentBounds = new Rect();
|
||||||
|
final Rect mSurfaceBounds = new Rect();
|
||||||
|
|
||||||
DismissingEffectPolicy(boolean applyDismissingParallax) {
|
ResizingEffectPolicy(int parallaxType) {
|
||||||
mApplyParallax = applyDismissingParallax;
|
mParallaxType = parallaxType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -662,7 +674,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
*/
|
*/
|
||||||
void applyDividerPosition(int position, boolean isLandscape) {
|
void applyDividerPosition(int position, boolean isLandscape) {
|
||||||
mDismissingSide = DOCKED_INVALID;
|
mDismissingSide = DOCKED_INVALID;
|
||||||
mDismissingParallaxOffset.set(0, 0);
|
mParallaxOffset.set(0, 0);
|
||||||
mDismissingDimValue = 0;
|
mDismissingDimValue = 0;
|
||||||
|
|
||||||
int totalDismissingDistance = 0;
|
int totalDismissingDistance = 0;
|
||||||
@@ -676,15 +688,39 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
- mDividerSnapAlgorithm.getDismissEndTarget().position;
|
- mDividerSnapAlgorithm.getDismissEndTarget().position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean topLeftShrink = isLandscape
|
||||||
|
? position < mWinBounds1.right : position < mWinBounds1.bottom;
|
||||||
|
if (topLeftShrink) {
|
||||||
|
mShrinkSide = isLandscape ? DOCKED_LEFT : DOCKED_TOP;
|
||||||
|
mContentBounds.set(mWinBounds1);
|
||||||
|
mSurfaceBounds.set(mBounds1);
|
||||||
|
} else {
|
||||||
|
mShrinkSide = isLandscape ? DOCKED_RIGHT : DOCKED_BOTTOM;
|
||||||
|
mContentBounds.set(mWinBounds2);
|
||||||
|
mSurfaceBounds.set(mBounds2);
|
||||||
|
}
|
||||||
|
|
||||||
if (mDismissingSide != DOCKED_INVALID) {
|
if (mDismissingSide != DOCKED_INVALID) {
|
||||||
float fraction = Math.max(0,
|
float fraction = Math.max(0,
|
||||||
Math.min(mDividerSnapAlgorithm.calculateDismissingFraction(position), 1f));
|
Math.min(mDividerSnapAlgorithm.calculateDismissingFraction(position), 1f));
|
||||||
mDismissingDimValue = DIM_INTERPOLATOR.getInterpolation(fraction);
|
mDismissingDimValue = DIM_INTERPOLATOR.getInterpolation(fraction);
|
||||||
fraction = calculateParallaxDismissingFraction(fraction, mDismissingSide);
|
if (mParallaxType == PARALLAX_DISMISSING) {
|
||||||
|
fraction = calculateParallaxDismissingFraction(fraction, mDismissingSide);
|
||||||
|
if (isLandscape) {
|
||||||
|
mParallaxOffset.x = (int) (fraction * totalDismissingDistance);
|
||||||
|
} else {
|
||||||
|
mParallaxOffset.y = (int) (fraction * totalDismissingDistance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mParallaxType == PARALLAX_ALIGN_CENTER) {
|
||||||
if (isLandscape) {
|
if (isLandscape) {
|
||||||
mDismissingParallaxOffset.x = (int) (fraction * totalDismissingDistance);
|
mParallaxOffset.x =
|
||||||
|
(mSurfaceBounds.width() - mContentBounds.width()) / 2;
|
||||||
} else {
|
} else {
|
||||||
mDismissingParallaxOffset.y = (int) (fraction * totalDismissingDistance);
|
mParallaxOffset.y =
|
||||||
|
(mSurfaceBounds.height() - mContentBounds.height()) / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -704,41 +740,66 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Applies parallax offset and dimming value to the root surface at the dismissing side. */
|
/** Applies parallax offset and dimming value to the root surface at the dismissing side. */
|
||||||
boolean adjustDismissingSurface(SurfaceControl.Transaction t,
|
void adjustRootSurface(SurfaceControl.Transaction t,
|
||||||
SurfaceControl leash1, SurfaceControl leash2,
|
SurfaceControl leash1, SurfaceControl leash2) {
|
||||||
|
SurfaceControl targetLeash = null;
|
||||||
|
|
||||||
|
if (mParallaxType == PARALLAX_DISMISSING) {
|
||||||
|
switch (mDismissingSide) {
|
||||||
|
case DOCKED_TOP:
|
||||||
|
case DOCKED_LEFT:
|
||||||
|
targetLeash = leash1;
|
||||||
|
mTempRect.set(mBounds1);
|
||||||
|
break;
|
||||||
|
case DOCKED_BOTTOM:
|
||||||
|
case DOCKED_RIGHT:
|
||||||
|
targetLeash = leash2;
|
||||||
|
mTempRect.set(mBounds2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (mParallaxType == PARALLAX_ALIGN_CENTER) {
|
||||||
|
switch (mShrinkSide) {
|
||||||
|
case DOCKED_TOP:
|
||||||
|
case DOCKED_LEFT:
|
||||||
|
targetLeash = leash1;
|
||||||
|
mTempRect.set(mBounds1);
|
||||||
|
break;
|
||||||
|
case DOCKED_BOTTOM:
|
||||||
|
case DOCKED_RIGHT:
|
||||||
|
targetLeash = leash2;
|
||||||
|
mTempRect.set(mBounds2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mParallaxType != PARALLAX_NONE && targetLeash != null) {
|
||||||
|
t.setPosition(targetLeash,
|
||||||
|
mTempRect.left + mParallaxOffset.x, mTempRect.top + mParallaxOffset.y);
|
||||||
|
// Transform the screen-based split bounds to surface-based crop bounds.
|
||||||
|
mTempRect.offsetTo(-mParallaxOffset.x, -mParallaxOffset.y);
|
||||||
|
t.setWindowCrop(targetLeash, mTempRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void adjustDimSurface(SurfaceControl.Transaction t,
|
||||||
SurfaceControl dimLayer1, SurfaceControl dimLayer2) {
|
SurfaceControl dimLayer1, SurfaceControl dimLayer2) {
|
||||||
SurfaceControl targetLeash, targetDimLayer;
|
SurfaceControl targetDimLayer;
|
||||||
switch (mDismissingSide) {
|
switch (mDismissingSide) {
|
||||||
case DOCKED_TOP:
|
case DOCKED_TOP:
|
||||||
case DOCKED_LEFT:
|
case DOCKED_LEFT:
|
||||||
targetLeash = leash1;
|
|
||||||
targetDimLayer = dimLayer1;
|
targetDimLayer = dimLayer1;
|
||||||
mTempRect.set(mBounds1);
|
|
||||||
break;
|
break;
|
||||||
case DOCKED_BOTTOM:
|
case DOCKED_BOTTOM:
|
||||||
case DOCKED_RIGHT:
|
case DOCKED_RIGHT:
|
||||||
targetLeash = leash2;
|
|
||||||
targetDimLayer = dimLayer2;
|
targetDimLayer = dimLayer2;
|
||||||
mTempRect.set(mBounds2);
|
|
||||||
break;
|
break;
|
||||||
case DOCKED_INVALID:
|
case DOCKED_INVALID:
|
||||||
default:
|
default:
|
||||||
t.setAlpha(dimLayer1, 0).hide(dimLayer1);
|
t.setAlpha(dimLayer1, 0).hide(dimLayer1);
|
||||||
t.setAlpha(dimLayer2, 0).hide(dimLayer2);
|
t.setAlpha(dimLayer2, 0).hide(dimLayer2);
|
||||||
return false;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (mApplyParallax) {
|
|
||||||
t.setPosition(targetLeash,
|
|
||||||
mTempRect.left + mDismissingParallaxOffset.x,
|
|
||||||
mTempRect.top + mDismissingParallaxOffset.y);
|
|
||||||
// Transform the screen-based split bounds to surface-based crop bounds.
|
|
||||||
mTempRect.offsetTo(-mDismissingParallaxOffset.x, -mDismissingParallaxOffset.y);
|
|
||||||
t.setWindowCrop(targetLeash, mTempRect);
|
|
||||||
}
|
}
|
||||||
t.setAlpha(targetDimLayer, mDismissingDimValue)
|
t.setAlpha(targetDimLayer, mDismissingDimValue)
|
||||||
.setVisibility(targetDimLayer, mDismissingDimValue > 0.001f);
|
.setVisibility(targetDimLayer, mDismissingDimValue > 0.001f);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStageCoordinator.updateSurfaceBounds(null /* layout */, t);
|
mStageCoordinator.updateSurfaceBounds(null /* layout */, t,
|
||||||
|
false /* applyResizingOffset */);
|
||||||
for (int i = 0; i < apps.length; ++i) {
|
for (int i = 0; i < apps.length; ++i) {
|
||||||
if (apps[i].mode == MODE_OPENING) {
|
if (apps[i].mode == MODE_OPENING) {
|
||||||
t.show(apps[i].leash);
|
t.show(apps[i].leash);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;
|
|||||||
import static android.view.WindowManager.transitTypeToString;
|
import static android.view.WindowManager.transitTypeToString;
|
||||||
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
|
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
|
||||||
|
|
||||||
|
import static com.android.wm.shell.common.split.SplitLayout.PARALLAX_ALIGN_CENTER;
|
||||||
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
|
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
|
||||||
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
|
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
|
||||||
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
|
import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
|
||||||
@@ -495,7 +496,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
|
|
||||||
// Using legacy transitions, so we can't use blast sync since it conflicts.
|
// Using legacy transitions, so we can't use blast sync since it conflicts.
|
||||||
mTaskOrganizer.applyTransaction(wct);
|
mTaskOrganizer.applyTransaction(wct);
|
||||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(mSplitLayout, t));
|
mSyncQueue.runInSync(t ->
|
||||||
|
updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -704,9 +706,11 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
mMainStage.deactivate(wct, !fromEnteringPip && mMainStage == childrenToTop);
|
mMainStage.deactivate(wct, !fromEnteringPip && mMainStage == childrenToTop);
|
||||||
wct.reorder(mRootTaskInfo.token, false /* onTop */);
|
wct.reorder(mRootTaskInfo.token, false /* onTop */);
|
||||||
mTaskOrganizer.applyTransaction(wct);
|
mTaskOrganizer.applyTransaction(wct);
|
||||||
mSyncQueue.runInSync(t -> t
|
mSyncQueue.runInSync(t -> {
|
||||||
.setWindowCrop(mMainStage.mRootLeash, null)
|
setResizingSplits(false /* resizing */);
|
||||||
.setWindowCrop(mSideStage.mRootLeash, null));
|
t.setWindowCrop(mMainStage.mRootLeash, null)
|
||||||
|
.setWindowCrop(mSideStage.mRootLeash, null);
|
||||||
|
});
|
||||||
|
|
||||||
// Hide divider and reset its position.
|
// Hide divider and reset its position.
|
||||||
mSplitLayout.resetDividerPosition();
|
mSplitLayout.resetDividerPosition();
|
||||||
@@ -780,7 +784,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
void finishEnterSplitScreen(SurfaceControl.Transaction t) {
|
void finishEnterSplitScreen(SurfaceControl.Transaction t) {
|
||||||
mSplitLayout.init();
|
mSplitLayout.init();
|
||||||
setDividerVisibility(true, t);
|
setDividerVisibility(true, t);
|
||||||
updateSurfaceBounds(mSplitLayout, t);
|
updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
|
||||||
setSplitsVisible(true);
|
setSplitsVisible(true);
|
||||||
mShouldUpdateRecents = true;
|
mShouldUpdateRecents = true;
|
||||||
updateRecentTasksSplitPair();
|
updateRecentTasksSplitPair();
|
||||||
@@ -925,7 +929,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
if (mSplitLayout == null) {
|
if (mSplitLayout == null) {
|
||||||
mSplitLayout = new SplitLayout(TAG + "SplitDivider", mContext,
|
mSplitLayout = new SplitLayout(TAG + "SplitDivider", mContext,
|
||||||
mRootTaskInfo.configuration, this, mParentContainerCallbacks,
|
mRootTaskInfo.configuration, this, mParentContainerCallbacks,
|
||||||
mDisplayImeController, mTaskOrganizer, false /* applyDismissingParallax */);
|
mDisplayImeController, mTaskOrganizer,
|
||||||
|
PARALLAX_ALIGN_CENTER /* parallaxType */);
|
||||||
mDisplayInsetsController.addInsetsChangedListener(mDisplayId, mSplitLayout);
|
mDisplayInsetsController.addInsetsChangedListener(mDisplayId, mSplitLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,7 +1080,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
prepareEnterSplitScreen(wct);
|
prepareEnterSplitScreen(wct);
|
||||||
mSyncQueue.queue(wct);
|
mSyncQueue.queue(wct);
|
||||||
mSyncQueue.runInSync(t -> {
|
mSyncQueue.runInSync(t -> {
|
||||||
updateSurfaceBounds(mSplitLayout, t);
|
updateSurfaceBounds(mSplitLayout, t, false /* applyResizingOffset */);
|
||||||
setDividerVisibility(true, t);
|
setDividerVisibility(true, t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1094,8 +1099,6 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSnappedToDismiss(boolean bottomOrRight) {
|
public void onSnappedToDismiss(boolean bottomOrRight) {
|
||||||
setResizingSplits(false /* resizing */);
|
|
||||||
|
|
||||||
final boolean mainStageToTop =
|
final boolean mainStageToTop =
|
||||||
bottomOrRight ? mSideStagePosition == SPLIT_POSITION_BOTTOM_OR_RIGHT
|
bottomOrRight ? mSideStagePosition == SPLIT_POSITION_BOTTOM_OR_RIGHT
|
||||||
: mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT;
|
: mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT;
|
||||||
@@ -1104,6 +1107,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setResizingSplits(false /* resizing */);
|
||||||
final int dismissTop = mainStageToTop ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE;
|
final int dismissTop = mainStageToTop ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE;
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
prepareExitSplitScreen(dismissTop, wct);
|
prepareExitSplitScreen(dismissTop, wct);
|
||||||
@@ -1121,14 +1125,14 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t, false /* applyResizingOffset */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||||
mSyncQueue.runInSync(t -> {
|
mSyncQueue.runInSync(t -> {
|
||||||
setResizingSplits(true /* resizing */);
|
setResizingSplits(true /* resizing */);
|
||||||
updateSurfaceBounds(layout, t);
|
updateSurfaceBounds(layout, t, true /* applyResizingOffset */);
|
||||||
mMainStage.onResizing(getMainStageBounds(), t);
|
mMainStage.onResizing(getMainStageBounds(), t);
|
||||||
mSideStage.onResizing(getSideStageBounds(), t);
|
mSideStage.onResizing(getSideStageBounds(), t);
|
||||||
});
|
});
|
||||||
@@ -1142,7 +1146,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
mSyncQueue.queue(wct);
|
mSyncQueue.queue(wct);
|
||||||
mSyncQueue.runInSync(t -> {
|
mSyncQueue.runInSync(t -> {
|
||||||
setResizingSplits(false /* resizing */);
|
setResizingSplits(false /* resizing */);
|
||||||
updateSurfaceBounds(layout, t);
|
updateSurfaceBounds(layout, t, false /* applyResizingOffset */);
|
||||||
mMainStage.onResized(t);
|
mMainStage.onResized(t);
|
||||||
mSideStage.onResized(t);
|
mSideStage.onResized(t);
|
||||||
});
|
});
|
||||||
@@ -1174,13 +1178,15 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
layout.applyTaskChanges(wct, topLeftStage.mRootTaskInfo, bottomRightStage.mRootTaskInfo);
|
layout.applyTaskChanges(wct, topLeftStage.mRootTaskInfo, bottomRightStage.mRootTaskInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSurfaceBounds(@Nullable SplitLayout layout, @NonNull SurfaceControl.Transaction t) {
|
void updateSurfaceBounds(@Nullable SplitLayout layout, @NonNull SurfaceControl.Transaction t,
|
||||||
|
boolean applyResizingOffset) {
|
||||||
final StageTaskListener topLeftStage =
|
final StageTaskListener topLeftStage =
|
||||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
||||||
final StageTaskListener bottomRightStage =
|
final StageTaskListener bottomRightStage =
|
||||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
||||||
(layout != null ? layout : mSplitLayout).applySurfaceChanges(t, topLeftStage.mRootLeash,
|
(layout != null ? layout : mSplitLayout).applySurfaceChanges(t, topLeftStage.mRootLeash,
|
||||||
bottomRightStage.mRootLeash, topLeftStage.mDimLayer, bottomRightStage.mDimLayer);
|
bottomRightStage.mRootLeash, topLeftStage.mDimLayer, bottomRightStage.mDimLayer,
|
||||||
|
applyResizingOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setResizingSplits(boolean resizing) {
|
void setResizingSplits(boolean resizing) {
|
||||||
@@ -1220,7 +1226,6 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
mTaskOrganizer.applyTransaction(wct);
|
mTaskOrganizer.applyTransaction(wct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayAdded(int displayId) {
|
public void onDisplayAdded(int displayId) {
|
||||||
if (displayId != DEFAULT_DISPLAY) {
|
if (displayId != DEFAULT_DISPLAY) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -253,7 +253,8 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps,
|
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps,
|
||||||
IRemoteAnimationFinishedCallback finishedCallback,
|
IRemoteAnimationFinishedCallback finishedCallback,
|
||||||
SurfaceControl.Transaction t) {
|
SurfaceControl.Transaction t) {
|
||||||
mStageCoordinator.updateSurfaceBounds(null /* layout */, t);
|
mStageCoordinator.updateSurfaceBounds(null /* layout */, t,
|
||||||
|
false /* applyResizingOffset */);
|
||||||
|
|
||||||
if (apps != null) {
|
if (apps != null) {
|
||||||
for (int i = 0; i < apps.length; ++i) {
|
for (int i = 0; i < apps.length; ++i) {
|
||||||
|
|||||||
@@ -265,7 +265,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
mMainStage.activate(getMainStageBounds(), wct);
|
mMainStage.activate(getMainStageBounds(), wct);
|
||||||
mSideStage.addTask(task, getSideStageBounds(), wct);
|
mSideStage.addTask(task, getSideStageBounds(), wct);
|
||||||
mSyncQueue.queue(wct);
|
mSyncQueue.queue(wct);
|
||||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(null /* layout */, t));
|
mSyncQueue.runInSync(
|
||||||
|
t -> updateSurfaceBounds(null /* layout */, t, false /* applyResizingOffset */));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,12 +802,12 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutPositionChanging(SplitLayout layout) {
|
public void onLayoutPositionChanging(SplitLayout layout) {
|
||||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t, true /* applyResizingOffset */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutSizeChanging(SplitLayout layout) {
|
public void onLayoutSizeChanging(SplitLayout layout) {
|
||||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t, true /* applyResizingOffset */));
|
||||||
mSideStage.setOutlineVisibility(false);
|
mSideStage.setOutlineVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -816,7 +817,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
updateWindowBounds(layout, wct);
|
updateWindowBounds(layout, wct);
|
||||||
updateUnfoldBounds();
|
updateUnfoldBounds();
|
||||||
mSyncQueue.queue(wct);
|
mSyncQueue.queue(wct);
|
||||||
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t));
|
mSyncQueue.runInSync(t -> updateSurfaceBounds(layout, t, false /* applyResizingOffset */));
|
||||||
mSideStage.setOutlineVisibility(true);
|
mSideStage.setOutlineVisibility(true);
|
||||||
mLogger.logResize(mSplitLayout.getDividerPositionAsFraction());
|
mLogger.logResize(mSplitLayout.getDividerPositionAsFraction());
|
||||||
}
|
}
|
||||||
@@ -840,13 +841,15 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
layout.applyTaskChanges(wct, topLeftStage.mRootTaskInfo, bottomRightStage.mRootTaskInfo);
|
layout.applyTaskChanges(wct, topLeftStage.mRootTaskInfo, bottomRightStage.mRootTaskInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSurfaceBounds(@Nullable SplitLayout layout, @NonNull SurfaceControl.Transaction t) {
|
void updateSurfaceBounds(@Nullable SplitLayout layout, @NonNull SurfaceControl.Transaction t,
|
||||||
|
boolean applyResizingOffset) {
|
||||||
final StageTaskListener topLeftStage =
|
final StageTaskListener topLeftStage =
|
||||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mSideStage : mMainStage;
|
||||||
final StageTaskListener bottomRightStage =
|
final StageTaskListener bottomRightStage =
|
||||||
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT ? mMainStage : mSideStage;
|
||||||
(layout != null ? layout : mSplitLayout).applySurfaceChanges(t, topLeftStage.mRootLeash,
|
(layout != null ? layout : mSplitLayout).applySurfaceChanges(t, topLeftStage.mRootLeash,
|
||||||
bottomRightStage.mRootLeash, topLeftStage.mDimLayer, bottomRightStage.mDimLayer);
|
bottomRightStage.mRootLeash, topLeftStage.mDimLayer, bottomRightStage.mDimLayer,
|
||||||
|
applyResizingOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -882,7 +885,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
if (mSplitLayout == null) {
|
if (mSplitLayout == null) {
|
||||||
mSplitLayout = new SplitLayout(TAG + "SplitDivider", mContext,
|
mSplitLayout = new SplitLayout(TAG + "SplitDivider", mContext,
|
||||||
mDisplayAreaInfo.configuration, this, mParentContainerCallbacks,
|
mDisplayAreaInfo.configuration, this, mParentContainerCallbacks,
|
||||||
mDisplayImeController, mTaskOrganizer, true /* applyDismissingParallax */);
|
mDisplayImeController, mTaskOrganizer, SplitLayout.PARALLAX_DISMISSING);
|
||||||
mDisplayInsetsController.addInsetsChangedListener(mDisplayId, mSplitLayout);
|
mDisplayInsetsController.addInsetsChangedListener(mDisplayId, mSplitLayout);
|
||||||
|
|
||||||
if (mMainUnfoldController != null && mSideUnfoldController != null) {
|
if (mMainUnfoldController != null && mSideUnfoldController != null) {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class SplitLayoutTests extends ShellTestCase {
|
|||||||
mCallbacks,
|
mCallbacks,
|
||||||
mDisplayImeController,
|
mDisplayImeController,
|
||||||
mTaskOrganizer,
|
mTaskOrganizer,
|
||||||
false /* applyDismissingParallax */));
|
SplitLayout.PARALLAX_NONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ public class StageCoordinatorTests extends ShellTestCase {
|
|||||||
public void testFinishEnterSplitScreen_applySurfaceLayout() {
|
public void testFinishEnterSplitScreen_applySurfaceLayout() {
|
||||||
mStageCoordinator.finishEnterSplitScreen(new SurfaceControl.Transaction());
|
mStageCoordinator.finishEnterSplitScreen(new SurfaceControl.Transaction());
|
||||||
|
|
||||||
verify(mSplitLayout).applySurfaceChanges(any(), any(), any(), any(), any());
|
verify(mSplitLayout).applySurfaceChanges(any(), any(), any(), any(), any(), eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UnfoldControllerProvider implements
|
private class UnfoldControllerProvider implements
|
||||||
|
|||||||
Reference in New Issue
Block a user