diff options
author | Adam Cohen <adamcohen@google.com> | 2012-04-04 14:58:12 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-04-04 15:02:26 -0700 |
commit | 1f36270212e46b6ec0f27a0109ceaa9eb4a4995d (patch) | |
tree | ebcdfd54a4e6cee7f06a4806a33fcfe0b4f85da3 | |
parent | f75547babbf91e0a488fa0d9dcc4789880cb6631 (diff) | |
download | android_packages_apps_Trebuchet-1f36270212e46b6ec0f27a0109ceaa9eb4a4995d.tar.gz android_packages_apps_Trebuchet-1f36270212e46b6ec0f27a0109ceaa9eb4a4995d.tar.bz2 android_packages_apps_Trebuchet-1f36270212e46b6ec0f27a0109ceaa9eb4a4995d.zip |
Some changes which are effectively no-op right now, but will be useful
for testing widget size reporting APIs
Change-Id: I7a47afcd25e45b7f3914ece6796b006153900054
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 38 | ||||
-rw-r--r-- | src/com/android/launcher2/PendingAddItemInfo.java | 4 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 840ec459d..f1ae2c568 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -577,6 +577,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen info.boundWidget = hostView; mWidgetCleanupState = WIDGET_INFLATED; hostView.setVisibility(INVISIBLE); + int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(info.spanX, + info.spanY, info, false); + + // We want the first widget layout to be the correct size. This will be important + // for width size reporting to the AppWidgetManager. + DragLayer.LayoutParams lp = new DragLayer.LayoutParams(unScaledSize[0], + unScaledSize[1]); + lp.x = lp.y = 0; + lp.customPosition = true; + hostView.setLayoutParams(lp); mLauncher.getDragLayer().addView(hostView); } }; @@ -629,14 +639,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (createItemInfo instanceof PendingAddWidgetInfo) { PendingAddWidgetInfo createWidgetInfo = mCreateWidgetInfo; createItemInfo = createWidgetInfo; - int[] spanXY = mLauncher.getSpanForWidget(createWidgetInfo, null); - int[] size = mLauncher.getWorkspace().estimateItemSize(spanXY[0], - spanXY[1], createWidgetInfo, true); - createItemInfo.spanX = spanXY[0]; - createItemInfo.spanY = spanXY[1]; - int[] minSpanXY = mLauncher.getMinSpanForWidget(createWidgetInfo, null); - createWidgetInfo.minSpanX = minSpanXY[0]; - createWidgetInfo.minSpanY = minSpanXY[1]; + int spanX = createItemInfo.spanX; + int spanY = createItemInfo.spanY; + int[] size = mLauncher.getWorkspace().estimateItemSize(spanX, spanY, + createWidgetInfo, true); FastBitmapDrawable previewDrawable = (FastBitmapDrawable) image.getDrawable(); float minScale = 1.25f; @@ -644,7 +650,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen minWidth = Math.max((int) (previewDrawable.getIntrinsicWidth() * minScale), size[0]); minHeight = Math.max((int) (previewDrawable.getIntrinsicHeight() * minScale), size[1]); preview = getWidgetPreview(createWidgetInfo.componentName, createWidgetInfo.previewImage, - createWidgetInfo.icon, spanXY[0], spanXY[1], minWidth, minHeight); + createWidgetInfo.icon, spanX, spanY, minWidth, minHeight); // Determine the image view drawable scale relative to the preview float[] mv = new float[9]; @@ -1198,8 +1204,18 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Fill in the widget information AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo; createItemInfo = new PendingAddWidgetInfo(info, null, null); - int[] cellSpans = mLauncher.getSpanForWidget(info, null); - widget.applyFromAppWidgetProviderInfo(info, -1, cellSpans); + + // Determine the widget spans and min resize spans. + int[] spanXY = mLauncher.getSpanForWidget(info, null); + int[] size = mLauncher.getWorkspace().estimateItemSize(spanXY[0], + spanXY[1], createItemInfo, true); + createItemInfo.spanX = spanXY[0]; + createItemInfo.spanY = spanXY[1]; + int[] minSpanXY = mLauncher.getMinSpanForWidget(info, null); + createItemInfo.minSpanX = minSpanXY[0]; + createItemInfo.minSpanY = minSpanXY[1]; + + widget.applyFromAppWidgetProviderInfo(info, -1, spanXY); widget.setTag(createItemInfo); widget.setShortPressListener(this); } else if (rawInfo instanceof ResolveInfo) { diff --git a/src/com/android/launcher2/PendingAddItemInfo.java b/src/com/android/launcher2/PendingAddItemInfo.java index d36e21763..26e946efa 100644 --- a/src/com/android/launcher2/PendingAddItemInfo.java +++ b/src/com/android/launcher2/PendingAddItemInfo.java @@ -76,5 +76,9 @@ class PendingAddWidgetInfo extends PendingAddItemInfo { configurationData = copy.configurationData; componentName = copy.componentName; itemType = copy.itemType; + spanX = copy.spanX; + spanY = copy.spanY; + minSpanX = copy.minSpanX; + minSpanY = copy.minSpanY; } } |