From d3cc05a3a8c573986d08ee293a4bb8b4534d06b2 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Mon, 21 Mar 2016 14:33:02 -0700 Subject: [PATCH] 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 --- .../launcher3/folder/ClippedFolderIconLayoutRule.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java b/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java index 68b756b244..6ee02f9d73 100644 --- a/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java +++ b/src/com/android/launcher3/folder/ClippedFolderIconLayoutRule.java @@ -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