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

Commit d3cc05a3 authored by Adam Cohen's avatar Adam Cohen
Browse files

Account for disparity btw folder preview size and drawable size

-> When there is disparity between the cached icon size and the available space
   in the preview, the folder preview could appear not as intended (either
   overly crammed, or overly spacious)

issue 27701193

Change-Id: I9f97012ba569d1419b1e3f661cd26761b2a36285
parent aa2542a4
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
    private float mRadius;
    private float mIconSize;
    private boolean mIsRtl;
    private float mBaselineIconScale;

    @Override
    public void init(int availableSpace, int intrinsicIconSize, boolean rtl) {
@@ -30,6 +31,7 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
        mRadius = ITEM_RADIUS_SCALE_FACTOR * availableSpace / 2f;
        mIconSize = intrinsicIconSize;
        mIsRtl = rtl;
        mBaselineIconScale = availableSpace / (intrinsicIconSize * 1f);
    }

    @Override
@@ -103,13 +105,16 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
    }

    private float scaleForNumItems(int numItems) {
        float scale = 1f;
        if (numItems <= 2) {
            return MAX_SCALE;
            scale = MAX_SCALE;
        } else if (numItems == 3) {
            return (MAX_SCALE + MIN_SCALE) / 2;
            scale = (MAX_SCALE + MIN_SCALE) / 2;
        } else {
            return MIN_SCALE;
            scale = MIN_SCALE;
        }

        return scale * mBaselineIconScale;
    }

    @Override