Various multi-window fixes

> Fixing scale up calculator for swipe-down
> Offsetting pivot so that the preview is aligned to bottom-right
> Allowing insets to be available in multi-window mode as well
> Offsetting taskViewSimulator appropriately in multi-window mode

Change-Id: I7da4c145efca72ef219a5ffcaf23d726812df270
This commit is contained in:
Sunny Goyal
2020-04-28 14:17:35 -07:00
parent df5d99f419
commit 0addbf0512
20 changed files with 329 additions and 268 deletions

View File

@@ -45,6 +45,8 @@ public class DeviceProfile {
public final boolean isLandscape;
public final boolean isMultiWindowMode;
public final int windowX;
public final int windowY;
public final int widthPx;
public final int heightPx;
public final int availableWidthPx;
@@ -133,13 +135,16 @@ public class DeviceProfile {
public DotRenderer mDotRendererWorkSpace;
public DotRenderer mDotRendererAllApps;
public DeviceProfile(Context context, InvariantDeviceProfile inv, DefaultDisplay.Info info,
DeviceProfile(Context context, InvariantDeviceProfile inv, DefaultDisplay.Info info,
Point minSize, Point maxSize, int width, int height, boolean isLandscape,
boolean isMultiWindowMode, boolean transposeLayoutWithOrientation) {
boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
Point windowPosition) {
this.inv = inv;
this.isLandscape = isLandscape;
this.isMultiWindowMode = isMultiWindowMode;
windowX = windowPosition.x;
windowY = windowPosition.y;
// Determine sizes.
widthPx = width;
@@ -244,6 +249,7 @@ public class DeviceProfile {
return new Builder(context, inv, mInfo)
.setSizeRange(size, size)
.setSize(widthPx, heightPx)
.setWindowPosition(windowX, windowY)
.setMultiWindowMode(isMultiWindowMode);
}
@@ -254,10 +260,11 @@ public class DeviceProfile {
/**
* TODO: Move this to the builder as part of setMultiWindowMode
*/
public DeviceProfile getMultiWindowProfile(Context context, Point mwSize) {
public DeviceProfile getMultiWindowProfile(Context context, Rect windowPosition) {
// We take the minimum sizes of this profile and it's multi-window variant to ensure that
// the system decor is always excluded.
mwSize.set(Math.min(availableWidthPx, mwSize.x), Math.min(availableHeightPx, mwSize.y));
Point mwSize = new Point(Math.min(availableWidthPx, windowPosition.width()),
Math.min(availableHeightPx, windowPosition.height()));
// In multi-window mode, we can have widthPx = availableWidthPx
// and heightPx = availableHeightPx because Launcher uses the InvariantDeviceProfiles'
@@ -265,6 +272,7 @@ public class DeviceProfile {
DeviceProfile profile = toBuilder(context)
.setSizeRange(mwSize, mwSize)
.setSize(mwSize.x, mwSize.y)
.setWindowPosition(windowPosition.left, windowPosition.top)
.setMultiWindowMode(true)
.build();
@@ -286,7 +294,7 @@ public class DeviceProfile {
}
/**
* Inverse of {@link #getMultiWindowProfile(Context, Point)}
* Inverse of {@link #getMultiWindowProfile(Context, Rect)}
* @return device profile corresponding to the current orientation in non multi-window mode.
*/
public DeviceProfile getFullScreenProfile() {
@@ -649,6 +657,7 @@ public class DeviceProfile {
private InvariantDeviceProfile mInv;
private DefaultDisplay.Info mInfo;
private final Point mWindowPosition = new Point();
private Point mMinSize, mMaxSize;
private int mWidth, mHeight;
@@ -682,6 +691,14 @@ public class DeviceProfile {
return this;
}
/**
* Sets the window position if not full-screen
*/
public Builder setWindowPosition(int x, int y) {
mWindowPosition.set(x, y);
return this;
}
public Builder setTransposeLayoutWithOrientation(boolean transposeLayoutWithOrientation) {
mTransposeLayoutWithOrientation = transposeLayoutWithOrientation;
return this;
@@ -690,7 +707,7 @@ public class DeviceProfile {
public DeviceProfile build() {
return new DeviceProfile(mContext, mInv, mInfo, mMinSize, mMaxSize,
mWidth, mHeight, mIsLandscape, mIsMultiWindowMode,
mTransposeLayoutWithOrientation);
mTransposeLayoutWithOrientation, mWindowPosition);
}
}