merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_architecture.jpg b/res/drawable-sw720dp-nodpi/wallpaper_00.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_architecture.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_00.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_architecture_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_00_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_architecture_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_00_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_bubblegum.jpg b/res/drawable-sw720dp-nodpi/wallpaper_01.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_bubblegum.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_01.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_bubblegum_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_01_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_bubblegum_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_01_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_canyon.jpg b/res/drawable-sw720dp-nodpi/wallpaper_02.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_canyon.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_02.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_canyon_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_02_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_canyon_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_02_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_chroma.jpg b/res/drawable-sw720dp-nodpi/wallpaper_03.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_chroma.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_03.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_chroma_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_03_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_chroma_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_03_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_escape.jpg b/res/drawable-sw720dp-nodpi/wallpaper_04.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_escape.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_04.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_escape_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_04_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_escape_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_04_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_fidelity.jpg b/res/drawable-sw720dp-nodpi/wallpaper_05.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_fidelity.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_05.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_fidelity_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_05_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_fidelity_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_05_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_flora.jpg b/res/drawable-sw720dp-nodpi/wallpaper_06.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_flora.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_06.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_flora_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_06_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_flora_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_06_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_kepler.jpg b/res/drawable-sw720dp-nodpi/wallpaper_07.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_kepler.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_07.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_kepler_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_07_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_kepler_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_07_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_leaf.jpg b/res/drawable-sw720dp-nodpi/wallpaper_08.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_leaf.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_08.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_leaf_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_08_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_leaf_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_08_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_noir.jpg b/res/drawable-sw720dp-nodpi/wallpaper_09.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_noir.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_09.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_noir_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_09_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_noir_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_09_small.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_outofthebox.jpg b/res/drawable-sw720dp-nodpi/wallpaper_10.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_outofthebox.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_10.jpg
Binary files differ
diff --git a/res/drawable-sw720dp-nodpi/wallpaper_outofthebox_small.jpg b/res/drawable-sw720dp-nodpi/wallpaper_10_small.jpg
similarity index 100%
rename from res/drawable-sw720dp-nodpi/wallpaper_outofthebox_small.jpg
rename to res/drawable-sw720dp-nodpi/wallpaper_10_small.jpg
Binary files differ
diff --git a/res/layout/custom_workspace_cling.xml b/res/layout/custom_workspace_cling.xml
new file mode 100644
index 0000000..5bdc587
--- /dev/null
+++ b/res/layout/custom_workspace_cling.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<!-- dummy layout, to be replaced in overlays -->
+<com.android.launcher2.Cling
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+    launcher:drawIdentifier="workspace_custom">
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textSize="20dp"
+        android:textColor="@android:color/holo_blue_light"
+        android:text="@string/dummy_custom_cling_error_message"
+        android:gravity="left"
+        android:layout_gravity="bottom|left"
+    />
+</com.android.launcher2.Cling>
diff --git a/res/values-sw720dp/wallpapers.xml b/res/values-sw720dp/wallpapers.xml
index fb386f4..8b01477 100644
--- a/res/values-sw720dp/wallpapers.xml
+++ b/res/values-sw720dp/wallpapers.xml
@@ -17,16 +17,16 @@
 
 <resources>
     <string-array name="wallpapers" translatable="false">
-        <item>wallpaper_architecture</item>
-        <item>wallpaper_bubblegum</item>
-        <item>wallpaper_canyon</item>
-        <item>wallpaper_chroma</item>
-        <item>wallpaper_escape</item>
-        <item>wallpaper_fidelity</item>
-        <item>wallpaper_flora</item>
-        <item>wallpaper_kepler</item>
-        <item>wallpaper_leaf</item>
-        <item>wallpaper_noir</item>
-        <item>wallpaper_outofthebox</item>
+        <item>wallpaper_00</item>
+        <item>wallpaper_01</item>
+        <item>wallpaper_02</item>
+        <item>wallpaper_03</item>
+        <item>wallpaper_04</item>
+        <item>wallpaper_05</item>
+        <item>wallpaper_06</item>
+        <item>wallpaper_07</item>
+        <item>wallpaper_08</item>
+        <item>wallpaper_09</item>
+        <item>wallpaper_10</item>
     </string-array>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d497c2d..628884f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -22,6 +22,9 @@
     <dimen name="cling_text_block_offset_x">0dp</dimen>
     <dimen name="cling_text_block_offset_y">0dp</dimen>
     <dimen name="reveal_radius">48dp</dimen>
+    <!-- entries for custom clings, will be set in overlays -->
+    <add-resource type="dimen" name="custom_cling_margin_top" />
+    <add-resource type="dimen" name="custom_cling_margin_right" />
 
 <!-- Workspace -->
     <!-- qsb_bar_height_inset represents qsb_bar_height minus the padding
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4aee339..0ea12c4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -244,6 +244,8 @@
     <string name="folder_cling_create_folder">To make a new folder on your Home screen, stack one app on top of another.</string>
     <!-- The text on the button to dismiss a cling [CHAR_LIMIT=none] -->
     <string name="cling_dismiss">OK</string>
+    <!-- Error message on dummy custom cling layout [DO NOT TRANSLATE] -->
+    <string name="dummy_custom_cling_error_message">Error: custom workspace layout passed in but custom cling was not overwritten</string>
     <add-resource type="string" name="default_folder_name" />
 
     <!-- Folder accessibility -->
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 609bb6d..b717261 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -617,11 +617,22 @@
         Bundle options = null;
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
             AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, mTmpRect);
+            Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(mLauncher,
+                    info.componentName, null);
+
+            float density = getResources().getDisplayMetrics().density;
+            int xPaddingDips = (int) ((padding.left + padding.right) / density);
+            int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
+
             options = new Bundle();
-            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, mTmpRect.left);
-            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, mTmpRect.top);
-            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, mTmpRect.right);
-            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, mTmpRect.bottom);
+            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
+                    mTmpRect.left - xPaddingDips);
+            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
+                    mTmpRect.top - yPaddingDips);
+            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
+                    mTmpRect.right - xPaddingDips);
+            options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
+                    mTmpRect.bottom - yPaddingDips);
         }
         return options;
     }
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 3fdf5c3..f94194b 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1191,9 +1191,8 @@
 
             launcherInfo.hostView.setTag(launcherInfo);
             launcherInfo.hostView.setVisibility(View.VISIBLE);
-            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
-                launcherInfo.notifyWidgetSizeChanged(this);
-            }
+            launcherInfo.notifyWidgetSizeChanged(this);
+
             mWorkspace.addInScreen(launcherInfo.hostView, container, screen, cellXY[0], cellXY[1],
                     launcherInfo.spanX, launcherInfo.spanY, isWorkspaceLocked());
 
@@ -3733,6 +3732,18 @@
         if (isClingsEnabled() &&
                 !mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false) &&
                 !skipCustomClingIfNoAccounts() ) {
+            // If we're not using the default workspace layout, replace workspace cling
+            // with a custom workspace cling (usually specified in an overlay)
+            if (mSharedPrefs.getInt(LauncherProvider.DEFAULT_WORKSPACE_RESOURCE_ID, 0) != 0) {
+                // Use a custom cling
+                View cling = findViewById(R.id.workspace_cling);
+                ViewGroup clingParent = (ViewGroup) cling.getParent();
+                int clingIndex = clingParent.indexOfChild(cling);
+                clingParent.removeViewAt(clingIndex);
+                View customCling = mInflater.inflate(R.layout.custom_workspace_cling, clingParent, false);
+                clingParent.addView(customCling, clingIndex);
+                customCling.setId(R.id.workspace_cling);
+            }
             initCling(R.id.workspace_cling, null, false, 0);
         } else {
             removeCling(R.id.workspace_cling);
diff --git a/src/com/android/launcher2/LauncherAppWidgetInfo.java b/src/com/android/launcher2/LauncherAppWidgetInfo.java
index 5c8fb38..602695a 100644
--- a/src/com/android/launcher2/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher2/LauncherAppWidgetInfo.java
@@ -73,8 +73,7 @@
      * done so already (only really for default workspace widgets).
      */
     void onBindAppWidget(Launcher launcher) {
-        if (!mHasNotifiedInitialWidgetSizeChanged &&
-            Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
+        if (!mHasNotifiedInitialWidgetSizeChanged) {
             notifyWidgetSizeChanged(launcher);
         }
     }
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index 74cf7a4..8097ac9 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -74,6 +74,8 @@
     static final String PARAMETER_NOTIFY = "notify";
     static final String DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED =
             "DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED";
+    static final String DEFAULT_WORKSPACE_RESOURCE_ID =
+            "DEFAULT_WORKSPACE_RESOURCE_ID";
 
     private static final String ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE =
             "com.android.launcher.action.APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE";
@@ -206,18 +208,23 @@
     /**
      * @param workspaceResId that can be 0 to use default or non-zero for specific resource
      */
-    synchronized public void loadDefaultFavoritesIfNecessary(int workspaceResId) {
+    synchronized public void loadDefaultFavoritesIfNecessary(int origWorkspaceResId) {
         String spKey = LauncherApplication.getSharedPreferencesKey();
         SharedPreferences sp = getContext().getSharedPreferences(spKey, Context.MODE_PRIVATE);
         if (sp.getBoolean(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED, false)) {
+            int workspaceResId = origWorkspaceResId;
+
             // Use default workspace resource if none provided
             if (workspaceResId == 0) {
-                workspaceResId = R.xml.default_workspace;
+                workspaceResId = sp.getInt(DEFAULT_WORKSPACE_RESOURCE_ID, R.xml.default_workspace);
             }
 
             // Populate favorites table with initial favorites
             SharedPreferences.Editor editor = sp.edit();
             editor.remove(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED);
+            if (origWorkspaceResId != 0) {
+                editor.putInt(DEFAULT_WORKSPACE_RESOURCE_ID, origWorkspaceResId);
+            }
             mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), workspaceResId);
             editor.commit();
         }
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 77cb467..6350c84 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2232,11 +2232,9 @@
 
                 boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0;
 
-                // if the widget resizes on drop, or the sdk level is less than JBMR1, then we
-                // need to update the size.
+                // if the widget resizes on drop
                 if (foundCell && (cell instanceof AppWidgetHostView) &&
-                        (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY ||
-                        Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
+                        (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY)) {
                     resizeOnDrop = true;
                     item.spanX = resultSpan[0];
                     item.spanY = resultSpan[1];
@@ -3045,7 +3043,7 @@
             }
 
             final ItemInfo item = (ItemInfo) d.dragInfo;
-            boolean updateWidgetSize = Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN;
+            boolean updateWidgetSize = false;
             if (findNearestVacantCell) {
                 int minSpanX = item.spanX;
                 int minSpanY = item.spanY;