Merge "Adding workaround for issue where icon labels on workspace were loaded differently than those in AllApps. (Bug 5250760)"
diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml
index 13d0acf..ae5a8c7 100644
--- a/res/values-af/strings.xml
+++ b/res/values-af/strings.xml
@@ -41,7 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Legstukke"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Muurpapier"</string>
     <string name="out_of_space" msgid="3056555298801463098">"Geen spasie op tuisskerm oor nie."</string>
-    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Nie meer plek op die warmlaai nie."</string>
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Geen plek meer op die warmlaai nie."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Hierdie legstuk is te groot vir die hoofposisie."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Kortpad \"<xliff:g id="NAME">%s</xliff:g>\" is geskep."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Kortpad \"<xliff:g id="NAME">%s</xliff:g>\" is verwyder."</string>
diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml
index 30e94e3..109e460 100644
--- a/res/values-bg/strings.xml
+++ b/res/values-bg/strings.xml
@@ -41,8 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Приспособления"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Тапети"</string>
     <string name="out_of_space" msgid="3056555298801463098">"На началните ви екрани няма повече място."</string>
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"В трамплина няма повече място."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Това приспособление е твърде голямо за трамплина."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Прекият път за „<xliff:g id="NAME">%s</xliff:g>“ бе създаден."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Прекият път към „<xliff:g id="NAME">%s</xliff:g>“ бе премахнат."</string>
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 513517d..f392747 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -41,7 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Widgets"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Tapeter"</string>
     <string name="out_of_space" msgid="3056555298801463098">"Der er ikke mere plads på dine startskærme."</string>
-    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Der er ikke mere plads på hotseat."</string>
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Der er ikke mere plads i hotseatet."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Denne widget er for stor til hotseat."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Genvejen \"<xliff:g id="NAME">%s</xliff:g>\" blev oprettet."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Genvejen \"<xliff:g id="NAME">%s</xliff:g>\" blev fjernet."</string>
diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml
index d129f1c..2f8b4cc 100644
--- a/res/values-es-rUS/strings.xml
+++ b/res/values-es-rUS/strings.xml
@@ -40,9 +40,8 @@
     <string name="group_shortcuts" msgid="9133529424900391877">"Accesos directos"</string>
     <string name="group_widgets" msgid="6704978494073105844">"Widgets"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Papeles tapiz"</string>
-    <string name="out_of_space" msgid="3056555298801463098">"No hay más espacio en tu pantalla de la página principal"</string>
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="out_of_space" msgid="3056555298801463098">"No hay más espacio en tu pantalla principal."</string>
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"No queda espacio en la barra de accesos directos."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Este widget es demasiado grande para el banquillo."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Acceso directo \"<xliff:g id="NAME">%s</xliff:g>\" creado."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"El acceso directo \"<xliff:g id="NAME">%s</xliff:g>\" ha sido eliminado."</string>
diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml
index 7e3f514..707abec 100644
--- a/res/values-fa/strings.xml
+++ b/res/values-fa/strings.xml
@@ -40,10 +40,8 @@
     <string name="group_shortcuts" msgid="9133529424900391877">"میانبرها"</string>
     <string name="group_widgets" msgid="6704978494073105844">"ابزارک ها"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"تصاویر زمینه"</string>
-    <!-- no translation found for out_of_space (3056555298801463098) -->
-    <skip />
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="out_of_space" msgid="3056555298801463098">"فضای بیشتری در صفحات نمایش اصلی شما موجود نیست."</string>
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"فضای بیشتری در صندلی داغ نیست."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"این ابزارک بیش از حد برای صندلی داغ بزرگ است."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"میانبر \"<xliff:g id="NAME">%s</xliff:g>\" ایجاد شد."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"میانبر \"<xliff:g id="NAME">%s</xliff:g>\" حذف شد."</string>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 312a456..d0d104f 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -41,7 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Widgets"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Fonds d\'écran"</string>
     <string name="out_of_space" msgid="3056555298801463098">"Vous n\'avez plus d\'espace libre sur vos écrans d\'accueil."</string>
-    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Vous n\'avez plus d\'espace libre sur la barre d\'accès rapide."</string>
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Vous n\'avez plus de place sur la barre d\'accès rapide."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Ce widget est trop volumineux pour la barre d\'accès rapide."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Le raccourci \"<xliff:g id="NAME">%s</xliff:g>\" a été créé."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Le raccourci \"<xliff:g id="NAME">%s</xliff:g>\" a été supprimé."</string>
diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml
index ba1c9de..4e4360a 100644
--- a/res/values-in/strings.xml
+++ b/res/values-in/strings.xml
@@ -59,7 +59,7 @@
     <string name="accessibility_voice_search_button" msgid="3938249215065842475">"Penelusuran Suara"</string>
     <string name="accessibility_all_apps_button" msgid="8803738611398979849">"Apl"</string>
     <string name="accessibility_delete_button" msgid="3628162007991023603">"Hapus"</string>
-    <string name="delete_zone_label_all_apps_system_app" msgid="3683920959591819044">"Copot pemasangan pemutakhiran"</string>
+    <string name="delete_zone_label_all_apps_system_app" msgid="3683920959591819044">"Copot pemasangan pembaruan"</string>
     <string name="menu_add" msgid="3065046628354640854">"Tambahkan"</string>
     <string name="menu_manage_apps" msgid="2308685199463588895">"Kelola apl"</string>
     <string name="menu_wallpaper" msgid="5837429080911269832">"Wallpaper"</string>
diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml
index b78bb20..4ea571e 100644
--- a/res/values-ms/strings.xml
+++ b/res/values-ms/strings.xml
@@ -41,8 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Widget"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Kertas dinding"</string>
     <string name="out_of_space" msgid="3056555298801463098">"Tiada lagi ruang pada skrin Utama anda."</string>
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Tiada lagi ruang pada kerusi panas."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Widget ini terlalu besar untuk kerusi panas."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Pintasan \"<xliff:g id="NAME">%s</xliff:g>\" diwujudkan."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Pintasan \"<xliff:g id="NAME">%s</xliff:g>\" telah dialih keluar."</string>
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index 8a0ccba..4f91467 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -40,7 +40,7 @@
     <string name="group_shortcuts" msgid="9133529424900391877">"Atalhos"</string>
     <string name="group_widgets" msgid="6704978494073105844">"Widgets"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Imagens de fundo"</string>
-    <string name="out_of_space" msgid="3056555298801463098">"Sem espaço nos ecrã Principais."</string>
+    <string name="out_of_space" msgid="3056555298801463098">"Sem espaço nos Ecrãs principais."</string>
     <string name="hotseat_out_of_space" msgid="6304886797358479361">"Não existe espaço suficiente na barra personalizável."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Este widget é demasiado grande para a barra inferior."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"O atalho \"<xliff:g id="NAME">%s</xliff:g>\" foi criado."</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index fa0be92..0557447 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -40,7 +40,7 @@
     <string name="group_shortcuts" msgid="9133529424900391877">"Ярлыки"</string>
     <string name="group_widgets" msgid="6704978494073105844">"Виджеты"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Обои"</string>
-    <string name="out_of_space" msgid="3056555298801463098">"На главных экранах нет свободного места."</string>
+    <string name="out_of_space" msgid="3056555298801463098">"На главных экранах всё занято."</string>
     <string name="hotseat_out_of_space" msgid="6304886797358479361">"Нет свободного места в слоте."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Виджет слишком велик для слота."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Ярлык \"<xliff:g id="NAME">%s</xliff:g>\" создан"</string>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index 53463d3..0fc2a5a 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -41,8 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Wijeti"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Mandhari"</string>
     <string name="out_of_space" msgid="3056555298801463098">"Hakuna nafasi zaidi kwenye skrini zako za nyumbani."</string>
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Hakuna nafasi zaidi kwenye eneo kali."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Wijeti hii ni kubwa zaidi kwa hotseat."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Njia ya mkato ya \"<xliff:g id="NAME">%s</xliff:g>\" imeundwa."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Njia ya mkato ya \"<xliff:g id="NAME">%s</xliff:g>\" iliondolewa."</string>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index dc0b9d7..c19a9d8 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -41,8 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"Tiện ích"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"Hình nền"</string>
     <string name="out_of_space" msgid="3056555298801463098">"Không còn chỗ trên màn hình chính của bạn."</string>
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"Không còn chỗ trên vùng gắn."</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"Tiện ích này quá lớn cho điểm giới hạn."</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"Lối tắt \"<xliff:g id="NAME">%s</xliff:g>\" đã được tạo."</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"Lối tắt \"<xliff:g id="NAME">%s</xliff:g>\" đã bị xóa."</string>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 4f89e91..7c30da4 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -41,8 +41,7 @@
     <string name="group_widgets" msgid="6704978494073105844">"窗口小部件"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"壁纸"</string>
     <string name="out_of_space" msgid="3056555298801463098">"您的主屏幕上没有空间了。"</string>
-    <!-- no translation found for hotseat_out_of_space (6304886797358479361) -->
-    <skip />
+    <string name="hotseat_out_of_space" msgid="6304886797358479361">"底部区域已无空间。"</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"该窗口小部件太大,超出基座区域可用空间。"</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"已创建“<xliff:g id="NAME">%s</xliff:g>”快捷方式。"</string>
     <string name="shortcut_uninstalled" msgid="2129499669449749995">"已删除“<xliff:g id="NAME">%s</xliff:g>”快捷方式。"</string>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index 850809f..00eeaf1 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -40,8 +40,7 @@
     <string name="group_shortcuts" msgid="9133529424900391877">"捷徑"</string>
     <string name="group_widgets" msgid="6704978494073105844">"小工具"</string>
     <string name="group_wallpapers" msgid="1568191644272224858">"桌布"</string>
-    <!-- no translation found for out_of_space (3056555298801463098) -->
-    <skip />
+    <string name="out_of_space" msgid="3056555298801463098">"主螢幕已無空間。"</string>
     <string name="hotseat_out_of_space" msgid="6304886797358479361">"停駐區已無可用空間。"</string>
     <string name="invalid_hotseat_item" msgid="6545340627805449250">"這個小工具過大,超出可用的空間。"</string>
     <string name="shortcut_installed" msgid="7071557296331322355">"已建立「<xliff:g id="NAME">%s</xliff:g>」捷徑。"</string>
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index af0f205..0199d01 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -255,8 +255,8 @@
                     PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
                     mAnimationBuffer.setAlpha(1f);
                     mAnimationBuffer.setVisibility(View.VISIBLE);
-                    LayoutParams p = new FrameLayout.LayoutParams(child.getWidth(),
-                            child.getHeight());
+                    LayoutParams p = new FrameLayout.LayoutParams(child.getMeasuredWidth(),
+                            child.getMeasuredHeight());
                     p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
                     mAnimationBuffer.addView(child, p);
                 }
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index fb319fe..199c41a 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -57,6 +57,7 @@
 public class CellLayout extends ViewGroup {
     static final String TAG = "CellLayout";
 
+    private Launcher mLauncher;
     private int mOriginalCellWidth;
     private int mOriginalCellHeight;
     private int mCellWidth;
@@ -175,6 +176,7 @@
         // A ViewGroup usually does not draw, but CellLayout needs to draw a rectangle to show
         // the user where a dragged item will land when dropped.
         setWillNotDraw(false);
+        mLauncher = (Launcher) context;
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
 
@@ -189,6 +191,8 @@
         mCountY = LauncherModel.getCellCountY();
         mOccupied = new boolean[mCountX][mCountY];
         mTmpOccupied = new boolean[mCountX][mCountY];
+        mPreviousReorderDirection[0] = INVALID_DIRECTION;
+        mPreviousReorderDirection[1] = INVALID_DIRECTION;
 
         a.recycle();
 
@@ -1564,7 +1568,8 @@
         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;
         }
 
@@ -2071,11 +2076,14 @@
             View child = mShortcutsAndWidgets.getChildAt(i);
             LayoutParams lp = (LayoutParams) child.getLayoutParams();
             ItemInfo info = (ItemInfo) child.getTag();
-            info.cellX = lp.cellX = lp.tmpCellX;
-            info.cellY = lp.cellY = lp.tmpCellY;
+            // We do a null check here because the item info can be null in the case of the
+            // AllApps button in the hotseat.
+            if (info != null) {
+                info.cellX = lp.cellX = lp.tmpCellX;
+                info.cellY = lp.cellY = lp.tmpCellY;
+            }
         }
-        Workspace workspace = (Workspace) getParent();
-        workspace.updateItemLocationsInDatabase(this);
+        mLauncher.getWorkspace().updateItemLocationsInDatabase(this);
     }
 
     public void setUseTempCoords(boolean useTempCoords) {
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 5a8617c..eba89e5 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -652,7 +652,6 @@
 
         mDragObject.x = coordinates[0];
         mDragObject.y = coordinates[1];
-        mDragObject.dragComplete = true;
 
         // Clean up dragging on the target if it's not the current fling delete target otherwise,
         // start dragging to it.
@@ -663,6 +662,9 @@
         // Drop onto the fling-to-delete target
         boolean accepted = false;
         mFlingToDeleteDropTarget.onDragEnter(mDragObject);
+        // We must set dragComplete to true _only_ after we "enter" the fling-to-delete target for
+        // "drop"
+        mDragObject.dragComplete = true;
         mFlingToDeleteDropTarget.onDragExit(mDragObject);
         if (mFlingToDeleteDropTarget.acceptDrop(mDragObject)) {
             mFlingToDeleteDropTarget.onFlingToDelete(mDragObject, mDragObject.x, mDragObject.y,
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 2b69a12..06e0185 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1744,6 +1744,7 @@
     @Override
     public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
         mIsSwitchingState = true;
+        cancelScrollingIndicatorAnimations();
     }
 
     @Override
@@ -3349,13 +3350,23 @@
 
     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();
-
-            LauncherModel.moveItemInDatabase(mLauncher, info, Favorites.CONTAINER_DESKTOP, screen,
-                        info.cellX, info.cellY);
+            // Null check required as the AllApps button doesn't have an item info
+            if (info != null) {
+                LauncherModel.moveItemInDatabase(mLauncher, info, container, screen, info.cellX,
+                        info.cellY);
+            }
         }
     }
 
@@ -3409,7 +3420,8 @@
     @Override
     public boolean onEnterScrollArea(int x, int y, int direction) {
         // Ignore the scroll area if we are dragging over the hot seat
-        if (mLauncher.getHotseat() != null) {
+        boolean isPortrait = !LauncherApplication.isScreenLandscape(getContext());
+        if (mLauncher.getHotseat() != null && isPortrait) {
             Rect r = new Rect();
             mLauncher.getHotseat().getHitRect(r);
             if (r.contains(x, y)) {