From 75ddf9f09cf5c41827b1437c335e6f6bf0134111 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 29 Mar 2012 17:25:17 -0700 Subject: 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 0ef6fd96f..51f092ca8 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); } } } -- cgit v1.2.3 From 8e6c43da73e87f86bfccdb604df953746da5d61b Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 29 Mar 2012 14:30:35 -0700 Subject: 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 5aa39c425..199c41a59 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; } -- cgit v1.2.3 From ff74520bf585db00c1c4e448af57302bf6c9f83f Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 12 Apr 2012 14:04:41 -0700 Subject: Preventing widgets that don't fit from showing in tray. (Bug 6331357) Change-Id: I9cbe85bed5c633f2be9b420eecbbee9a1b171e51 --- .../android/launcher2/AppWidgetResizeFrame.java | 2 +- .../android/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 c01a882cb..4518f9025 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 67ae1f112..3d5d06a11 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 3e626e874..97c8373e6 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 -- cgit v1.2.3 From 1a9b3e03f3e08335f0c77ef13ee045a426d43256 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 13 Apr 2012 17:57:11 -0700 Subject: 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 3d5d06a11..636117b8a 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 { -- cgit v1.2.3 From eae91ba47f952fcebe90d514dd962f3d5728d9e4 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 3 May 2012 15:21:11 -0700 Subject: Workaround for default workspace widgets not getting notified for new widget sizes. (Bug 6439962) Change-Id: Ib775a606e8fa185a5595fbe8f3824fc24fbe9bb2 --- src/com/android/launcher2/Launcher.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index e5baf62fa..0d4b0d041 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -3097,6 +3097,9 @@ public final class Launcher extends Activity workspace.requestLayout(); + AppWidgetResizeFrame.updateWidgetSizeRanges(item.hostView, + this, item.spanX, item.spanY); + if (DEBUG_WIDGETS) { Log.d(TAG, "bound widget id="+item.appWidgetId+" in " + (SystemClock.uptimeMillis()-start) + "ms"); -- cgit v1.2.3 From f4a77b6e53c5cfe1457d21bab9b040411c5d9357 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 7 May 2012 10:34:12 -0700 Subject: Try and resolve the package name from the intent directly falling back to the resolved component name if it fails. (Bug 6452306) Change-Id: Ifb2187fb845f807f30df966bf298ffde1b779b46 --- src/com/android/launcher2/ApplicationInfo.java | 6 ++++++ src/com/android/launcher2/DragController.java | 4 ++-- src/com/android/launcher2/ItemInfo.java | 22 +++++++++++++++++++--- src/com/android/launcher2/LauncherModel.java | 2 +- src/com/android/launcher2/ShortcutInfo.java | 6 ++++++ src/com/android/launcher2/Workspace.java | 3 ++- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/com/android/launcher2/ApplicationInfo.java b/src/com/android/launcher2/ApplicationInfo.java index 1fc1d1f55..281d59c68 100644 --- a/src/com/android/launcher2/ApplicationInfo.java +++ b/src/com/android/launcher2/ApplicationInfo.java @@ -102,6 +102,12 @@ class ApplicationInfo extends ItemInfo { firstInstallTime = info.firstInstallTime; } + /** Returns the package name that the shortcut's intent will resolve to, or an empty string if + * none exists. */ + String getPackageName() { + return super.getPackageName(intent); + } + /** * Creates the application intent based on a component name and various launch flags. * Sets {@link #itemType} to {@link LauncherSettings.BaseLauncherColumns#ITEM_TYPE_APPLICATION}. diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java index 9b617552e..b4b20c69f 100644 --- a/src/com/android/launcher2/DragController.java +++ b/src/com/android/launcher2/DragController.java @@ -381,8 +381,8 @@ public class DragController { if (dragInfo != null && dragInfo.intent != null && info.intent != null) { - boolean isSamePackage = info.intent.getComponent().getPackageName().equals( - dragInfo.intent.getComponent().getPackageName()); + boolean isSamePackage = dragInfo.getPackageName().equals( + info.getPackageName()); if (isSamePackage) { cancelDrag(); return; diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java index 11a6c0d00..d34b87e39 100644 --- a/src/com/android/launcher2/ItemInfo.java +++ b/src/com/android/launcher2/ItemInfo.java @@ -16,13 +16,14 @@ package com.android.launcher2; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - import android.content.ContentValues; +import android.content.Intent; import android.graphics.Bitmap; import android.util.Log; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + /** * Represents an item in the launcher. */ @@ -109,6 +110,21 @@ class ItemInfo { container = info.container; } + /** Returns the package name that the intent will resolve to, or an empty string if + * none exists. */ + static String getPackageName(Intent intent) { + if (intent != null) { + String packageName = intent.getPackage(); + if (packageName == null) { + packageName = intent.getComponent().getPackageName(); + } + if (packageName != null) { + return packageName; + } + } + return ""; + } + /** * Write the fields of this item to the DB * diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index bae4c56fc..97e52fe31 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -1684,7 +1684,7 @@ public class LauncherModel extends BroadcastReceiver { for (ItemInfo i : sWorkspaceItems) { if (i instanceof ShortcutInfo) { ShortcutInfo info = (ShortcutInfo) i; - if (info.intent.getComponent().getPackageName().equals(packageName)) { + if (packageName.equals(info.getPackageName())) { infos.add(info); } } diff --git a/src/com/android/launcher2/ShortcutInfo.java b/src/com/android/launcher2/ShortcutInfo.java index 76892dbde..533059f57 100644 --- a/src/com/android/launcher2/ShortcutInfo.java +++ b/src/com/android/launcher2/ShortcutInfo.java @@ -98,6 +98,12 @@ class ShortcutInfo extends ItemInfo { return mIcon; } + /** Returns the package name that the shortcut's intent will resolve to, or an empty string if + * none exists. */ + String getPackageName() { + return super.getPackageName(intent); + } + public void updateIcon(IconCache iconCache) { mIcon = iconCache.getIcon(intent); usingFallbackIcon = iconCache.isDefaultIcon(mIcon); diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 3c84805dd..5e45c99d8 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -3622,7 +3622,8 @@ public class Workspace extends SmoothPagedView for (String intentStr : newApps) { try { Intent intent = Intent.parseUri(intentStr, 0); - if (packageNames.contains(intent.getComponent().getPackageName())) { + String pn = ItemInfo.getPackageName(intent); + if (packageNames.contains(pn)) { newApps.remove(intentStr); } } catch (URISyntaxException e) {} -- cgit v1.2.3 From add3f2c8a1ef68dd08f9775d244140ea57919c4b Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 8 May 2012 10:00:31 -0700 Subject: Fixing NPE. (Bug 6460298) Change-Id: I535cdcabb9121594b4a877839e8a0ef1c6b25af1 --- src/com/android/launcher2/ItemInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java index d34b87e39..dedc0f4f3 100644 --- a/src/com/android/launcher2/ItemInfo.java +++ b/src/com/android/launcher2/ItemInfo.java @@ -115,7 +115,7 @@ class ItemInfo { static String getPackageName(Intent intent) { if (intent != null) { String packageName = intent.getPackage(); - if (packageName == null) { + if (packageName == null && intent.getComponent() != null) { packageName = intent.getComponent().getPackageName(); } if (packageName != null) { -- cgit v1.2.3 From 5da59830e3f2f4d34a7eaf40f353781746b83ab8 Mon Sep 17 00:00:00 2001 From: Andrew Flynn Date: Wed, 9 May 2012 11:12:48 -0700 Subject: Set app_icon_size back to 72dp for sw720dp Change-Id: I3b6ffc1b77eaebadb914d32a3e3bea6410fc7dc4 --- res/values-sw720dp/dimens.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml index 848c40958..02b7ec73b 100644 --- a/res/values-sw720dp/dimens.xml +++ b/res/values-sw720dp/dimens.xml @@ -15,6 +15,7 @@ --> + 72dp 12dip 12dip -- cgit v1.2.3 From cab4822e6dc43ee5325d485d9cd90b400f8e7e78 Mon Sep 17 00:00:00 2001 From: Andrew Flynn Date: Wed, 9 May 2012 11:56:01 -0700 Subject: sw600dp pixel perfect tweaks Change-Id: I9db1418c35a79f869c75bd3eb9741a8bb3b13ec9 --- res/values-sw600dp/dimens.xml | 30 +++++++++++++++++++----------- res/values-sw720dp/dimens.xml | 4 ++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 2d02040e3..24c6a066b 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -15,10 +15,18 @@ --> - 54dp + 56dp 3dp 4dp + + 34dp + 48dp + 12dp + 12dp + 48dp + 70dp 70dp @@ -40,21 +48,21 @@ 96dp 98dp - 10dp - 10dp + 12dp + 12dp 60dp 8dp - 36dp - 36dp + 0dp + 24dp - 82dp - 82dp - 82dp - 82dp + 84dp + 84dp + 84dp + 84dp 32dp - 0dp + 6dp 0dp - 28dp + 24dp diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml index 02b7ec73b..48c729d69 100644 --- a/res/values-sw720dp/dimens.xml +++ b/res/values-sw720dp/dimens.xml @@ -22,6 +22,10 @@ 56dp + 37dp + 0dp + 0dp + 40dp 36dp -- cgit v1.2.3 From d7b03ae38b863170a62488afbc416cd33983bc52 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Wed, 9 May 2012 18:00:44 -0700 Subject: Fix launcher crash when adding widget (issue 6433360) Change-Id: I0deaef6f4ba9252b76aeb5f2afa8564479557f8c --- src/com/android/launcher2/Launcher.java | 68 +++++++++++++++++++------------- src/com/android/launcher2/Workspace.java | 4 +- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 74ec6f3b5..2e7caff3d 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -162,6 +162,12 @@ public final class Launcher extends Activity private static final String RUNTIME_STATE_PENDING_FOLDER_RENAME = "launcher.rename_folder"; // Type: long private static final String RUNTIME_STATE_PENDING_FOLDER_RENAME_ID = "launcher.rename_folder_id"; + // Type: int + private static final String RUNTIME_STATE_PENDING_ADD_SPAN_X = "launcher.add_span_x"; + // Type: int + private static final String RUNTIME_STATE_PENDING_ADD_SPAN_Y = "launcher.add_span_y"; + // Type: parcelable + private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info"; private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon"; private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME = @@ -203,6 +209,8 @@ public final class Launcher extends Activity private LauncherAppWidgetHost mAppWidgetHost; private ItemInfo mPendingAddInfo = new ItemInfo(); + private AppWidgetProviderInfo mPendingAddWidgetInfo; + private int[] mTmpAddItemCellCoordinates = new int[2]; private FolderInfo mFolderInfo; @@ -259,7 +267,6 @@ public final class Launcher extends Activity private static Drawable.ConstantState[] sAppMarketIcon = new Drawable.ConstantState[2]; static final ArrayList sDumpLogs = new ArrayList(); - PendingAddWidgetInfo mWidgetBeingBoundOrConfigured = null; // We only want to get the SharedPreferences once since it does an FS stat each time we get // it from the context. @@ -533,9 +540,6 @@ public final class Launcher extends Activity args.cellY); result = true; break; - case REQUEST_PICK_APPWIDGET: - addAppWidgetFromPick(args.intent); - break; case REQUEST_CREATE_APPWIDGET: int appWidgetId = args.intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); completeAddAppWidget(appWidgetId, args.container, args.screen, null, null); @@ -561,7 +565,7 @@ public final class Launcher extends Activity if (resultCode == RESULT_CANCELED) { completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId); } else if (resultCode == RESULT_OK) { - addAppWidgetImpl(appWidgetId, mWidgetBeingBoundOrConfigured); + addAppWidgetImpl(appWidgetId, mPendingAddInfo, null, mPendingAddWidgetInfo); } return; } @@ -611,15 +615,16 @@ public final class Launcher extends Activity private void completeTwoStageWidgetDrop(final int resultCode, final int appWidgetId) { CellLayout cellLayout = - (CellLayout) mWorkspace.getChildAt(mWidgetBeingBoundOrConfigured.screen); + (CellLayout) mWorkspace.getChildAt(mPendingAddInfo.screen); Runnable onCompleteRunnable = null; int animationType = 0; + AppWidgetHostView boundWidget = null; if (resultCode == RESULT_OK) { animationType = Workspace.COMPLETE_TWO_STAGE_WIDGET_DROP_ANIMATION; final AppWidgetHostView layout = mAppWidgetHost.createView(this, appWidgetId, - mWidgetBeingBoundOrConfigured.info); - mWidgetBeingBoundOrConfigured.boundWidget = layout; + mPendingAddWidgetInfo); + boundWidget = layout; onCompleteRunnable = new Runnable() { @Override public void run() { @@ -639,10 +644,14 @@ public final class Launcher extends Activity } }; } - mWorkspace.animateWidgetDrop(mWidgetBeingBoundOrConfigured, cellLayout, - (DragView) mDragLayer.getAnimatedView(), onCompleteRunnable, - animationType, mWidgetBeingBoundOrConfigured.boundWidget, true); - mWidgetBeingBoundOrConfigured = null; + if (mDragLayer.getAnimatedView() != null) { + mWorkspace.animateWidgetDrop(mPendingAddInfo, cellLayout, + (DragView) mDragLayer.getAnimatedView(), onCompleteRunnable, + animationType, boundWidget, true); + } else { + // The animated view may be null in the case of a rotation during widget configuration + onCompleteRunnable.run(); + } } @Override @@ -803,9 +812,13 @@ public final class Launcher extends Activity mPendingAddInfo.screen = pendingAddScreen; mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X); mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y); + mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X); + mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y); + mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO); mRestoring = true; } + boolean renameFolder = savedState.getBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, false); if (renameFolder) { long id = savedState.getLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID); @@ -1369,6 +1382,9 @@ public final class Launcher extends Activity outState.putInt(RUNTIME_STATE_PENDING_ADD_SCREEN, mPendingAddInfo.screen); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY); + outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX); + outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY); + outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo); } if (mFolderInfo != null && mWaitingForResult) { @@ -1547,26 +1563,20 @@ public final class Launcher extends Activity mPendingAddInfo.dropPos = null; } - void addAppWidgetFromPick(Intent data) { - // TODO: catch bad widget exception when sent - int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); - // TODO: Is this log message meaningful? - if (LOGD) Log.d(TAG, "dumping extras content=" + data.getExtras()); - addAppWidgetImpl(appWidgetId, null); - } + void addAppWidgetImpl(final int appWidgetId, ItemInfo info, AppWidgetHostView boundWidget, + AppWidgetProviderInfo appWidgetInfo) { + if (appWidgetInfo.configure != null) { + mPendingAddWidgetInfo = appWidgetInfo; - void addAppWidgetImpl(final int appWidgetId, final PendingAddWidgetInfo info) { - final AppWidgetProviderInfo appWidget = info.info; - if (appWidget.configure != null) { // Launch over to configure widget, if needed Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE); - intent.setComponent(appWidget.configure); + intent.setComponent(appWidgetInfo.configure); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET); - mWidgetBeingBoundOrConfigured = info; } else { // Otherwise just add it - completeAddAppWidget(appWidgetId, info.container, info.screen, info.boundWidget, appWidget); + completeAddAppWidget(appWidgetId, info.container, info.screen, boundWidget, + appWidgetInfo); // Exit spring loaded mode if necessary after adding the widget exitSpringLoadedDragModeDelayed(true, false, null); } @@ -1627,13 +1637,15 @@ public final class Launcher extends Activity int appWidgetId; if (hostView != null) { appWidgetId = hostView.getAppWidgetId(); - addAppWidgetImpl(appWidgetId, info); + addAppWidgetImpl(appWidgetId, info, hostView, info.info); } else { + // In this case, we either need to start an activity to get permission to bind + // the widget, or we need to start an activity to configure the widget, or both. appWidgetId = getAppWidgetHost().allocateAppWidgetId(); - mWidgetBeingBoundOrConfigured = info; if (mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.componentName)) { - addAppWidgetImpl(appWidgetId, info); + addAppWidgetImpl(appWidgetId, info, null, info.info); } else { + mPendingAddWidgetInfo = info.info; Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName); diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 100055689..fd9cc5726 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -3125,7 +3125,7 @@ public class Workspace extends SmoothPagedView } private void getFinalPositionForDropAnimation(int[] loc, float[] scaleXY, - DragView dragView, CellLayout layout, ItemInfo info, int[] targetCell, View finalView, + DragView dragView, CellLayout layout, ItemInfo info, int[] targetCell, boolean external) { // Now we animate the dragView, (ie. the widget or shortcut preview) into its final // location and size on the home screen. @@ -3161,7 +3161,7 @@ public class Workspace extends SmoothPagedView int[] finalPos = new int[2]; float scaleXY[] = new float[2]; getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, - finalView, external); + external); Resources res = mLauncher.getResources(); int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200; -- cgit v1.2.3 From 4d7d378ce413ea4682fdc6884591fe8605b6e366 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 11 May 2012 14:27:30 -0700 Subject: Fix folder order regression (issue 6482634) Change-Id: I8246450ec857d0653c65d9daaf7a8b771de6c974 --- src/com/android/launcher2/Folder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index e8f1ac96b..92cabe5a4 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -323,7 +323,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList int rhIndex = rhs.cellY * mNumCols + rhs.cellX; return (lhIndex - rhIndex); } - } private void placeInReadingOrder(ArrayList items) { @@ -335,7 +334,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList maxX = item.cellX; } } - GridComparator gridComparator = new GridComparator(maxX); + + GridComparator gridComparator = new GridComparator(maxX + 1); Collections.sort(items, gridComparator); final int countX = mContent.getCountX(); for (int i = 0; i < count; i++) { @@ -383,6 +383,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } else { mFolderName.setText(""); } + updateItemLocationsInDatabase(); } /** -- cgit v1.2.3 From c8f6d2e49d19cf6ba3ace5adef52b4068ac4b15d Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 11 May 2012 14:27:30 -0700 Subject: Fix folder order regression (issue 6482634) Change-Id: I8246450ec857d0653c65d9daaf7a8b771de6c974 --- src/com/android/launcher2/Folder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index e8f1ac96b..92cabe5a4 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -323,7 +323,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList int rhIndex = rhs.cellY * mNumCols + rhs.cellX; return (lhIndex - rhIndex); } - } private void placeInReadingOrder(ArrayList items) { @@ -335,7 +334,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList maxX = item.cellX; } } - GridComparator gridComparator = new GridComparator(maxX); + + GridComparator gridComparator = new GridComparator(maxX + 1); Collections.sort(items, gridComparator); final int countX = mContent.getCountX(); for (int i = 0; i < count; i++) { @@ -383,6 +383,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } else { mFolderName.setText(""); } + updateItemLocationsInDatabase(); } /** -- cgit v1.2.3 From 5212e51649c0754412c607d5a0f7bf896237f944 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 17 May 2012 12:24:40 -0700 Subject: Removing logging related to and fixing (issue 6238330) Change-Id: I7ed89840d90fd13cbfedc795e789706b32f76b5d --- src/com/android/launcher2/AppsCustomizePagedView.java | 10 ---------- src/com/android/launcher2/PagedViewWidget.java | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 4712a37b8..618d62e55 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -614,24 +614,18 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen @Override public void onShortPress(View v) { - Log.d(TAG, "onShortPress, view: " + v); // We are anticipating a long press, and we use this time to load bind and instantiate // the widget. This will need to be cleaned up if it turns out no long press occurs. if (mCreateWidgetInfo != null) { - Log.d(TAG, "onShortPress --> cleanup previous, view: " + v + ", create info: " + mCreateWidgetInfo); // Just in case the cleanup process wasn't properly executed. This shouldn't happen. cleanupWidgetPreloading(false); } mCreateWidgetInfo = new PendingAddWidgetInfo((PendingAddWidgetInfo) v.getTag()); - Log.d(TAG, "onShortPress --> create widget info: " + mCreateWidgetInfo); preloadWidget(mCreateWidgetInfo); } private void cleanupWidgetPreloading(boolean widgetWasAdded) { - Log.d(TAG, "cleanup widget preloading"); - if (!widgetWasAdded) { - Log.d(TAG, "cleanup widget preloading --> widget wasn't added"); // If the widget was not added, we may need to do further cleanup. PendingAddWidgetInfo info = mCreateWidgetInfo; mCreateWidgetInfo = null; @@ -657,9 +651,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen @Override public void cleanUpShortPress(View v) { - Log.d(TAG, "cleanup shortpress, view: " + v); if (!mDraggingWidget) { - Log.d(TAG, "cleanup shortpress --> cleanup preloading"); cleanupWidgetPreloading(false); } } @@ -675,7 +667,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and // we abort the drag. if (image.getDrawable() == null) { - Log.d(TAG, "begin dragging widget, no drawable"); mDraggingWidget = false; return false; } @@ -683,7 +674,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // This can happen in some weird cases involving multi-touch. We can't start dragging the // widget if this is null, so we break out. if (mCreateWidgetInfo == null) { - Log.d(TAG, "begin dragging widget, create widget info null"); return false; } diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java index a6ea78f46..e89414254 100644 --- a/src/com/android/launcher2/PagedViewWidget.java +++ b/src/com/android/launcher2/PagedViewWidget.java @@ -144,8 +144,8 @@ public class PagedViewWidget extends LinearLayout { if (sShortpressTarget != null) return; if (mShortPressListener != null) { mShortPressListener.onShortPress(PagedViewWidget.this); + sShortpressTarget = PagedViewWidget.this; } - sShortpressTarget = PagedViewWidget.this; mShortPressTriggered = true; } } -- cgit v1.2.3 From 98a72fbb08f30fe9d42555460c453e4d438867f5 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 17 May 2012 13:43:29 -0700 Subject: Fixing regression where you can't add shortcuts Change-Id: I2c91a9a5131591aa15319efdaf887f06fb593b08 --- src/com/android/launcher2/AppsCustomizePagedView.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 618d62e55..5e0d43dcc 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -657,8 +657,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } private boolean beginDraggingWidget(View v) { - Log.d(TAG, "begin dragging widget, view: " + v); - mDraggingWidget = true; // Get the widget preview as the drag representation ImageView image = (ImageView) v.findViewById(R.id.widget_preview); @@ -671,17 +669,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen return false; } - // This can happen in some weird cases involving multi-touch. We can't start dragging the - // widget if this is null, so we break out. - if (mCreateWidgetInfo == null) { - return false; - } - // Compose the drag image Bitmap preview; Bitmap outline; float scale = 1f; if (createItemInfo instanceof PendingAddWidgetInfo) { + // This can happen in some weird cases involving multi-touch. We can't start dragging + // the widget if this is null, so we break out. + if (mCreateWidgetInfo == null) { + return false; + } + PendingAddWidgetInfo createWidgetInfo = mCreateWidgetInfo; createItemInfo = createWidgetInfo; int spanX = createItemInfo.spanX; -- cgit v1.2.3 From 99838b84078f0f787c488ee8ffafafad7f76bbe2 Mon Sep 17 00:00:00 2001 From: Andrew Flynn Date: Thu, 17 May 2012 13:37:52 -0700 Subject: Change custom workspace cling Change-Id: I8fe44469ac4bf38f9be2228d8eace1198bf3a48e --- res/values/dimens.xml | 2 -- src/com/android/launcher2/Cling.java | 24 ++++++------------------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index fa85a1b16..e789fdf33 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -22,8 +22,6 @@ 0dp 0dp 48dp - -