Fixing issue where you can't drag from AllApps.

Change-Id: I61bd966b97d275ece1db238edaac8d66936d0a20
diff --git a/src/com/android/launcher2/AllApps2D.java b/src/com/android/launcher2/AllApps2D.java
index 1cbb999..329109f 100644
--- a/src/com/android/launcher2/AllApps2D.java
+++ b/src/com/android/launcher2/AllApps2D.java
@@ -143,7 +143,7 @@
                 homeButton.setOnClickListener(
                     new View.OnClickListener() {
                         public void onClick(View v) {
-                            mLauncher.closeAllApps(true);
+                            mLauncher.showWorkspace(true);
                         }
                     });
             }
@@ -167,7 +167,7 @@
 
         switch (keyCode) {
             case KeyEvent.KEYCODE_BACK:
-                mLauncher.closeAllApps(true);
+                mLauncher.showWorkspace(true);
                 break;
             default:
                 return false;
@@ -190,7 +190,7 @@
         app = new ApplicationInfo(app);
 
         mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
-        mLauncher.closeAllApps(true);
+        mLauncher.showWorkspace(true);
 
         return true;
     }
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index 29f49af..d42481b 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -350,7 +350,7 @@
             if (mArrowNavigation) {
                 if (mLastSelection == SELECTION_HOME) {
                     reallyPlaySoundEffect(SoundEffectConstants.CLICK);
-                    mLauncher.closeAllApps(true);
+                    mLauncher.showWorkspace(true);
                 } else {
                     int whichApp = sRollo.mScript.get_gSelectedIconIndex();
                     if (whichApp >= 0) {
@@ -637,7 +637,7 @@
                     if ((isPortrait && y > mTouchYBorders[mTouchYBorders.length-1]) ||
                         (!isPortrait && x > mTouchXBorders[mTouchXBorders.length-1])) {
                         reallyPlaySoundEffect(SoundEffectConstants.CLICK);
-                        mLauncher.closeAllApps(true);
+                        mLauncher.showWorkspace(true);
                     }
                     sRollo.setHomeSelected(SELECTED_NONE);
                 }
@@ -691,10 +691,12 @@
             int screenX = mMotionDownRawX - (bmp.getWidth() / 2);
             int screenY = mMotionDownRawY - bmp.getHeight();
 
+            mLauncher.lockScreenOrientation();
+            mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, bmp);
             mDragController.startDrag(
                     bmp, screenX, screenY, this, app, DragController.DRAG_ACTION_COPY);
 
-            mLauncher.closeAllApps(true);
+            mLauncher.showWorkspace(true);
         }
         return true;
     }
@@ -747,6 +749,8 @@
 
     @Override
     public void onDropCompleted(View target, Object dragInfo, boolean success) {
+        mLauncher.getWorkspace().onDragStopped(success);
+        mLauncher.unlockScreenOrientation();
     }
 
     /**
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index d7a360d..64cbee4 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -3106,7 +3106,7 @@
                 mAllAppsGrid.zoom(0.0f, animated);
             }
             ((View)mAllAppsGrid).setFocusable(false);
-            mWorkspace.getChildAt(mWorkspace.getCurrentPage()).requestFocus();
+            ((CellLayout) mWorkspace.getChildAt(mWorkspace.getCurrentPage())).getChildrenLayout().requestFocus();
         }
     }
 
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index b5c1074..2e202f7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1708,26 +1708,32 @@
         for (int i = 0; i < screenCount; i++) {
             CellLayout cl = (CellLayout) getChildAt(i);
             cl.setIsDragOccuring(isDragHappening);
-            switch (state) {
-                case TOP:
-                    cl.setIsDefaultDropTarget(i == mCurrentPage);
-                case BOTTOM_HIDDEN:
-                case BOTTOM_VISIBLE:
-                case SPRING_LOADED:
-                    if (state != ShrinkState.TOP) {
-                        cl.setIsDefaultDropTarget(false);
-                    }
-                    if (!isDragHappening) {
-                        // even if a drag isn't happening, we don't want to show a screen as
-                        // accepting drops if it doesn't have at least one free cell
-                        spanX = 1;
-                        spanY = 1;
-                    }
-                    // the page accepts drops if we can find at least one empty spot
-                    cl.setAcceptsDrops(cl.findCellForSpan(null, spanX, spanY));
-                    break;
-                default:
-                     throw new RuntimeException("Unhandled ShrinkState " + state);
+            if (state == null) {
+                // If we are not in a shrunken state, mark all cell layouts as droppable (if they
+                // have the space)
+                cl.setAcceptsDrops(cl.findCellForSpan(null, spanX, spanY));
+            } else {
+                switch (state) {
+                    case TOP:
+                        cl.setIsDefaultDropTarget(i == mCurrentPage);
+                    case BOTTOM_HIDDEN:
+                    case BOTTOM_VISIBLE:
+                    case SPRING_LOADED:
+                        if (state != ShrinkState.TOP) {
+                            cl.setIsDefaultDropTarget(false);
+                        }
+                        if (!isDragHappening) {
+                            // even if a drag isn't happening, we don't want to show a screen as
+                            // accepting drops if it doesn't have at least one free cell
+                            spanX = 1;
+                            spanY = 1;
+                        }
+                        // the page accepts drops if we can find at least one empty spot
+                        cl.setAcceptsDrops(cl.findCellForSpan(null, spanX, spanY));
+                        break;
+                    default:
+                         throw new RuntimeException("Unhandled ShrinkState " + state);
+                }
             }
         }
     }