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

Commit 0740b7fb authored by Thales Lima's avatar Thales Lima Committed by Android (Google) Code Review
Browse files

Merge "Add feature flag and attribute for responsive grid" into udc-dev

parents 09b42b3d ec5abba9
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
@@ -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;
+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