Merge "Slight polish for split screen gesture animation" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-09-09 03:17:23 +00:00
committed by Android (Google) Code Review
4 changed files with 31 additions and 27 deletions

View File

@@ -107,11 +107,9 @@ public class RemoteTargetGluer {
primaryTaskTarget = targets.findTask(splitIds[0]);
secondaryTaskTarget = targets.findTask(splitIds[1]);
RemoteAnimationTargetCompat dividerTarget = targets.getNonAppTargetOfType(
TYPE_DOCK_DIVIDER);
mStagedSplitBounds = new SplitConfigurationOptions.StagedSplitBounds(
primaryTaskTarget.screenSpaceBounds,
secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds);
secondaryTaskTarget.screenSpaceBounds);
mRemoteTargetHandles[0].mTransformParams.setTargetSet(
createRemoteAnimationTargetsForTarget(primaryTaskTarget, targets));
mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget,

View File

@@ -388,11 +388,12 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
float diff;
float horizontalDividerDiff = splitInfo.visualDividerBounds.width() / 2f;
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
diff = outRect.height() * (1f - splitInfo.leftTaskPercent);
diff = outRect.height() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff;
outRect.bottom -= diff;
} else {
diff = outRect.height() * splitInfo.leftTaskPercent;
diff = outRect.height() * splitInfo.leftTaskPercent + horizontalDividerDiff;
outRect.top += diff;
}
}
@@ -402,7 +403,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
if (desiredStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
// The preview set is for the bottom/right, inset by top/left task
splitOffset.x = splitInfo.leftTopBounds.width() + splitInfo.dividerBounds.width() / 2;
splitOffset.x = splitInfo.leftTopBounds.width() + splitInfo.visualDividerBounds.width();
}
}
@@ -413,7 +414,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot;
int totalThumbnailWidth = taskParent.getWidth();
int dividerBar = splitBoundsConfig.dividerBounds.width() / 2;
int dividerBar = splitBoundsConfig.visualDividerBounds.width();
ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();

View File

@@ -474,21 +474,23 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) {
boolean isLandscape = dp.isLandscape;
float verticalDividerDiff = splitInfo.visualDividerBounds.height() / 2f;
float horizontalDividerDiff = splitInfo.visualDividerBounds.width() / 2f;
float diff;
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
if (isLandscape) {
diff = outRect.width() * (1f - splitInfo.leftTaskPercent);
diff = outRect.width() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff;
outRect.right -= diff;
} else {
diff = outRect.height() * (1f - splitInfo.topTaskPercent);
diff = outRect.height() * (1f - splitInfo.topTaskPercent) + verticalDividerDiff;
outRect.bottom -= diff;
}
} else {
if (isLandscape) {
diff = outRect.width() * splitInfo.leftTaskPercent;
diff = outRect.width() * splitInfo.leftTaskPercent + horizontalDividerDiff;
outRect.left += diff;
} else {
diff = outRect.height() * splitInfo.topTaskPercent;
diff = outRect.height() * splitInfo.topTaskPercent + verticalDividerDiff;
outRect.top += diff;
}
}
@@ -500,10 +502,10 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
if (desiredStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
if (dp.isLandscape) {
splitOffset.x = splitInfo.leftTopBounds.width() +
splitInfo.dividerBounds.width() / 2;
splitInfo.visualDividerBounds.width();
} else {
splitOffset.y = splitInfo.leftTopBounds.height() +
splitInfo.dividerBounds.height() / 2;
splitInfo.visualDividerBounds.height();
}
}
}
@@ -516,9 +518,8 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot;
int totalThumbnailWidth = taskParent.getWidth();
int dividerBar = (dp.isLandscape ?
splitBoundsConfig.dividerBounds.width() :
splitBoundsConfig.dividerBounds.height())
/ 2;
splitBoundsConfig.visualDividerBounds.width() :
splitBoundsConfig.visualDividerBounds.height());
ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();

View File

@@ -88,25 +88,29 @@ public final class SplitConfigurationOptions {
public static class StagedSplitBounds {
public final Rect leftTopBounds;
public final Rect rightBottomBounds;
public final Rect dividerBounds;
/** This rect represents the actual gap between the two apps */
public final Rect visualDividerBounds;
// This class is orientation-agnostic, so we compute both for later use
public final float topTaskPercent;
public final float leftTaskPercent;
public StagedSplitBounds(Rect leftTopBounds, Rect rightBottomBounds, Rect dividerBounds) {
public StagedSplitBounds(Rect leftTopBounds, Rect rightBottomBounds) {
this.leftTopBounds = leftTopBounds;
this.rightBottomBounds = rightBottomBounds;
this.dividerBounds = dividerBounds;
float totalHeight = this.leftTopBounds.height()
+ this.rightBottomBounds.height()
+ this.dividerBounds.height();
float totalWidth = this.leftTopBounds.width()
+ this.rightBottomBounds.width()
+ this.dividerBounds.width();
leftTaskPercent = this.leftTopBounds.width() / totalWidth;
topTaskPercent = this.leftTopBounds.height() / totalHeight;
if (rightBottomBounds.top > leftTopBounds.top) {
// vertical apps, horizontal divider
this.visualDividerBounds = new Rect(leftTopBounds.left, leftTopBounds.bottom,
leftTopBounds.right, rightBottomBounds.top);
} else {
// horizontal apps, vertical divider
this.visualDividerBounds = new Rect(leftTopBounds.right, leftTopBounds.top,
rightBottomBounds.left, leftTopBounds.bottom);
}
leftTaskPercent = this.leftTopBounds.width() / (float) rightBottomBounds.right;
topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom;
}
}