Fixed 3066306 Widget measurement wrong in customize tray
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 164d7c5..13603f0 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -1110,9 +1110,12 @@
* @param result An array of length 2 in which to store the result (may be null).
*/
public int[] rectToCell(int width, int height, int[] result) {
+ return rectToCell(getResources(), width, height, result);
+ }
+
+ public static int[] rectToCell(Resources resources, int width, int height, int[] result) {
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
- final Resources resources = getResources();
int actualWidth = resources.getDimensionPixelSize(R.dimen.workspace_cell_width);
int actualHeight = resources.getDimensionPixelSize(R.dimen.workspace_cell_height);
int smallerSize = Math.min(actualWidth, actualHeight);
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index b7e5dcd..f3de74b 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -624,8 +624,10 @@
l.setOnLongClickListener(this);
final Drawable icon = getWidgetIcon(info);
- final int hSpan = mWorkspaceWidgetLayout.estimateCellHSpan(info.minWidth);
- final int vSpan = mWorkspaceWidgetLayout.estimateCellHSpan(info.minHeight);
+
+ int[] spans = CellLayout.rectToCell(getResources(), info.minWidth, info.minHeight, null);
+ final int hSpan = spans[0];
+ final int vSpan = spans[1];
ImageView image = (ImageView) l.findViewById(R.id.widget_preview);
image.setMaxWidth(mMaxWidgetWidth);