From dd027348dd980ee015887786c0b2aefbac515857 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Fri, 7 Jan 2022 12:54:37 +0000 Subject: [PATCH] create 6x5 scalable grid for tablets Create more attributes for landscape and fix the space between icons in the hotseat. The dimensions are correct but some size might differ from mocks because of device scaling, qsb position and insets not finalized. Bug: 210118169 Test: visual, using HSV and Window Change-Id: Ie505923dce2e30133eb1e5c9c83c33a2895147f2 --- res/values/attrs.xml | 8 ++++++++ src/com/android/launcher3/CellLayout.java | 16 +++++++++++++--- src/com/android/launcher3/DeviceProfile.java | 3 ++- .../launcher3/InvariantDeviceProfile.java | 13 +++++++++++-- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 5a46e1280e..095cb1aff5 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -185,6 +185,10 @@ + + + + @@ -242,6 +246,8 @@ + + @@ -268,6 +274,8 @@ + + diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index adb1613e9d..11f58e7d87 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -238,9 +238,19 @@ public class CellLayout extends ViewGroup { mActivity = ActivityContext.lookupContext(context); DeviceProfile deviceProfile = mActivity.getDeviceProfile(); - mBorderSpace = mContainerType == FOLDER - ? new Point(deviceProfile.folderCellLayoutBorderSpacePx) - : new Point(deviceProfile.cellLayoutBorderSpacePx); + switch (mContainerType) { + case FOLDER: + mBorderSpace = new Point(deviceProfile.folderCellLayoutBorderSpacePx); + break; + case HOTSEAT: + mBorderSpace = new Point(deviceProfile.hotseatBorderSpace, + deviceProfile.hotseatBorderSpace); + break; + case WORKSPACE: + default: + mBorderSpace = new Point(deviceProfile.cellLayoutBorderSpacePx); + break; + } mCellWidth = mCellHeight = -1; mFixedCellWidth = mFixedCellHeight = -1; diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 2a29f3bde7..be10d52474 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -161,7 +161,7 @@ public class DeviceProfile { public final int hotseatBarSidePaddingStartPx; public final int hotseatBarSidePaddingEndPx; public final int hotseatQsbHeight; - public final int hotseatBorderSpace; + public int hotseatBorderSpace; public final float qsbBottomMarginOriginalPx; public int qsbBottomMarginPx; @@ -716,6 +716,7 @@ public class DeviceProfile { } // Hotseat + hotseatBorderSpace = pxFromDp(inv.hotseatBorderSpaces[mTypeIndex], mMetrics, scale); updateHotseatIconSize(iconSizePx); if (!isVerticalLayout) { diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 2d0d640772..036726d682 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -789,6 +789,11 @@ public class InvariantDeviceProfile { x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidth, 0); y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeight, 0); minCellSize[INDEX_DEFAULT] = new PointF(x, y); + + x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthLandscape, + minCellSize[INDEX_DEFAULT].x); + y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightLandscape, + minCellSize[INDEX_DEFAULT].y); minCellSize[INDEX_LANDSCAPE] = new PointF(x, y); x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelPortrait, @@ -891,7 +896,9 @@ public class InvariantDeviceProfile { horizontalMargin[INDEX_DEFAULT] = a.getFloat( R.styleable.ProfileDisplayOption_horizontalMargin, 0); - horizontalMargin[INDEX_LANDSCAPE] = horizontalMargin[INDEX_DEFAULT]; + horizontalMargin[INDEX_LANDSCAPE] = a.getFloat( + R.styleable.ProfileDisplayOption_horizontalMarginLandscape, + horizontalMargin[INDEX_DEFAULT]); horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelLandscape, horizontalMargin[INDEX_DEFAULT]); @@ -901,7 +908,9 @@ public class InvariantDeviceProfile { hotseatBorderSpaces[INDEX_DEFAULT] = a.getFloat( R.styleable.ProfileDisplayOption_hotseatBorderSpace, borderSpace); - hotseatBorderSpaces[INDEX_LANDSCAPE] = hotseatBorderSpaces[INDEX_DEFAULT]; + hotseatBorderSpaces[INDEX_LANDSCAPE] = a.getFloat( + R.styleable.ProfileDisplayOption_hotseatBorderSpaceLandscape, + hotseatBorderSpaces[INDEX_DEFAULT]); hotseatBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat( R.styleable.ProfileDisplayOption_hotseatBorderSpaceTwoPanelLandscape, hotseatBorderSpaces[INDEX_DEFAULT]);