From a25cd90b5e730f0a6f9e9f281b4801d2f96906c4 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Wed, 1 Nov 2023 12:00:32 +0000 Subject: [PATCH] Center AllApps on the screen AllApps used workspace paddings which are unbalanced in verticalBar. This changes it to always be centered. In dynamic grid AllApps now uses the whole width for the layout. In responsive grid it keeps the cell width and center the layout. Note that this is centered on the screen but nothing could be done regarding the camera inset at this time, as it would need a refactor of how AllApps QSB is layout as well. Bug: 269632571 Test: NexusLauncherTest Flag: ACONFIG com.android.launcher3.enable_responsive_workspace TEAMFOOD Change-Id: I326d041bcef211d398d1a5c3210958b689414d49 --- src/com/android/launcher3/DeviceProfile.java | 14 +++++++++----- .../allapps/ActivityAllAppsContainerView.java | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 2ed33ec656..b1e833bff1 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -611,10 +611,10 @@ public class DeviceProfile { isTwoPanels ? inv.allAppsSpecsTwoPanelId : inv.allAppsSpecsId), ResponsiveSpecType.AllApps); mAllAppsResponsiveWidthSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, - DimensionType.WIDTH, numColumns, mResponsiveWidthSpec.getAvailableSpace(), + DimensionType.WIDTH, numColumns, availableWidthPx, mResponsiveWidthSpec); mAllAppsResponsiveHeightSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, - DimensionType.HEIGHT, inv.numRows, mResponsiveHeightSpec.getAvailableSpace(), + DimensionType.HEIGHT, inv.numRows, heightPx - mInsets.top, mResponsiveHeightSpec); ResponsiveSpecsProvider folderSpecs = ResponsiveSpecsProvider.create( @@ -1271,8 +1271,12 @@ public class DeviceProfile { allAppsCellHeightPx = mAllAppsResponsiveHeightSpec.getCellSizePx() + mAllAppsResponsiveHeightSpec.getGutterPx(); allAppsCellWidthPx = mAllAppsResponsiveWidthSpec.getCellSizePx(); - allAppsPadding.left = mAllAppsResponsiveWidthSpec.getStartPaddingPx(); - allAppsPadding.right = mAllAppsResponsiveWidthSpec.getEndPaddingPx(); + + // This workaround is needed to align AllApps icons with Workspace icons + // since AllApps doesn't have borders between cells + int halfBorder = allAppsBorderSpacePx.x / 2; + allAppsPadding.left = mAllAppsResponsiveWidthSpec.getStartPaddingPx() - halfBorder; + allAppsPadding.right = mAllAppsResponsiveWidthSpec.getEndPaddingPx() - halfBorder; } /** @@ -1293,7 +1297,7 @@ public class DeviceProfile { + (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1)) + allAppsPadding.left + allAppsPadding.right; allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2); - } else { + } else if (!mIsResponsiveGrid) { allAppsPadding.left = allAppsPadding.right = Math.max(0, desiredWorkspaceHorizontalMarginPx + cellLayoutHorizontalPadding - (allAppsBorderSpacePx.x / 2)); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index d822fec4cf..5b4d2b8f85 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -1101,7 +1101,7 @@ public class ActivityAllAppsContainerView mlp.rightMargin = insets.right; setLayoutParams(mlp); - if (grid.isVerticalBarLayout()) { + if (grid.isVerticalBarLayout() && !FeatureFlags.enableResponsiveWorkspace()) { setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0); } else { int topPadding = grid.allAppsPadding.top; @@ -1111,7 +1111,6 @@ public class ActivityAllAppsContainerView } setPadding(grid.allAppsLeftRightMargin, topPadding, grid.allAppsLeftRightMargin, 0); } - InsettableFrameLayout.dispatchInsets(this, insets); }