diff options
author | Adam Cohen <adamcohen@google.com> | 2012-05-01 10:39:40 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-01 10:39:40 -0700 |
commit | 60d85e3afc9d0e056f9a9153af5565cf74dca9ae (patch) | |
tree | 657bab54709f1adbcd0c4085e7640cbdad993dfd | |
parent | 5d3ffdba3dc0bb565a9d80fa4633aee1e4929d1e (diff) | |
parent | 2f093b6ad185967c129781526060288e983bc58a (diff) | |
download | packages_apps_trebuchet-60d85e3afc9d0e056f9a9153af5565cf74dca9ae.zip packages_apps_trebuchet-60d85e3afc9d0e056f9a9153af5565cf74dca9ae.tar.gz packages_apps_trebuchet-60d85e3afc9d0e056f9a9153af5565cf74dca9ae.tar.bz2 |
Merge "Fix widget resizes that shouldn't (issue 6380435)" into jb-dev
-rw-r--r-- | src/com/android/launcher2/AppWidgetResizeFrame.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 3 |
4 files changed, 23 insertions, 19 deletions
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java index 7281a6f..8824686 100644 --- a/src/com/android/launcher2/AppWidgetResizeFrame.java +++ b/src/com/android/launcher2/AppWidgetResizeFrame.java @@ -79,7 +79,7 @@ public class AppWidgetResizeFrame extends FrameLayout { mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace); final AppWidgetProviderInfo info = widgetView.getAppWidgetInfo(); - int[] result = mLauncher.getMinSpanForWidget(info); + int[] result = Launcher.getMinSpanForWidget(mLauncher, info); mMinHSpan = result[0]; mMinVSpan = result[1]; diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 3936e59..586177b 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -481,8 +481,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen for (AppWidgetProviderInfo widget : widgets) { if (widget.minWidth > 0 && widget.minHeight > 0) { // Ensure that all widgets we show can be added on a workspace of this size - int[] spanXY = mLauncher.getSpanForWidget(widget); - int[] minSpanXY = mLauncher.getMinSpanForWidget(widget); + int[] spanXY = Launcher.getSpanForWidget(mLauncher, widget); + int[] minSpanXY = Launcher.getMinSpanForWidget(mLauncher, widget); int minSpanX = Math.min(spanXY[0], minSpanXY[0]); int minSpanY = Math.min(spanXY[1], minSpanXY[1]); if (minSpanX <= LauncherModel.getCellCountX() && @@ -1225,10 +1225,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen createItemInfo = new PendingAddWidgetInfo(info, null, null); // Determine the widget spans and min resize spans. - int[] spanXY = mLauncher.getSpanForWidget(info); + int[] spanXY = Launcher.getSpanForWidget(mLauncher, info); createItemInfo.spanX = spanXY[0]; createItemInfo.spanY = spanXY[1]; - int[] minSpanXY = mLauncher.getMinSpanForWidget(info); + int[] minSpanXY = Launcher.getMinSpanForWidget(mLauncher, info); createItemInfo.minSpanX = minSpanXY[0]; createItemInfo.minSpanY = minSpanXY[1]; @@ -1315,7 +1315,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen Object rawInfo = items.get(i); if (rawInfo instanceof AppWidgetProviderInfo) { AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo; - int[] cellSpans = mLauncher.getSpanForWidget(info); + int[] cellSpans = Launcher.getSpanForWidget(mLauncher, info); int maxWidth = Math.min(data.maxImageWidth, mWidgetSpacingLayout.estimateCellWidth(cellSpans[0])); diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index cb737ff..3c20a58 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1000,29 +1000,30 @@ public final class Launcher extends Activity } } - int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight) { - Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(this, component, null); + static int[] getSpanForWidget(Context context, ComponentName component, int minWidth, + int minHeight) { + Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, component, null); // We want to account for the extra amount of padding that we are adding to the widget // to ensure that it gets the full amount of space that it has requested int requiredWidth = minWidth + padding.left + padding.right; int requiredHeight = minHeight + padding.top + padding.bottom; - return CellLayout.rectToCell(getResources(), requiredWidth, requiredHeight, null); + return CellLayout.rectToCell(context.getResources(), requiredWidth, requiredHeight, null); } - int[] getSpanForWidget(AppWidgetProviderInfo info) { - return getSpanForWidget(info.provider, info.minWidth, info.minHeight); + static int[] getSpanForWidget(Context context, AppWidgetProviderInfo info) { + return getSpanForWidget(context, info.provider, info.minWidth, info.minHeight); } - int[] getMinSpanForWidget(AppWidgetProviderInfo info) { - return getSpanForWidget(info.provider, info.minResizeWidth, info.minResizeHeight); + static int[] getMinSpanForWidget(Context context, AppWidgetProviderInfo info) { + return getSpanForWidget(context, info.provider, info.minResizeWidth, info.minResizeHeight); } - int[] getSpanForWidget(PendingAddWidgetInfo info) { - return getSpanForWidget(info.componentName, info.minWidth, info.minHeight); + static int[] getSpanForWidget(Context context, PendingAddWidgetInfo info) { + return getSpanForWidget(context, info.componentName, info.minWidth, info.minHeight); } - int[] getMinSpanForWidget(PendingAddWidgetInfo info) { - return getSpanForWidget(info.componentName, info.minResizeWidth, + static int[] getMinSpanForWidget(Context context, PendingAddWidgetInfo info) { + return getSpanForWidget(context, info.componentName, info.minResizeWidth, info.minResizeHeight); } @@ -1041,8 +1042,8 @@ public final class Launcher extends Activity // Calculate the grid spans needed to fit this widget CellLayout layout = getCellLayout(container, screen); - int[] minSpanXY = getMinSpanForWidget(appWidgetInfo); - int[] spanXY = getSpanForWidget(appWidgetInfo); + int[] minSpanXY = getMinSpanForWidget(this, appWidgetInfo); + int[] spanXY = getSpanForWidget(this, appWidgetInfo); // Try finding open space on Launcher screen // We have saved the position to which the widget was dragged-- this really only matters diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 6d1cc75..b76df39 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -1175,6 +1175,9 @@ public class LauncherModel extends BroadcastReceiver { appWidgetInfo.cellY = c.getInt(cellYIndex); appWidgetInfo.spanX = c.getInt(spanXIndex); appWidgetInfo.spanY = c.getInt(spanYIndex); + int[] minSpan = Launcher.getMinSpanForWidget(context, provider); + appWidgetInfo.minSpanX = minSpan[0]; + appWidgetInfo.minSpanY = minSpan[1]; container = c.getInt(containerIndex); if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP && |