From ab800f71d05989f5058de12faca9b9b7c96a3392 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 13 Dec 2022 17:46:06 +0000 Subject: [PATCH] Temporarily use 1f bottomSheetDepth for multi-display Bug: 259893832 Test: Manual and DeviceProfileDumpTest Change-Id: I196958e6f9f889de003b4d3a22a176bfd7e49511 --- src/com/android/launcher3/DeviceProfile.java | 37 ++++++++++++------- .../launcher3/InvariantDeviceProfile.java | 2 +- .../launcher3/config/FeatureFlags.java | 4 ++ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index eb016b2193..bfde8da6a9 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -23,6 +23,7 @@ import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_PORTR import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.Utilities.pxFromSp; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.config.FeatureFlags.ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH; import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR; import static com.android.launcher3.icons.GraphicsUtils.getShapePath; import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE; @@ -78,6 +79,7 @@ public class DeviceProfile { public final boolean isTablet; public final boolean isPhone; public final boolean transposeLayoutWithOrientation; + public final boolean isMultiDisplay; public final boolean isTwoPanels; public final boolean isQsbInline; @@ -263,13 +265,14 @@ public class DeviceProfile { /** TODO: Once we fully migrate to staged split, remove "isMultiWindowMode" */ DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds, SparseArray dotRendererCache, boolean isMultiWindowMode, - boolean transposeLayoutWithOrientation, boolean useTwoPanels, boolean isGestureMode, + boolean transposeLayoutWithOrientation, boolean isMultiDisplay, boolean isGestureMode, @NonNull final ViewScaleProvider viewScaleProvider) { this.inv = inv; this.isLandscape = windowBounds.isLandscape(); this.isMultiWindowMode = isMultiWindowMode; this.transposeLayoutWithOrientation = transposeLayoutWithOrientation; + this.isMultiDisplay = isMultiDisplay; this.isGestureMode = isGestureMode; windowX = windowBounds.bounds.left; windowY = windowBounds.bounds.top; @@ -281,7 +284,7 @@ public class DeviceProfile { mInfo = info; isTablet = info.isTablet(windowBounds); isPhone = !isTablet; - isTwoPanels = isTablet && useTwoPanels; + isTwoPanels = isTablet && isMultiDisplay; isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS; // Some more constants. @@ -348,13 +351,19 @@ public class DeviceProfile { bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration); if (isTablet) { bottomSheetWorkspaceScale = workspaceContentScale; - // The goal is to set wallpaper to zoom at workspaceContentScale when in AllApps. - // When depth is 0, wallpaper zoom is set to maxWallpaperScale. - // When depth is 1, wallpaper zoom is set to 1. - // For depth to achieve zoom set to maxWallpaperScale * workspaceContentScale: - float maxWallpaperScale = res.getFloat(R.dimen.config_wallpaperMaxScale); - bottomSheetDepth = Utilities.mapToRange(maxWallpaperScale * workspaceContentScale, - maxWallpaperScale, 1f, 0f, 1f, LINEAR); + if (isMultiDisplay && !ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH.get()) { + // TODO(b/259893832): Revert to use maxWallpaperScale to calculate bottomSheetDepth + // when screen recorder bug is fixed. + bottomSheetDepth = 1f; + } else { + // The goal is to set wallpaper to zoom at workspaceContentScale when in AllApps. + // When depth is 0, wallpaper zoom is set to maxWallpaperScale. + // When depth is 1, wallpaper zoom is set to 1. + // For depth to achieve zoom set to maxWallpaperScale * workspaceContentScale: + float maxWallpaperScale = res.getFloat(R.dimen.config_wallpaperMaxScale); + bottomSheetDepth = Utilities.mapToRange(maxWallpaperScale * workspaceContentScale, + maxWallpaperScale, 1f, 0f, 1f, LINEAR); + } } else { bottomSheetWorkspaceScale = 1f; bottomSheetDepth = 0f; @@ -723,7 +732,7 @@ public class DeviceProfile { return new Builder(context, inv, mInfo) .setWindowBounds(bounds) - .setUseTwoPanels(isTwoPanels) + .setIsMultiDisplay(isMultiDisplay) .setMultiWindowMode(isMultiWindowMode) .setDotRendererCache(dotRendererCache) .setGestureMode(isGestureMode); @@ -1714,7 +1723,7 @@ public class DeviceProfile { private Info mInfo; private WindowBounds mWindowBounds; - private boolean mUseTwoPanels; + private boolean mIsMultiDisplay; private boolean mIsMultiWindowMode = false; private Boolean mTransposeLayoutWithOrientation; @@ -1734,8 +1743,8 @@ public class DeviceProfile { return this; } - public Builder setUseTwoPanels(boolean useTwoPanels) { - mUseTwoPanels = useTwoPanels; + public Builder setIsMultiDisplay(boolean isMultiDisplay) { + mIsMultiDisplay = isMultiDisplay; return this; } @@ -1789,7 +1798,7 @@ public class DeviceProfile { mViewScaleProvider = DEFAULT_PROVIDER; } return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mDotRendererCache, - mIsMultiWindowMode, mTransposeLayoutWithOrientation, mUseTwoPanels, + mIsMultiWindowMode, mTransposeLayoutWithOrientation, mIsMultiDisplay, mIsGestureMode, mViewScaleProvider); } } diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 594d7cbd82..806e7b13e7 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -400,7 +400,7 @@ public class InvariantDeviceProfile { SparseArray dotRendererCache = new SparseArray<>(); for (WindowBounds bounds : displayInfo.supportedBounds) { localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo) - .setUseTwoPanels(deviceType == TYPE_MULTI_DISPLAY) + .setIsMultiDisplay(deviceType == TYPE_MULTI_DISPLAY) .setWindowBounds(bounds) .setDotRendererCache(dotRendererCache) .build()); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index c56186aa1d..0e546ed436 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -303,6 +303,10 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_WIDGET_PICKER_DEPTH = new DeviceFlag( "ENABLE_WIDGET_PICKER_DEPTH", true, "Enable changing depth in widget picker."); + public static final BooleanFlag ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH = getDebugFlag( + "ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH", false, + "Allow bottom sheet depth to be smaller than 1 for multi-display devices."); + public static final BooleanFlag SCROLL_TOP_TO_RESET = new DeviceFlag( "SCROLL_TOP_TO_RESET", true, "Bring up IME and focus on " + "input when scroll to top if 'Always show keyboard' is enabled or in prefix state");