Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec5abba9 authored by Thales Lima's avatar Thales Lima
Browse files

Add feature flag and attribute for responsive grid

This shouldn't change anything in the grids, only support the creation of responsive grids in the future. For now, to check that the flag works, turn it on and check the dumpsys. There is also a dump test created for this.

Fix: 277064696
Fix: 277064702
Test: DeviceProfileResponsiveDumpTest
Flag: ENABLE_RESPONSIVE_WORKSPACE
Change-Id: I1bef87043a100234bd661cd6ac00007fdc654116
parent b33a2e07
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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 -->
+6 −0
Original line number Diff line number Diff line
@@ -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);
+14 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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(
@@ -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] =
+4 −0
Original line number Diff line number Diff line
@@ -420,6 +420,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;
+2 −2
Original line number Diff line number Diff line
@@ -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)
    }
Loading