merge in jb-release history after reset to master
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 840ec45..f1ae2c5 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -577,6 +577,16 @@
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 @@
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 @@
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 @@
// 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/Hotseat.java b/src/com/android/launcher2/Hotseat.java
index 9e525bd..fbb45b9 100644
--- a/src/com/android/launcher2/Hotseat.java
+++ b/src/com/android/launcher2/Hotseat.java
@@ -104,7 +104,6 @@
inflater.inflate(R.layout.application, mContent, false);
allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null,
context.getResources().getDrawable(R.drawable.all_apps_button_icon), null, null);
- // allAppsButton.setText(context.getString(R.string.all_apps_button_label));
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
allAppsButton.setOnTouchListener(new View.OnTouchListener() {
@Override
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 32c77c7..a9c4970 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1228,7 +1228,39 @@
return;
}
- int N;
+ // Get the list of workspace items to load and unbind the existing ShortcutInfos
+ // before we call startBinding() below.
+ final int currentScreen = oldCallbacks.getCurrentWorkspaceScreen();
+ final ArrayList<ItemInfo> tmpWorkspaceItems = unbindWorkspaceItemsOnMainThread();
+ // Order the items for loading as follows: current workspace, hotseat, everything else
+ Collections.sort(tmpWorkspaceItems, new Comparator<ItemInfo>() {
+ @Override
+ public int compare(ItemInfo lhs, ItemInfo rhs) {
+ int cellCountX = LauncherModel.getCellCountX();
+ int cellCountY = LauncherModel.getCellCountY();
+ int screenOffset = cellCountX * cellCountY;
+ int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); // +1 hotseat
+ long lr = (lhs.container * containerOffset + lhs.screen * screenOffset +
+ lhs.cellY * cellCountX + lhs.cellX);
+ long rr = (rhs.container * containerOffset + rhs.screen * screenOffset +
+ rhs.cellY * cellCountX + rhs.cellX);
+ return (int) (lr - rr);
+ }
+ });
+ // Precondition: the items are ordered by page, screen
+ final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();
+ for (ItemInfo ii : tmpWorkspaceItems) {
+ // Prepend the current items, hotseat items, append everything else
+ if (ii.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
+ ii.screen == currentScreen) {
+ workspaceItems.add(0, ii);
+ } else if (ii.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ workspaceItems.add(0, ii);
+ } else {
+ workspaceItems.add(ii);
+ }
+ }
+
// Tell the workspace that we're about to start firing items at it
mHandler.post(new Runnable() {
public void run() {
@@ -1239,10 +1271,8 @@
}
});
- final ArrayList<ItemInfo> workspaceItems = unbindWorkspaceItemsOnMainThread();
-
// Add the items to the workspace.
- N = workspaceItems.size();
+ int N = workspaceItems.size();
for (int i=0; i<N; i+=ITEMS_CHUNK) {
final int start = i;
final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);
@@ -1278,7 +1308,6 @@
// but since getCurrentScreen() just returns the int, we should be okay. This
// is just a hint for the order, and if it's wrong, we'll be okay.
// TODO: instead, we should have that push the current screen into here.
- final int currentScreen = oldCallbacks.getCurrentWorkspaceScreen();
N = sAppWidgets.size();
// once for the current screen
for (int i=0; i<N; i++) {
diff --git a/src/com/android/launcher2/PendingAddItemInfo.java b/src/com/android/launcher2/PendingAddItemInfo.java
index d36e217..26e946e 100644
--- a/src/com/android/launcher2/PendingAddItemInfo.java
+++ b/src/com/android/launcher2/PendingAddItemInfo.java
@@ -76,5 +76,9 @@
configurationData = copy.configurationData;
componentName = copy.componentName;
itemType = copy.itemType;
+ spanX = copy.spanX;
+ spanY = copy.spanY;
+ minSpanX = copy.minSpanX;
+ minSpanY = copy.minSpanY;
}
}
diff --git a/src/com/android/launcher2/ShortcutInfo.java b/src/com/android/launcher2/ShortcutInfo.java
index ff3028b..76892db 100644
--- a/src/com/android/launcher2/ShortcutInfo.java
+++ b/src/com/android/launcher2/ShortcutInfo.java
@@ -149,7 +149,10 @@
@Override
public String toString() {
- return "ShortcutInfo(title=" + title.toString() + ")";
+ return "ShortcutInfo(title=" + title.toString() + "intent=" + intent + "id=" + this.id
+ + " type=" + this.itemType + " container=" + this.container + " screen=" + screen
+ + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY
+ + " isGesture=" + isGesture + " dropPos=" + dropPos + ")";
}
public static void dumpShortcutInfoList(String tag, String label,