summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-10-31 22:13:22 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2011-10-31 22:13:22 +0000
commitc36c68e8380cfcf1e23973e11e55c4fa71144c83 (patch)
tree023e380de19552afae578ff089fbd1ff630196fc /src
parent9af3ee5400439134edd0eed491d174156b792dae (diff)
parent0ee2a438193205466aff63dd690ba6ca9796ddae (diff)
downloadpackages_apps_trebuchet-c36c68e8380cfcf1e23973e11e55c4fa71144c83.zip
packages_apps_trebuchet-c36c68e8380cfcf1e23973e11e55c4fa71144c83.tar.gz
packages_apps_trebuchet-c36c68e8380cfcf1e23973e11e55c4fa71144c83.tar.bz2
am 0ee2a438: Merge "Fixing issue where widget previews were being scaled up." into ics-mr1
* commit '0ee2a438193205466aff63dd690ba6ca9796ddae': Fixing issue where widget previews were being scaled up.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 5a54c78..4d8a9cf 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -949,18 +949,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Log.w(LOG_TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon)
+ " for provider: " + info.provider);
} else {
- // Scale down the preview to something that is closer to the cellWidth/Height
- int imageWidth = drawable.getIntrinsicWidth();
- int imageHeight = drawable.getIntrinsicHeight();
- int bitmapWidth = imageWidth;
- int bitmapHeight = imageHeight;
- if (imageWidth > imageHeight) {
- bitmapWidth = cellWidth;
- bitmapHeight = (int) (imageHeight * ((float) bitmapWidth / imageWidth));
+ // Map the target width/height to the cell dimensions
+ int targetWidth = mWidgetSpacingLayout.estimateCellWidth(cellHSpan);
+ int targetHeight = mWidgetSpacingLayout.estimateCellHeight(cellVSpan);
+ int targetCellWidth;
+ int targetCellHeight;
+ if (targetWidth >= targetHeight) {
+ targetCellWidth = Math.min(targetWidth, cellWidth);
+ targetCellHeight = (int) (cellHeight * ((float) targetCellWidth / cellWidth));
} else {
- bitmapHeight = cellHeight;
- bitmapWidth = (int) (imageWidth * ((float) bitmapHeight / imageHeight));
+ targetCellHeight = Math.min(targetHeight, cellHeight);
+ targetCellWidth = (int) (cellWidth * ((float) targetCellHeight / cellHeight));
}
+ // Map the preview to the target cell dimensions
+ int bitmapWidth = Math.min(targetCellWidth, drawable.getIntrinsicWidth());
+ int bitmapHeight = (int) (drawable.getIntrinsicHeight() *
+ ((float) bitmapWidth / drawable.getIntrinsicWidth()));
preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
renderDrawableToBitmap(drawable, preview, 0, 0, bitmapWidth, bitmapHeight);
@@ -989,7 +993,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
} else {
// Otherwise, ensure that we are properly sized within the cellWidth/Height
- if (targetWidth > targetHeight) {
+ if (targetWidth >= targetHeight) {
bitmapWidth = Math.min(targetWidth, cellWidth);
bitmapHeight = (int) (targetHeight * ((float) bitmapWidth / targetWidth));
iconScale = Math.min((float) bitmapHeight / (mAppIconSize + 2 * minOffset), 1f);