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
This commit is contained in:
Adam Cohen
2016-03-21 14:33:02 -07:00
parent aa2542a461
commit d3cc05a3a8

View File

@@ -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