From 75ddf9f09cf5c41827b1437c335e6f6bf0134111 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 29 Mar 2012 17:25:17 -0700 Subject: [PATCH 1/4] Fix issue where hotseat wasn't being correctly persisted (issue 6259158) Change-Id: Ie19c0f8e79a91a1021a3576f48e1db7d0c3478e1 --- src/com/android/launcher2/Workspace.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 0ef6fd96f6..51f092ca84 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -3349,14 +3349,22 @@ public class Workspace extends SmoothPagedView void updateItemLocationsInDatabase(CellLayout cl) { int count = cl.getShortcutsAndWidgets().getChildCount(); + int screen = indexOfChild(cl); + int container = Favorites.CONTAINER_DESKTOP; + + if (mLauncher.isHotseatLayout(cl)) { + screen = -1; + container = Favorites.CONTAINER_HOTSEAT; + } + for (int i = 0; i < count; i++) { View v = cl.getShortcutsAndWidgets().getChildAt(i); ItemInfo info = (ItemInfo) v.getTag(); // Null check required as the AllApps button doesn't have an item info if (info != null) { - LauncherModel.moveItemInDatabase(mLauncher, info, Favorites.CONTAINER_DESKTOP, - screen, info.cellX, info.cellY); + LauncherModel.moveItemInDatabase(mLauncher, info, container, screen, info.cellX, + info.cellY); } } } From 8e6c43da73e87f86bfccdb604df953746da5d61b Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 29 Mar 2012 14:30:35 -0700 Subject: [PATCH 2/4] Fixing launcher ANR (issue 6238175) Change-Id: I6518ea9e6ce8b50a5f2a3b24e909e18c5b1bde51 --- src/com/android/launcher2/CellLayout.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 5aa39c425f..199c41a59e 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -191,6 +191,8 @@ public class CellLayout extends ViewGroup { mCountY = LauncherModel.getCellCountY(); mOccupied = new boolean[mCountX][mCountY]; mTmpOccupied = new boolean[mCountX][mCountY]; + mPreviousReorderDirection[0] = INVALID_DIRECTION; + mPreviousReorderDirection[1] = INVALID_DIRECTION; a.recycle(); @@ -1566,7 +1568,8 @@ public class CellLayout extends ViewGroup { float bestDistance = Float.MAX_VALUE; // We use this to march in a single direction - if (direction[0] != 0 && direction[1] != 0) { + if ((direction[0] != 0 && direction[1] != 0) || + (direction[0] == 0 && direction[1] == 0)) { return bestXY; } From ff74520bf585db00c1c4e448af57302bf6c9f83f Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 12 Apr 2012 14:04:41 -0700 Subject: [PATCH 3/4] Preventing widgets that don't fit from showing in tray. (Bug 6331357) Change-Id: I9cbe85bed5c633f2be9b420eecbbee9a1b171e51 --- .../launcher2/AppWidgetResizeFrame.java | 2 +- .../launcher2/AppsCustomizePagedView.java | 16 +++++++++--- src/com/android/launcher2/Launcher.java | 26 ++++++++----------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java index c01a882cb7..4518f90257 100644 --- a/src/com/android/launcher2/AppWidgetResizeFrame.java +++ b/src/com/android/launcher2/AppWidgetResizeFrame.java @@ -80,7 +80,7 @@ public class AppWidgetResizeFrame extends FrameLayout { mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace); final AppWidgetProviderInfo info = widgetView.getAppWidgetInfo(); - int[] result = mLauncher.getMinSpanForWidget(info, null); + int[] result = mLauncher.getMinSpanForWidget(info); mMinHSpan = result[0]; mMinVSpan = result[1]; diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 67ae1f1123..3d5d06a118 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -480,7 +480,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen List shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0); for (AppWidgetProviderInfo widget : widgets) { if (widget.minWidth > 0 && widget.minHeight > 0) { - mWidgets.add(widget); + // 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 minSpanX = Math.min(spanXY[0], minSpanXY[0]); + int minSpanY = Math.min(spanXY[1], minSpanXY[1]); + if (minSpanX < LauncherModel.getCellCountX() && + minSpanY < LauncherModel.getCellCountY()) { + mWidgets.add(widget); + } } else { Log.e(LOG_TAG, "Widget " + widget.provider + " has invalid dimensions (" + widget.minWidth + ", " + widget.minHeight + ")"); @@ -1205,12 +1213,12 @@ 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, null); + int[] spanXY = mLauncher.getSpanForWidget(info); 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); + int[] minSpanXY = mLauncher.getMinSpanForWidget(info); createItemInfo.minSpanX = minSpanXY[0]; createItemInfo.minSpanY = minSpanXY[1]; @@ -1297,7 +1305,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, null); + int[] cellSpans = mLauncher.getSpanForWidget(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 3e626e8749..97c8373e6e 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -960,11 +960,7 @@ public final class Launcher extends Activity } } - int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight, int[] spanXY) { - if (spanXY == null) { - spanXY = new int[2]; - } - + int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight) { Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(this, 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 @@ -973,21 +969,21 @@ public final class Launcher extends Activity return CellLayout.rectToCell(getResources(), requiredWidth, requiredHeight, null); } - int[] getSpanForWidget(AppWidgetProviderInfo info, int[] spanXY) { - return getSpanForWidget(info.provider, info.minWidth, info.minHeight, spanXY); + int[] getSpanForWidget(AppWidgetProviderInfo info) { + return getSpanForWidget(info.provider, info.minWidth, info.minHeight); } - int[] getMinSpanForWidget(AppWidgetProviderInfo info, int[] spanXY) { - return getSpanForWidget(info.provider, info.minResizeWidth, info.minResizeHeight, spanXY); + int[] getMinSpanForWidget(AppWidgetProviderInfo info) { + return getSpanForWidget(info.provider, info.minResizeWidth, info.minResizeHeight); } - int[] getSpanForWidget(PendingAddWidgetInfo info, int[] spanXY) { - return getSpanForWidget(info.componentName, info.minWidth, info.minHeight, spanXY); + int[] getSpanForWidget(PendingAddWidgetInfo info) { + return getSpanForWidget(info.componentName, info.minWidth, info.minHeight); } - int[] getMinSpanForWidget(PendingAddWidgetInfo info, int[] spanXY) { + int[] getMinSpanForWidget(PendingAddWidgetInfo info) { return getSpanForWidget(info.componentName, info.minResizeWidth, - info.minResizeHeight, spanXY); + info.minResizeHeight); } /** @@ -1005,8 +1001,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, null); - int[] spanXY = getSpanForWidget(appWidgetInfo, null); + int[] minSpanXY = getMinSpanForWidget(appWidgetInfo); + int[] spanXY = getSpanForWidget(appWidgetInfo); // Try finding open space on Launcher screen // We have saved the position to which the widget was dragged-- this really only matters From 1a9b3e03f3e08335f0c77ef13ee045a426d43256 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 13 Apr 2012 17:57:11 -0700 Subject: [PATCH 4/4] Fix issue where certain widgets don't appear in tray (issue 6339060) Change-Id: I3e16021da11d67b6e59ec2f4e251927362bf4fe6 --- src/com/android/launcher2/AppsCustomizePagedView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 3d5d06a118..636117b8a5 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -485,8 +485,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen int[] minSpanXY = mLauncher.getMinSpanForWidget(widget); int minSpanX = Math.min(spanXY[0], minSpanXY[0]); int minSpanY = Math.min(spanXY[1], minSpanXY[1]); - if (minSpanX < LauncherModel.getCellCountX() && - minSpanY < LauncherModel.getCellCountY()) { + if (minSpanX <= LauncherModel.getCellCountX() && + minSpanY <= LauncherModel.getCellCountY()) { mWidgets.add(widget); } } else {