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

Commit 591e3608 authored by Jon Miranda's avatar Jon Miranda
Browse files

Match folder icon size to normalized circle icon size.

Simplifies the logic for calculating the folder icon size,
and ensures consistent sizing in different launcher viewing modes.

Bug: 74078689
Change-Id: I5cf4474fd81e55aa50b056418c95533801f07d48
parent 71d45a0a
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -31,9 +31,6 @@
    <dimen name="dynamic_grid_cell_layout_padding">0dp</dimen>
    <dimen name="dynamic_grid_cell_layout_bottom_padding">5.5dp</dimen>

    <!-- Folders -->
    <dimen name="folder_preview_padding">2dp</dimen>

    <!-- Hotseat -->
    <!-- Will be set to equal the hotseat icon size. -->
    <dimen name="dynamic_grid_hotseat_size">0dp</dimen>
+0 −2
Original line number Diff line number Diff line
@@ -137,8 +137,6 @@
    <dimen name="spring_loaded_panel_border">1dp</dimen>

<!-- Folders -->
    <!-- The size of the padding on the preview background drawable -->
    <dimen name="folder_preview_padding">10dp</dimen>
    <dimen name="page_indicator_dot_size">8dp</dimen>

    <dimen name="folder_cell_x_padding">9dp</dimen>
+4 −5
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.util.DisplayMetrics;

import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.badge.BadgeRenderer;
import com.android.launcher3.graphics.IconNormalizer;

public class DeviceProfile {

@@ -81,9 +82,8 @@ public class DeviceProfile {
    public int workspaceCellPaddingXPx;

    // Folder
    public int folderBackgroundOffset;
    public int folderIconSizePx;
    public int folderIconPreviewPadding;
    public int folderIconOffsetYPx;

    // Folder cell
    public int folderCellWidthPx;
@@ -340,9 +340,8 @@ public class DeviceProfile {
        }

        // Folder icon
        folderBackgroundOffset = -iconDrawablePaddingPx;
        folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
        folderIconPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding);
        folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx);
        folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
    }

    private void updateAvailableFolderCellDimensions(DisplayMetrics dm, Resources res) {
+4 −7
Original line number Diff line number Diff line
@@ -129,18 +129,15 @@ public class PreviewBackground {
            };

    public void setup(Launcher launcher, View invalidateDelegate,
                      int availableSpace, int topPadding) {
                      int availableSpaceX, int topPadding) {
        mInvalidateDelegate = invalidateDelegate;
        mBgColor = Themes.getAttrColor(launcher, android.R.attr.colorPrimary);

        DeviceProfile grid = launcher.getDeviceProfile();
        final int previewSize = grid.folderIconSizePx;
        final int previewPadding = grid.folderIconPreviewPadding;
        previewSize = grid.folderIconSizePx;

        this.previewSize = (previewSize - 2 * previewPadding);

        basePreviewOffsetX = (availableSpace - this.previewSize) / 2;
        basePreviewOffsetY = previewPadding + grid.folderBackgroundOffset + topPadding;
        basePreviewOffsetX = (availableSpaceX - previewSize) / 2;
        basePreviewOffsetY = topPadding + grid.folderIconOffsetYPx;

        // Stroke width is 1dp
        mStrokeWidth = launcher.getResources().getDisplayMetrics().density;
+8 −0
Original line number Diff line number Diff line
@@ -376,4 +376,12 @@ public class IconNormalizer {
            last = i;
        }
    }

    /**
     * @return The diameter of the normalized circle that fits inside of the square (size x size).
     */
    public static int getNormalizedCircleSize(int size) {
        float area = size * size * MAX_CIRCLE_AREA_FACTOR;
        return (int) Math.round(Math.sqrt((4 * area) / Math.PI));
    }
}