Merge "Add feature flag and attribute for responsive grid" into udc-dev am: 0740b7fb43

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/22476842

Change-Id: I3b885fb6ed534a68f253a55a5e3ef2d39098fe39
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Thales Lima
2023-05-10 10:04:12 +00:00
committed by Automerger Merge Worker
6 changed files with 41 additions and 4 deletions

View File

@@ -199,6 +199,9 @@
<attr name="demoModeLayoutId" format="reference" />
<attr name="isScalable" format="boolean" />
<attr name="devicePaddingId" format="reference" />
<!-- File that contains the specs for the workspace.
Needs FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE enabled -->
<attr name="workspaceSpecsId" format="reference" />
<!-- By default all categories are enabled -->
<attr name="deviceCategory" format="integer">
<!-- Enable on phone only -->

View File

@@ -101,6 +101,7 @@ public class DeviceProfile {
public final float aspectRatio;
public final boolean isScalableGrid;
public final boolean isResponsiveGrid;
private final int mTypeIndex;
/**
@@ -293,6 +294,10 @@ public class DeviceProfile {
this.rotationHint = windowBounds.rotationHint;
mInsets.set(windowBounds.insets);
// TODO(b/241386436):
// for testing that the flag works only, shouldn't change any launcher behaviour
isResponsiveGrid = inv.workspaceSpecsId != INVALID_RESOURCE_HANDLE;
isScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode;
// Determine device posture.
mInfo = info;
@@ -1577,6 +1582,7 @@ public class DeviceProfile {
writer.println(prefix + "\taspectRatio:" + aspectRatio);
writer.println(prefix + "\tisResponsiveGrid:" + isResponsiveGrid);
writer.println(prefix + "\tisScalableGrid:" + isScalableGrid);
writer.println(prefix + "\tinv.numRows: " + inv.numRows);

View File

@@ -48,6 +48,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.annotation.XmlRes;
import androidx.core.content.res.ResourcesCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.model.DeviceGridState;
import com.android.launcher3.provider.RestoreDbTask;
@@ -105,7 +106,7 @@ public class InvariantDeviceProfile {
static final int INDEX_TWO_PANEL_PORTRAIT = 2;
static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
/** These resources are used to override the device profile */
/** These resources are used to override the device profile */
private static final String RES_GRID_NUM_ROWS = "grid_num_rows";
private static final String RES_GRID_NUM_COLUMNS = "grid_num_columns";
private static final String RES_GRID_ICON_SIZE_DP = "grid_icon_size_dp";
@@ -177,6 +178,8 @@ public class InvariantDeviceProfile {
protected boolean isScalable;
@XmlRes
public int devicePaddingId = INVALID_RESOURCE_HANDLE;
@XmlRes
public int workspaceSpecsId = INVALID_RESOURCE_HANDLE;
public String dbFile;
public int defaultLayoutId;
@@ -350,6 +353,7 @@ public class InvariantDeviceProfile {
isScalable = closestProfile.isScalable;
devicePaddingId = closestProfile.devicePaddingId;
workspaceSpecsId = closestProfile.mWorkspaceSpecsId;
this.deviceType = deviceType;
inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing;
@@ -795,6 +799,7 @@ public class InvariantDeviceProfile {
private final boolean isScalable;
private final int devicePaddingId;
private final int mWorkspaceSpecsId;
public GridOption(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(
@@ -836,7 +841,7 @@ public class InvariantDeviceProfile {
inlineNavButtonsEndSpacing =
a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing,
R.dimen.taskbar_button_margin_default);
R.dimen.taskbar_button_margin_default);
numFolderRows = a.getInt(
R.styleable.GridDisplayOption_numFolderRows, numRows);
@@ -856,6 +861,13 @@ public class InvariantDeviceProfile {
deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory,
DEVICE_CATEGORY_ALL);
if (FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE.get()) {
mWorkspaceSpecsId = a.getResourceId(
R.styleable.GridDisplayOption_workspaceSpecsId, INVALID_RESOURCE_HANDLE);
} else {
mWorkspaceSpecsId = INVALID_RESOURCE_HANDLE;
}
int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb,
DONT_INLINE_QSB);
inlineQsb[INDEX_DEFAULT] =

View File

@@ -416,6 +416,10 @@ public final class FeatureFlags {
// TODO(Block 32): Empty block
public static final BooleanFlag ENABLE_RESPONSIVE_WORKSPACE = getDebugFlag(241386436,
"ENABLE_RESPONSIVE_WORKSPACE", DISABLED,
"Enables new workspace grid calculations method.");
public static class BooleanFlag {
private final boolean mCurrentValue;

View File

@@ -50,7 +50,7 @@ abstract class AbstractDeviceProfileTest {
private lateinit var originalWindowManagerProxy: WindowManagerProxy
@Before
fun setUp() {
open fun setUp() {
val appContext: Context = ApplicationProvider.getApplicationContext()
originalWindowManagerProxy = WindowManagerProxy.INSTANCE.get(appContext)
originalDisplayController = DisplayController.INSTANCE.get(appContext)
@@ -59,7 +59,7 @@ abstract class AbstractDeviceProfileTest {
}
@After
fun tearDown() {
open fun tearDown() {
WindowManagerProxy.INSTANCE.initializeForTesting(originalWindowManagerProxy)
DisplayController.INSTANCE.initializeForTesting(originalDisplayController)
}

View File

@@ -58,6 +58,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 126.0px (48.0dp)\n" +
"\taspectRatio:2.2222223\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 5\n" +
@@ -193,6 +194,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 63.0px (24.0dp)\n" +
"\taspectRatio:2.2222223\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 5\n" +
@@ -328,6 +330,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 126.0px (48.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:2.2222223\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 5\n" +
@@ -463,6 +466,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 63.0px (24.0dp)\n" +
"\taspectRatio:2.2222223\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 5\n" +
@@ -599,6 +603,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.6\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:true\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 6\n" +
@@ -735,6 +740,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.6\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:true\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 6\n" +
@@ -871,6 +877,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.6\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:true\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 6\n" +
@@ -1007,6 +1014,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.6\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:true\n" +
"\tinv.numRows: 5\n" +
"\tinv.numColumns: 6\n" +
@@ -1148,6 +1156,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.2\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 4\n" +
"\tinv.numColumns: 4\n" +
@@ -1288,6 +1297,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.2\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 4\n" +
"\tinv.numColumns: 4\n" +
@@ -1428,6 +1438,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.2\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 4\n" +
"\tinv.numColumns: 4\n" +
@@ -1564,6 +1575,7 @@ class DeviceProfileDumpTest : AbstractDeviceProfileTest() {
"\tmInsets.right: 0.0px (0.0dp)\n" +
"\tmInsets.bottom: 0.0px (0.0dp)\n" +
"\taspectRatio:1.2\n" +
"\tisResponsiveGrid:false\n" +
"\tisScalableGrid:false\n" +
"\tinv.numRows: 4\n" +
"\tinv.numColumns: 4\n" +