Merge "Fixing issue where flinging-to-delete from a folder does not reflow/close the folder. (Bug 6240540)"
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index fb319fe..5aa39c4 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);
@@ -2071,11 +2073,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/Workspace.java b/src/com/android/launcher2/Workspace.java
index 2b69a12..239031f 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -3353,9 +3353,11 @@
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, Favorites.CONTAINER_DESKTOP,
+ screen, info.cellX, info.cellY);
+ }
}
}
@@ -3409,7 +3411,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)) {