From 11af7bcd83566e2a7b2911dfd7a3ab955369775f Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Fri, 12 Aug 2022 15:24:54 +0100 Subject: [PATCH] Make inlineQsb a grid-option attr It should be per grid and not display size Fix: 242301548 Test: atest DeviceProfileTest Change-Id: I5ac11bd7162ce8102fd47c64039e339099ee8a05 --- res/values/attrs.xml | 25 +++++----- .../launcher3/InvariantDeviceProfile.java | 47 +++++++++---------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index df1ca14de2..726eb4d89b 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -184,7 +184,7 @@ - + @@ -193,6 +193,18 @@ + + + + + + + + + + + + @@ -373,17 +385,6 @@ - - - - - - - - - - - diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index cf2a3f8474..d518eca4f8 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -255,8 +255,6 @@ public class InvariantDeviceProfile { COUNT_SIZES); System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0, COUNT_SIZES); - System.arraycopy(defaultDisplayOption.inlineQsb, 0, result.inlineQsb, 0, - COUNT_SIZES); initGrid(context, myInfo, result, deviceType); } @@ -381,7 +379,7 @@ public class InvariantDeviceProfile { devicePaddings = new DevicePaddings(context, devicePaddingId); } - inlineQsb = displayOption.inlineQsb; + inlineQsb = closestProfile.inlineQsb; // If the partner customization apk contains any grid overrides, apply them // Supported overrides: numRows, numColumns, iconSize @@ -717,6 +715,12 @@ public class InvariantDeviceProfile { private static final int DEVICE_CATEGORY_ALL = DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY; + private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0; + private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1; + private static final int INLINE_QSB_FOR_TWO_PANEL_PORTRAIT = 1 << 2; + private static final int INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE = 1 << 3; + private static final int DONT_INLINE_QSB = 0; + public final String name; public final int numRows; public final int numColumns; @@ -733,6 +737,8 @@ public class InvariantDeviceProfile { private final int[] hotseatColumnSpan = new int[COUNT_SIZES]; + private final boolean[] inlineQsb = new boolean[COUNT_SIZES]; + private int inlineNavButtonsEndSpacing; private final String dbFile; @@ -805,6 +811,19 @@ public class InvariantDeviceProfile { && ((deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY) == DEVICE_CATEGORY_MULTI_DISPLAY)); + int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb, + DONT_INLINE_QSB); + inlineQsb[INDEX_DEFAULT] = + (inlineForRotation & INLINE_QSB_FOR_PORTRAIT) == INLINE_QSB_FOR_PORTRAIT; + inlineQsb[INDEX_LANDSCAPE] = + (inlineForRotation & INLINE_QSB_FOR_LANDSCAPE) == INLINE_QSB_FOR_LANDSCAPE; + inlineQsb[INDEX_TWO_PANEL_PORTRAIT] = + (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_PORTRAIT) + == INLINE_QSB_FOR_TWO_PANEL_PORTRAIT; + inlineQsb[INDEX_TWO_PANEL_LANDSCAPE] = + (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE) + == INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE; + a.recycle(); extraAttrs = Themes.createValueMap(context, attrs, IntArray.wrap(R.styleable.GridDisplayOption)); @@ -813,18 +832,11 @@ public class InvariantDeviceProfile { @VisibleForTesting static final class DisplayOption { - private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0; - private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1; - private static final int INLINE_QSB_FOR_TWO_PANEL_PORTRAIT = 1 << 2; - private static final int INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE = 1 << 3; - private static final int DONT_INLINE_QSB = 0; - public final GridOption grid; private final float minWidthDps; private final float minHeightDps; private final boolean canBeDefault; - private final boolean[] inlineQsb = new boolean[COUNT_SIZES]; private final PointF[] minCellSize = new PointF[COUNT_SIZES]; @@ -852,19 +864,6 @@ public class InvariantDeviceProfile { canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false); - int inlineForRotation = a.getInt(R.styleable.ProfileDisplayOption_inlineQsb, - DONT_INLINE_QSB); - inlineQsb[INDEX_DEFAULT] = - (inlineForRotation & INLINE_QSB_FOR_PORTRAIT) == INLINE_QSB_FOR_PORTRAIT; - inlineQsb[INDEX_LANDSCAPE] = - (inlineForRotation & INLINE_QSB_FOR_LANDSCAPE) == INLINE_QSB_FOR_LANDSCAPE; - inlineQsb[INDEX_TWO_PANEL_PORTRAIT] = - (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_PORTRAIT) - == INLINE_QSB_FOR_TWO_PANEL_PORTRAIT; - inlineQsb[INDEX_TWO_PANEL_LANDSCAPE] = - (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE) - == INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE; - float x; float y; @@ -1097,7 +1096,6 @@ public class InvariantDeviceProfile { allAppsIconSizes[i] = 0; allAppsIconTextSizes[i] = 0; allAppsBorderSpaces[i] = new PointF(); - inlineQsb[i] = false; } } @@ -1142,7 +1140,6 @@ public class InvariantDeviceProfile { allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i]; allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x; allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y; - inlineQsb[i] |= p.inlineQsb[i]; } folderBorderSpace += p.folderBorderSpace;