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

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

launcher: more options for all apps icon sizes

Different postures now require different icons sizes, changes in spaces and text size. This should give enough options to change the sizes in All Apps the same was as in the home screen.

Bug: 202708085
Test: visual, using HSV and Window
Change-Id: I40a28f27a19b5728a950a4b43f4239c1ba26c2a4
parent 6e7f36c8
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -221,11 +221,23 @@

        <!-- defaults to borderSpace, if not specified -->
        <attr name="allAppsBorderSpace" format="float" />
        <!-- defaults to allAppsBorderSpace, if not specified -->
        <attr name="allAppsBorderSpaceTwoPanelPortrait" format="float" />
        <!-- defaults to allAppsBorderSpace, if not specified -->
        <attr name="allAppsBorderSpaceTwoPanelLandscape" format="float" />
        <!-- The following values are only enabled if grid is supported. -->
        <!-- defaults to iconImageSize, if not specified -->
        <attr name="allAppsIconSize" format="float" />
        <!-- defaults to allAppsIconSize, if not specified -->
        <attr name="allAppsIconSizeTwoPanelPortrait" format="float" />
        <!-- defaults to allAppsIconSize, if not specified -->
        <attr name="allAppsIconSizeTwoPanelLandscape" format="float" />
        <!-- defaults to iconTextSize, if not specified -->
        <attr name="allAppsIconTextSize" format="float" />
        <!-- defaults to allAppsIconTextSize, if not specified -->
        <attr name="allAppsIconTextSizeTwoPanelPortrait" format="float" />
        <!-- defaults to allAppsIconTextSize, if not specified -->
        <attr name="allAppsIconTextSizeTwoPanelLandscape" format="float" />

        <!-- defaults to borderSpaceDps, if not specified -->
        <attr name="hotseatBorderSpace" format="float" />
+5 −5
Original line number Diff line number Diff line
@@ -292,8 +292,8 @@ public class DeviceProfile {

        cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv);
        allAppsBorderSpacePx = new Point(
                pxFromDp(inv.borderSpaces[InvariantDeviceProfile.INDEX_ALL_APPS].x, mMetrics, 1f),
                pxFromDp(inv.borderSpaces[InvariantDeviceProfile.INDEX_ALL_APPS].y, mMetrics, 1f));
                pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].x, mMetrics),
                pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics));
        cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx);
        folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics, 1f);
        folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx,
@@ -697,9 +697,9 @@ public class DeviceProfile {
        // All apps
        if (numShownAllAppsColumns != inv.numColumns) {
            allAppsIconSizePx =
                    pxFromDp(inv.iconSize[InvariantDeviceProfile.INDEX_ALL_APPS], mMetrics);
                    pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics);
            allAppsIconTextSizePx =
                    pxFromSp(inv.iconTextSize[InvariantDeviceProfile.INDEX_ALL_APPS], mMetrics);
                    pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics);
            allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
            autoResizeAllAppsCells();
        } else {
@@ -708,7 +708,7 @@ public class DeviceProfile {
            allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
            allAppsCellHeightPx = getCellSize().y;
        }
        allAppsCellWidthPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx;
        allAppsCellWidthPx = allAppsIconSizePx + (2 * allAppsIconDrawablePaddingPx);
        updateAllAppsWidth();

        if (isVerticalLayout) {
+57 −15
Original line number Diff line number Diff line
@@ -94,12 +94,11 @@ public class InvariantDeviceProfile {

    // Used for arrays to specify different sizes (e.g. border spaces, width/height) in different
    // constraints
    static final int COUNT_SIZES = 5;
    static final int COUNT_SIZES = 4;
    static final int INDEX_DEFAULT = 0;
    static final int INDEX_LANDSCAPE = 1;
    static final int INDEX_TWO_PANEL_PORTRAIT = 2;
    static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
    static final int INDEX_ALL_APPS = 4;

    /**
     * Number of icons per row and column in the workspace.
@@ -126,6 +125,10 @@ public class InvariantDeviceProfile {

    public float[] horizontalMargin;

    public float[] allAppsIconSize;
    public float[] allAppsIconTextSize;
    public PointF[] allAppsBorderSpaces;

    private SparseArray<TypedValue> mExtraAttrs;

    /**
@@ -338,9 +341,12 @@ public class InvariantDeviceProfile {
        numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
                ? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;

        allAppsBorderSpaces = displayOption.allAppsBorderSpaces;
        allAppsIconSize = displayOption.allAppsIconSizes;
        allAppsIconTextSize = displayOption.allAppsIconTextSizes;
        if (!Utilities.isGridOptionsEnabled(context)) {
            iconSize[INDEX_ALL_APPS] = iconSize[INDEX_DEFAULT];
            iconTextSize[INDEX_ALL_APPS] = iconTextSize[INDEX_DEFAULT];
            allAppsIconSize = iconSize;
            allAppsIconTextSize = iconTextSize;
        }

        if (devicePaddingId != 0) {
@@ -763,6 +769,10 @@ public class InvariantDeviceProfile {
        private final float[] iconSizes = new float[COUNT_SIZES];
        private final float[] textSizes = new float[COUNT_SIZES];

        private final float[] allAppsIconSizes = new float[COUNT_SIZES];
        private final float[] allAppsIconTextSizes = new float[COUNT_SIZES];
        private final PointF[] allAppsBorderSpaces = new PointF[COUNT_SIZES];

        DisplayOption(GridOption grid, Context context, AttributeSet attrs) {
            this.grid = grid;

@@ -780,7 +790,6 @@ public class InvariantDeviceProfile {
            y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeight, 0);
            minCellSize[INDEX_DEFAULT] = new PointF(x, y);
            minCellSize[INDEX_LANDSCAPE] = new PointF(x, y);
            minCellSize[INDEX_ALL_APPS] = new PointF(x, y);

            x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthTwoPanelPortrait,
                    minCellSize[INDEX_DEFAULT].x);
@@ -821,19 +830,26 @@ public class InvariantDeviceProfile {
                    borderSpaceTwoPanelLandscape);
            borderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);

            folderBorderSpace = borderSpace;

            x = y = a.getFloat(R.styleable.ProfileDisplayOption_allAppsBorderSpace,
                    borderSpace);
            borderSpaces[INDEX_ALL_APPS] = new PointF(x, y);
            folderBorderSpace = borderSpace;
            allAppsBorderSpaces[INDEX_DEFAULT] = new PointF(x, y);
            allAppsBorderSpaces[INDEX_LANDSCAPE] = new PointF(x, y);
            x = y = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelPortrait,
                    allAppsBorderSpaces[INDEX_DEFAULT].x);
            allAppsBorderSpaces[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
            x = y = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsBorderSpaceTwoPanelLandscape,
                    allAppsBorderSpaces[INDEX_DEFAULT].x);
            allAppsBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);

            iconSizes[INDEX_DEFAULT] =
                    a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0);
            iconSizes[INDEX_LANDSCAPE] =
                    a.getFloat(R.styleable.ProfileDisplayOption_iconSizeLandscape,
                            iconSizes[INDEX_DEFAULT]);
            iconSizes[INDEX_ALL_APPS] =
                    a.getFloat(R.styleable.ProfileDisplayOption_allAppsIconSize,
                            iconSizes[INDEX_DEFAULT]);
            iconSizes[INDEX_TWO_PANEL_PORTRAIT] =
                    a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelPortrait,
                            iconSizes[INDEX_DEFAULT]);
@@ -841,14 +857,21 @@ public class InvariantDeviceProfile {
                    a.getFloat(R.styleable.ProfileDisplayOption_iconSizeTwoPanelLandscape,
                            iconSizes[INDEX_DEFAULT]);

            allAppsIconSizes[INDEX_DEFAULT] = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]);
            allAppsIconSizes[INDEX_LANDSCAPE] = allAppsIconSizes[INDEX_DEFAULT];
            allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait,
                    allAppsIconSizes[INDEX_DEFAULT]);
            allAppsIconSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelLandscape,
                    allAppsIconSizes[INDEX_DEFAULT]);

            textSizes[INDEX_DEFAULT] =
                    a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0);
            textSizes[INDEX_LANDSCAPE] =
                    a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeLandscape,
                            textSizes[INDEX_DEFAULT]);
            textSizes[INDEX_ALL_APPS] =
                    a.getFloat(R.styleable.ProfileDisplayOption_allAppsIconTextSize,
                            textSizes[INDEX_DEFAULT]);
            textSizes[INDEX_TWO_PANEL_PORTRAIT] =
                    a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelPortrait,
                            textSizes[INDEX_DEFAULT]);
@@ -856,10 +879,19 @@ public class InvariantDeviceProfile {
                    a.getFloat(R.styleable.ProfileDisplayOption_iconTextSizeTwoPanelLandscape,
                            textSizes[INDEX_DEFAULT]);

            allAppsIconTextSizes[INDEX_DEFAULT] = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsIconTextSize, textSizes[INDEX_DEFAULT]);
            allAppsIconTextSizes[INDEX_LANDSCAPE] = allAppsIconTextSizes[INDEX_DEFAULT];
            allAppsIconTextSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelPortrait,
                    allAppsIconTextSizes[INDEX_DEFAULT]);
            allAppsIconTextSizes[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
                    R.styleable.ProfileDisplayOption_allAppsIconTextSizeTwoPanelLandscape,
                    allAppsIconTextSizes[INDEX_DEFAULT]);

            horizontalMargin[INDEX_DEFAULT] = a.getFloat(
                    R.styleable.ProfileDisplayOption_horizontalMargin, 0);
            horizontalMargin[INDEX_LANDSCAPE] = horizontalMargin[INDEX_DEFAULT];
            horizontalMargin[INDEX_ALL_APPS] = horizontalMargin[INDEX_DEFAULT];
            horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
                    R.styleable.ProfileDisplayOption_horizontalMarginTwoPanelLandscape,
                    horizontalMargin[INDEX_DEFAULT]);
@@ -870,7 +902,6 @@ public class InvariantDeviceProfile {
            hotseatBorderSpaces[INDEX_DEFAULT] = a.getFloat(
                    R.styleable.ProfileDisplayOption_hotseatBorderSpace, borderSpace);
            hotseatBorderSpaces[INDEX_LANDSCAPE] = hotseatBorderSpaces[INDEX_DEFAULT];
            hotseatBorderSpaces[INDEX_ALL_APPS] = hotseatBorderSpaces[INDEX_DEFAULT];
            hotseatBorderSpaces[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
                    R.styleable.ProfileDisplayOption_hotseatBorderSpaceTwoPanelLandscape,
                    hotseatBorderSpaces[INDEX_DEFAULT]);
@@ -895,6 +926,9 @@ public class InvariantDeviceProfile {
                textSizes[i] = 0;
                borderSpaces[i] = new PointF();
                minCellSize[i] = new PointF();
                allAppsIconSizes[i] = 0;
                allAppsIconTextSizes[i] = 0;
                allAppsBorderSpaces[i] = new PointF();
            }
        }

@@ -908,6 +942,10 @@ public class InvariantDeviceProfile {
                minCellSize[i].y *= w;
                horizontalMargin[i] *= w;
                hotseatBorderSpaces[i] *= w;
                allAppsIconSizes[i] *= w;
                allAppsIconTextSizes[i] *= w;
                allAppsBorderSpaces[i].x *= w;
                allAppsBorderSpaces[i].y *= w;
            }

            folderBorderSpace *= w;
@@ -925,6 +963,10 @@ public class InvariantDeviceProfile {
                minCellSize[i].y += p.minCellSize[i].y;
                horizontalMargin[i] += p.horizontalMargin[i];
                hotseatBorderSpaces[i] += p.hotseatBorderSpaces[i];
                allAppsIconSizes[i] += p.allAppsIconSizes[i];
                allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i];
                allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x;
                allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y;
            }

            folderBorderSpace += p.folderBorderSpace;