diff options
author | Owen Lin <owenlin@google.com> | 2011-09-13 20:48:13 +0800 |
---|---|---|
committer | Wei Huang <weih@google.com> | 2011-09-19 16:22:44 -0700 |
commit | 9ed28cc0b7108a95aebbc3fe59671e36149d2aa7 (patch) | |
tree | 7aa567aac48de03b9fd03d1d1de05cef8ac9f567 /src/com/android/gallery3d/gadget | |
parent | 56e813b555f7723a033bbb84ffc2ac517d4c1a2d (diff) | |
download | android_packages_apps_Snap-9ed28cc0b7108a95aebbc3fe59671e36149d2aa7.tar.gz android_packages_apps_Snap-9ed28cc0b7108a95aebbc3fe59671e36149d2aa7.tar.bz2 android_packages_apps_Snap-9ed28cc0b7108a95aebbc3fe59671e36149d2aa7.zip |
Add a hard limit on the size of the widget images.
There is a limit on the size of the data transfered by binder.
For now, we just add a hard limit (360 pixel) to ensure the widget's image
can be passed by binder.
Also adjust the size of widget to make it looks better.
Fix a bug in DecodeUtils which cause OOM for a image in size 12200x1920.
In that case, we should generate a screen nail of size 640x101 instead of
4066x640.
Change-Id: Ia8227d8e5368471fe7af94bf164d67017aa321fa
fix: 5273271
Diffstat (limited to 'src/com/android/gallery3d/gadget')
-rw-r--r-- | src/com/android/gallery3d/gadget/WidgetConfigure.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/gadget/WidgetConfigure.java b/src/com/android/gallery3d/gadget/WidgetConfigure.java index 747cc3a6d..a871e24fe 100644 --- a/src/com/android/gallery3d/gadget/WidgetConfigure.java +++ b/src/com/android/gallery3d/gadget/WidgetConfigure.java @@ -48,6 +48,7 @@ public class WidgetConfigure extends Activity { // Note: There is also a limit on the size of data that can be // passed in Binder's transaction. private static float WIDGET_SCALE_FACTOR = 1.5f; + private static int MAX_WIDGET_SIDE = 360; private int mAppWidgetId = -1; private int mWidgetType = 0; @@ -115,10 +116,18 @@ public class WidgetConfigure extends Activity { private void setChoosenPhoto(Intent data) { Resources res = getResources(); - int widgetWidth = Math.round(WIDGET_SCALE_FACTOR - * res.getDimension(R.dimen.appwidget_width)); - int widgetHeight = Math.round(WIDGET_SCALE_FACTOR - * res.getDimension(R.dimen.appwidget_height)); + + float width = res.getDimension(R.dimen.appwidget_width); + float height = res.getDimension(R.dimen.appwidget_height); + + // We try to crop a larger image (by scale factor), but there is still + // a bound on the binder limit. + float scale = Math.min(WIDGET_SCALE_FACTOR, + MAX_WIDGET_SIDE / Math.max(width, height)); + + int widgetWidth = Math.round(width * scale); + int widgetHeight = Math.round(height * scale); + mPickedItem = data.getData(); Intent request = new Intent(CropImage.ACTION_CROP, mPickedItem) .putExtra(CropImage.KEY_OUTPUT_X, widgetWidth) |