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

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

Merge changes from topic "numFolderRows" into main

* changes:
  Update dump tests
  Make numFolderRows/Columns accept more values
parents d761f5c3 0c9e869a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -164,7 +164,19 @@

        <!-- numFolderRows & numFolderColumns defaults to numRows & numColumns, if not specified -->
        <attr name="numFolderRows" format="integer" />
        <!-- defaults to numFolderRows, if not specified -->
        <attr name="numFolderRowsLandscape" format="integer" />
        <!-- defaults to numFolderRows, if not specified -->
        <attr name="numFolderRowsTwoPanelLandscape" format="integer" />
        <!-- defaults to numFolderRows, if not specified -->
        <attr name="numFolderRowsTwoPanelPortrait" format="integer" />
        <attr name="numFolderColumns" format="integer" />
        <!-- defaults to numFolderColumns, if not specified -->
        <attr name="numFolderColumnsLandscape" format="integer" />
        <!-- defaults to numFolderColumns, if not specified -->
        <attr name="numFolderColumnsTwoPanelLandscape" format="integer" />
        <!-- defaults to numFolderColumns, if not specified -->
        <attr name="numFolderColumnsTwoPanelPortrait" format="integer" />
        <!-- Support attributes in FolderStyle -->
        <attr name="folderStyle" format="reference" />

+12 −8
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ public class DeviceProfile {
    public int cellYPaddingPx = -1;

    // Folder
    public final int numFolderRows;
    public final int numFolderColumns;
    public final float folderLabelTextScale;
    public int folderLabelTextSizePx;
    public int folderFooterHeightPx;
@@ -439,6 +441,8 @@ public class DeviceProfile {
        }

        folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
        numFolderRows = inv.numFolderRows[mTypeIndex];
        numFolderColumns = inv.numFolderColumns[mTypeIndex];

        if (mIsScalableGrid && inv.folderStyle != INVALID_RESOURCE_HANDLE) {
            TypedArray folderStyle = context.obtainStyledAttributes(inv.folderStyle,
@@ -645,11 +649,11 @@ public class DeviceProfile {
                            isTwoPanels ? inv.folderSpecsTwoPanelId : inv.folderSpecsId),
                    ResponsiveSpecType.Folder);
            mResponsiveFolderWidthSpec = folderSpecs.getCalculatedSpec(responsiveAspectRatio,
                    DimensionType.WIDTH, inv.numFolderColumns,
                    DimensionType.WIDTH, numFolderColumns,
                    mResponsiveWorkspaceWidthSpec.getAvailableSpace(),
                    mResponsiveWorkspaceWidthSpec);
            mResponsiveFolderHeightSpec = folderSpecs.getCalculatedSpec(responsiveAspectRatio,
                    DimensionType.HEIGHT, inv.numFolderRows,
                    DimensionType.HEIGHT, numFolderRows,
                    mResponsiveWorkspaceHeightSpec.getAvailableSpace(),
                    mResponsiveWorkspaceHeightSpec);

@@ -1406,16 +1410,16 @@ public class DeviceProfile {
        Point totalWorkspacePadding = getTotalWorkspacePadding();

        // Check if the folder fit within the available height.
        float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
                + ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacePx.y)
        float contentUsedHeight = folderCellHeightPx * numFolderRows
                + ((numFolderRows - 1) * folderCellLayoutBorderSpacePx.y)
                + folderFooterHeightPx
                + folderContentPaddingTop;
        int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y;
        float scaleY = contentMaxHeight / contentUsedHeight;

        // Check if the folder fit within the available width.
        float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
                + ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x)
        float contentUsedWidth = folderCellWidthPx * numFolderColumns
                + ((numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x)
                + folderContentPaddingLeftRight * 2;
        int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x;
        float scaleX = contentMaxWidth / contentUsedWidth;
@@ -2045,8 +2049,8 @@ public class DeviceProfile {
        writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx));
        writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx));

        writer.println(prefix + "\tinv.numFolderRows: " + inv.numFolderRows);
        writer.println(prefix + "\tinv.numFolderColumns: " + inv.numFolderColumns);
        writer.println(prefix + "\tnumFolderRows: " + numFolderRows);
        writer.println(prefix + "\tnumFolderColumns: " + numFolderColumns);
        writer.println(prefix + pxToDpStr("folderCellWidthPx", folderCellWidthPx));
        writer.println(prefix + pxToDpStr("folderCellHeightPx", folderCellHeightPx));
        writer.println(prefix + pxToDpStr("folderChildIconSizePx", folderChildIconSizePx));
+34 −6
Original line number Diff line number Diff line
@@ -122,8 +122,8 @@ public class InvariantDeviceProfile {
    /**
     * Number of icons per row and column in the folder.
     */
    public int numFolderRows;
    public int numFolderColumns;
    public int[] numFolderRows;
    public int[] numFolderColumns;
    public float[] iconSize;
    public float[] iconTextSize;
    public int iconBitmapSize;
@@ -810,8 +810,8 @@ public class InvariantDeviceProfile {
        public final int numSearchContainerColumns;
        public final int deviceCategory;

        private final int numFolderRows;
        private final int numFolderColumns;
        private final int[] numFolderRows = new int[COUNT_SIZES];
        private final int[] numFolderColumns = new int[COUNT_SIZES];
        private final @StyleRes int folderStyle;
        private final @StyleRes int cellStyle;

@@ -888,11 +888,39 @@ public class InvariantDeviceProfile {
                    a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing,
                            R.dimen.taskbar_button_margin_default);

            numFolderRows = a.getInt(
            numFolderRows[INDEX_DEFAULT] = a.getInt(
                    R.styleable.GridDisplayOption_numFolderRows, numRows);
            numFolderColumns = a.getInt(
            numFolderColumns[INDEX_DEFAULT] = a.getInt(
                    R.styleable.GridDisplayOption_numFolderColumns, numColumns);

            if (FeatureFlags.enableResponsiveWorkspace()) {
                numFolderRows[INDEX_LANDSCAPE] = a.getInt(
                        R.styleable.GridDisplayOption_numFolderRowsLandscape,
                        numFolderRows[INDEX_DEFAULT]);
                numFolderColumns[INDEX_LANDSCAPE] = a.getInt(
                        R.styleable.GridDisplayOption_numFolderColumnsLandscape,
                        numFolderColumns[INDEX_DEFAULT]);
                numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
                        R.styleable.GridDisplayOption_numFolderRowsTwoPanelPortrait,
                        numFolderRows[INDEX_DEFAULT]);
                numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
                        R.styleable.GridDisplayOption_numFolderColumnsTwoPanelPortrait,
                        numFolderColumns[INDEX_DEFAULT]);
                numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
                        R.styleable.GridDisplayOption_numFolderRowsTwoPanelLandscape,
                        numFolderRows[INDEX_DEFAULT]);
                numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
                        R.styleable.GridDisplayOption_numFolderColumnsTwoPanelLandscape,
                        numFolderColumns[INDEX_DEFAULT]);
            } else {
                numFolderRows[INDEX_LANDSCAPE] = numFolderRows[INDEX_DEFAULT];
                numFolderColumns[INDEX_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT];
                numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = numFolderRows[INDEX_DEFAULT];
                numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = numFolderColumns[INDEX_DEFAULT];
                numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = numFolderRows[INDEX_DEFAULT];
                numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT];
            }

            folderStyle = a.getResourceId(R.styleable.GridDisplayOption_folderStyle,
                    INVALID_RESOURCE_HANDLE);

+1 −1
Original line number Diff line number Diff line
@@ -791,7 +791,7 @@ public class Launcher extends StatefulActivity<LauncherState>
        if (info.container >= 0) {
            View folderIcon = getWorkspace().getHomescreenIconByItemId(info.container);
            if (folderIcon instanceof FolderIcon && folderIcon.getTag() instanceof FolderInfo) {
                if (new FolderGridOrganizer(getDeviceProfile().inv)
                if (new FolderGridOrganizer(getDeviceProfile())
                        .setFolderInfo((FolderInfo) folderIcon.getTag())
                        .isItemInPreview(info.rank)) {
                    folderIcon.invalidate();
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
        // Cache one page worth of icons
        launcher.viewCache.setCacheSize(
            R.layout.folder_application,
            deviceProfile.inv.numFolderColumns * deviceProfile.inv.numFolderRows
            deviceProfile.numFolderColumns * deviceProfile.numFolderRows
        )
        launcher.viewCache.setCacheSize(R.layout.folder_page, 2)
        TraceHelper.INSTANCE.endSection()
Loading