Move the all apps view back into the window with the workspace.
diff --git a/res/layout-land/all_apps.xml b/res/layout-land/all_apps.xml
deleted file mode 100644
index c538062..0000000
--- a/res/layout-land/all_apps.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 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.
--->
-
-<com.android.launcher2.AllAppsView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2"
-
-    android:id="@+id/all_apps"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-
-    android:scrollbarStyle="outsideInset"
-    android:drawSelectorOnTop="false"
-    android:listSelector="@drawable/grid_selector"
-
-    android:verticalSpacing="10dip"
-    android:numColumns="5" />
-
-<!--
-    android:nextFocusLeft="@id/all_apps"
-    android:nextFocusDown="@id/content"
-    android:nextFocusUp="@id/content"
-    android:nextFocusRight="@id/content"
--->
-
-
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index ef16231..fd27bad 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -37,7 +37,7 @@
     </com.android.launcher2.Workspace>
 
     <com.android.launcher2.HandleView
-        android:id="@id/all_apps"
+        android:id="@+id/all_apps_button"
         android:layout_width="56dip"
         android:layout_height="fill_parent"
 
diff --git a/res/layout-port/all_apps.xml b/res/layout-port/all_apps.xml
deleted file mode 100644
index d1cbeeb..0000000
--- a/res/layout-port/all_apps.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 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.
--->
-
-<com.android.launcher2.DragLayer
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2"
-
-    android:id="@+id/drag_layer"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
-
-    <com.android.launcher2.AllAppsView
-        android:id="@+id/all_apps"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-
-        android:scrollbarStyle="outsideInset"
-        android:drawSelectorOnTop="false"
-        android:listSelector="@drawable/grid_selector"
-
-        android:verticalSpacing="10dip"
-        android:numColumns="4" />
-
-<!--
-    android:nextFocusLeft="@id/content"
-    android:nextFocusDown="@id/content"
-    android:nextFocusUp="@id/all_apps"
-    android:nextFocusRight="@id/content"
--->
-
-</com.android.launcher2.DragLayer>
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 273403e..d57d3a4 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -14,18 +14,27 @@
      limitations under the License.
 -->
 
-<FrameLayout
+<com.android.launcher2.DragLayer
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher2"
 
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
-
-<com.android.launcher2.DragLayer
     android:id="@+id/drag_layer"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
 
+    <com.android.launcher2.AllAppsView
+        android:id="@+id/all_apps_view"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:visibility="gone"
+
+        android:scrollbarStyle="outsideInset"
+        android:drawSelectorOnTop="false"
+        android:listSelector="@drawable/grid_selector"
+
+        android:verticalSpacing="10dip"
+        android:numColumns="4" />
+
     <!-- The workspace contains 3 screens of cells -->
     <com.android.launcher2.Workspace
         android:id="@+id/workspace"
@@ -41,7 +50,7 @@
     </com.android.launcher2.Workspace>
 
     <com.android.launcher2.HandleView
-        android:id="@id/all_apps"
+        android:id="@+id/all_apps_button"
         android:layout_width="fill_parent"
         android:layout_height="56dip"
         android:layout_gravity="bottom"
@@ -71,5 +80,3 @@
         launcher:direction="horizontal" />
 
 </com.android.launcher2.DragLayer>
-
-</FrameLayout>
diff --git a/src/com/android/launcher2/AllAppsGridView.java b/src/com/android/launcher2/AllAppsGridView.java
index 711e213..23d4a7a 100644
--- a/src/com/android/launcher2/AllAppsGridView.java
+++ b/src/com/android/launcher2/AllAppsGridView.java
@@ -66,7 +66,7 @@
         app = new ApplicationInfo(app);
 
         mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
-        mLauncher.showWorkspace();
+        mLauncher.closeAllAppsDialog(true);
         mDraw = false;
         invalidate();
         return true;
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index 8c0b83d..755ba65 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -36,6 +36,7 @@
 
 import android.content.Context;
 import android.content.res.Resources;
+import android.database.DataSetObserver;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
@@ -65,20 +66,28 @@
     private VelocityTracker mVelocity;
     private int mLastScrollX;
     private int mLastMotionX;
+    private ApplicationsAdapter mAdapter;
 
-    public AllAppsView(Context context) {
-        super(context);
+
+    public AllAppsView(Context context, AttributeSet attrs) {
+        super(context, attrs);
         setFocusable(true);
         getHolder().setFormat(PixelFormat.TRANSLUCENT);
         mConfig = ViewConfiguration.get(context);
     }
 
-    public AllAppsView(Context context, AttributeSet attrs) {
-        this(context);
+    public AllAppsView(Context context, AttributeSet attrs, int defStyle) {
+        this(context, attrs);
     }
 
-    public AllAppsView(Context context, AttributeSet attrs, int defStyle) {
-        this(context);
+    void setAdapter(ApplicationsAdapter adapter) {
+        if (mAdapter != null) {
+            mAdapter.unregisterDataSetObserver(mIconObserver);
+        }
+        mAdapter = adapter;
+        if (adapter != null) {
+            adapter.registerDataSetObserver(mIconObserver);
+        }
     }
 
     @Override
@@ -100,6 +109,7 @@
     @Override
     public boolean onTouchEvent(MotionEvent ev)
     {
+        Log.d(Launcher.LOG_TAG, "onTouchEvent " + ev);
         int x = (int)ev.getX();
         int deltaX;
         switch (ev.getAction()) {
@@ -151,6 +161,12 @@
         return true;
     }
 
+    DataSetObserver mIconObserver = new DataSetObserver() {
+        public void onChanged() {
+            Log.d(Launcher.LOG_TAG, "new icons arrived! now have " + mAdapter.getCount());
+        }
+    };
+
     public class RolloRS {
 
         // Allocations ======
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index da2df5c..51cf5e1 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -273,6 +273,8 @@
      * Call this from a drag source view.
      */
     public boolean onInterceptTouchEvent(MotionEvent ev) {
+        Log.d(Launcher.LOG_TAG, "DragController.onInterceptTouchEvent " + ev + " mDragging="
+                + mDragging);
         final int action = ev.getAction();
 
         final float screenX = ev.getRawX();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index b370222..e388ac3 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -55,6 +55,7 @@
 import android.text.TextUtils;
 import android.text.method.TextKeyListener;
 import static android.util.Log.*;
+import android.util.Log;
 import android.view.Display;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -117,9 +118,8 @@
     static final int NUMBER_CELLS_X = 4;
     static final int NUMBER_CELLS_Y = 4;
 
-    static final int DIALOG_ALL_APPS = 1;
-    static final int DIALOG_CREATE_SHORTCUT = 2;
-    static final int DIALOG_RENAME_FOLDER = 3;
+    static final int DIALOG_CREATE_SHORTCUT = 1;
+    static final int DIALOG_RENAME_FOLDER = 2;
 
     private static final String PREFERENCES = "launcher.preferences";
 
@@ -173,9 +173,10 @@
     private final int[] mCellCoordinates = new int[2];
     private FolderInfo mFolderInfo;
 
-    private AllAppsDialog mAllAppsDialog;
+    private DeleteZone mDeleteZone;
     private HandleView mHandleView;
-    private AllAppsView mAllAppsGrid; // TODO: put this into AllAppsDialog
+    private AllAppsView mAllAppsGrid;
+    private boolean mAllAppsVisible;
 
     private boolean mDesktopLocked = true;
     private Bundle mSavedState;
@@ -218,8 +219,7 @@
         setContentView(R.layout.launcher);
         setupViews();
 
-        mAllAppsDialog = new AllAppsDialog(this);
-        mAllAppsDialog.lock();
+        lockAllApps();
 
         registerIntentReceivers();
         registerContentObservers();
@@ -527,12 +527,15 @@
         DragLayer dragLayer = (DragLayer) findViewById(R.id.drag_layer);
         dragLayer.setDragController(dragController);
 
+        mAllAppsGrid = (AllAppsView)dragLayer.findViewById(R.id.all_apps_view);
+
         mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace);
         final Workspace workspace = mWorkspace;
 
-        final DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone);
+        DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone);
+        mDeleteZone = deleteZone;
 
-        mHandleView = (HandleView) findViewById(R.id.all_apps);
+        mHandleView = (HandleView) findViewById(R.id.all_apps_button);
         mHandleView.setLauncher(this);
         mHandleView.setOnClickListener(this);
         TransitionDrawable handleIcon = (TransitionDrawable) mHandleView.getDrawable();
@@ -848,7 +851,7 @@
 
         // When the drawer is opened and we are saving the state because of a
         // configuration change
-        if (mAllAppsDialog.isOpen && isConfigurationChange) {
+        if (mAllAppsVisible && isConfigurationChange) {
             outState.putBoolean(RUNTIME_STATE_ALL_APPS_FOLDER, true);
         }
 
@@ -887,7 +890,7 @@
 
         TextKeyListener.getInstance().release();
 
-        // TODO mAllAppsGrid.setAdapter(null);
+        mAllAppsGrid.setAdapter(null);
         sModel.unbind();
         sModel.abortLoaders();
 
@@ -1299,7 +1302,7 @@
                 case KeyEvent.KEYCODE_BACK:
                     if (!event.isCanceled()) {
                         mWorkspace.dispatchKeyEvent(event);
-                        if (mAllAppsDialog.isOpen) {
+                        if (mAllAppsVisible) {
                             closeAllAppsDialog(true);
                         } else {
                             closeFolder();
@@ -1339,7 +1342,7 @@
      */
     private void onFavoritesChanged() {
         mDesktopLocked = true;
-        mAllAppsDialog.lock();
+        lockAllApps();
         sModel.loadUserItems(false, this, false, false);
     }
 
@@ -1479,18 +1482,18 @@
         }
 
         /* TODO
-        if (mAllAppsDialog.isOpen && !mDrawer.hasFocus()) {
+        if (mAllAppsVisible && !mDrawer.hasFocus()) {
             mDrawer.requestFocus();
         }
         */
 
         mDesktopLocked = false;
-        mAllAppsDialog.unlock();
+        unlockAllApps();
     }
 
     private void bindDrawer(Launcher.DesktopBinder binder,
             ApplicationsAdapter drawerAdapter) {
-        // TODO mAllAppsGrid.setAdapter(drawerAdapter);
+        mAllAppsGrid.setAdapter(drawerAdapter);
         binder.startBindingAppWidgetsWhenIdle();
     }
 
@@ -1541,7 +1544,7 @@
         } else if (tag instanceof FolderInfo) {
             handleFolderClick((FolderInfo) tag);
         } else if (v == mHandleView) {
-            if (mAllAppsDialog.isOpen) {
+            if (mAllAppsVisible) {
                 // TODO how can we be here?
             } else {
                 showAllAppsDialog();
@@ -1666,8 +1669,8 @@
         return mHandleView;
     }
 
-    boolean isDrawerDown() {
-        return /* TODO !mDrawer.isMoving() && */ !mAllAppsDialog.isOpen;
+    boolean isDrawerDown() { // TODO rename to isAllAppsVisible()
+        return /* TODO !mDrawer.isMoving() && */ !mAllAppsVisible;
     }
 
     Workspace getWorkspace() {
@@ -1683,8 +1686,6 @@
     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
-            case DIALOG_ALL_APPS:
-                return mAllAppsDialog;
             case DIALOG_CREATE_SHORTCUT:
                 return new CreateShortcut().createDialog();
             case DIALOG_RENAME_FOLDER:
@@ -1697,9 +1698,6 @@
     @Override
     protected void onPrepareDialog(int id, Dialog dialog) {
         switch (id) {
-            case DIALOG_ALL_APPS:
-                // TODO mAllAppsGrid.onPrepareDialog();
-                break;
             case DIALOG_CREATE_SHORTCUT:
                 break;
             case DIALOG_RENAME_FOLDER:
@@ -1797,7 +1795,7 @@
                 LauncherModel.updateItemInDatabase(Launcher.this, mFolderInfo);
 
                 if (mDesktopLocked) {
-                    mAllAppsDialog.lock();
+                    lockAllApps();
                     sModel.loadUserItems(false, Launcher.this, false, false);
                 } else {
                     final FolderIcon folderIcon = (FolderIcon)
@@ -1807,7 +1805,7 @@
                         getWorkspace().requestLayout();
                     } else {
                         mDesktopLocked = true;
-                        mAllAppsDialog.lock();
+                        lockAllApps();
                         sModel.loadUserItems(false, Launcher.this, false, false);
                     }
                 }
@@ -1823,89 +1821,43 @@
         }
     }
 
-    /**
-     * Holds the 3d all apps view.
-     */
-    private class AllAppsDialog extends Dialog implements DialogInterface.OnCancelListener,
-            DialogInterface.OnDismissListener, DialogInterface.OnShowListener {
-
-        boolean isOpen;
-
-        AllAppsDialog(Context context) {
-            super(context, android.R.style.Theme_Translucent_NoTitleBar);
-
-            setOnCancelListener(this);
-            setOnDismissListener(this);
-            setOnShowListener(this);
-
-            setContentView(R.layout.all_apps);
-            mAllAppsGrid = (AllAppsView) findViewById(R.id.all_apps);
-
-            DragLayer dragLayer = (DragLayer)findViewById(R.id.drag_layer);
-            dragLayer.setDragController(mDragController);
-
-            // TODO grid.setDragController(mDragController);
-            // TODO grid.setLauncher(Launcher.this);
-        }
-
-        public void onCancel(DialogInterface dialog) {
-            onDestroy();
-        }
-
-        public void onDismiss(DialogInterface dialog) {
-            onDestroy();
-        }
-
-        public void onShow(DialogInterface dialog) {
-        }
-        
-        private void onDestroy() {
-        }
-
-        void lock() {
-            // TODO
-        }
-        
-        void unlock() {
-            // TODO
-        }
-
-        @Override
-        public boolean onKeyDown(int keyCode, KeyEvent event) {
-            switch (keyCode) {
-                case KeyEvent.KEYCODE_BACK:
-                    closeAllAppsDialog(true);
-                    return true;
-                default:
-                    return super.onKeyDown(keyCode, event);
-            }
-        }
-    }
-
     void showAllAppsDialog() {
-        mAllAppsDialog.isOpen = true;
-        showDialog(DIALOG_ALL_APPS);
+        mAllAppsVisible = true;
+        mAllAppsGrid.setVisibility(View.VISIBLE);
         mWorkspace.hide();
-    }
-
-    void showWorkspace() {
-        mWorkspace.show();
+        
+        // TODO: fade these two too
+        mDeleteZone.setVisibility(View.GONE);
+        mHandleView.setVisibility(View.GONE);
     }
 
     void closeAllAppsDialog(boolean animated) {
-        if (mAllAppsDialog.isOpen) {
+        if (mAllAppsVisible) {
+            Log.d(LOG_TAG, "closing all apps");
             if (animated) {
                 // TODO mDrawer.animateClose();
-                mAllAppsDialog.dismiss();
+                mAllAppsGrid.setVisibility(View.GONE);
             } else {
-                mAllAppsDialog.dismiss();
+                mAllAppsGrid.setVisibility(View.GONE);
             }
-            mAllAppsDialog.isOpen = false;
+            mAllAppsVisible = false;
             mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
             mWorkspace.show();
+
+            // TODO: fade these two too
+            mDeleteZone.setVisibility(View.VISIBLE);
+            mHandleView.setVisibility(View.VISIBLE);
         }
     }
 
+    void lockAllApps() {
+        // TODO
+    }
+
+    void unlockAllApps() {
+        // TODO
+    }
+
     /**
      * Displays the shortcut creation dialog and launches, if necessary, the
      * appropriate activity.
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index c960412..759deb6 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -26,6 +26,7 @@
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.MotionEvent;
 import android.view.VelocityTracker;
 import android.view.View;
@@ -641,8 +642,11 @@
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
+        Log.d(Launcher.LOG_TAG, "Workspace onIntercept " + ev + " mLocked=" + mLocked
+                + " mLauncher.isDrawerDown()=" + mLauncher.isDrawerDown());
         if (mLocked || !mLauncher.isDrawerDown()) {
-            return true;
+            Log.d(Launcher.LOG_TAG, "returning false");
+            return false; // We don't want the events.  Let them fall through to the all apps view.
         }
 
         /*
@@ -751,8 +755,10 @@
     @Override
     public boolean onTouchEvent(MotionEvent ev) {
 
+        Log.d(Launcher.LOG_TAG, "Workspace onTouchEvent " + ev);
+
         if (mLocked || !mLauncher.isDrawerDown()) {
-            return true;
+            return false; // We don't want the events.  Let them fall through to the all apps view.
         }
 
         if (mVelocityTracker == null) {
@@ -1357,6 +1363,7 @@
 
     void show() {
         mTween.start(true);
+        setVisibility(VISIBLE);
     }
 
     void hide() {
@@ -1378,5 +1385,8 @@
         // TODO: This conflicts with the cache for drawing.  Ref count instead?
         // TODO: Don't cache all three.
         clearChildrenCache();
+        if (mAlpha == 0) {
+            setVisibility(GONE);
+        }
     }
 }