Merge branch 'eclair' into eclair-release
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index 5ae939e..e51e9b0 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -273,13 +273,13 @@
         }
 
         if (gainFocus) {
-            if (mRollo != null) {
+            if (mRollo != null && mRollo.mHasSurface) {
                 gainFocus();
             } else {
                 mShouldGainFocus = true;
             }
         } else {
-            if (mRollo != null) {
+            if (mRollo != null && mRollo.mHasSurface) {
                 if (mArrowNavigation) {
                     // Clear selection when we lose focus
                     mRollo.clearSelectedIcon();
@@ -370,8 +370,8 @@
                     } else if (currentTopRow > 0) {
                         newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;
                         mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
-                    } else {
-                        newSelection = Defines.COLUMNS_PER_PAGE * (Defines.ROWS_PER_PAGE-1);
+                    } else if (currentPageRow != 0) {
+                        newSelection = currentTopRow * Defines.ROWS_PER_PAGE;
                     }
                 }
                 handled = true;
@@ -660,7 +660,11 @@
     public void setApps(ArrayList<ApplicationInfo> list) {
         mAllAppsList = list;
         if (mRollo != null) {
-            mRollo.setApps(list);
+            if (mRollo.mHasSurface) {
+                mRollo.setApps(list);
+            } else {
+                mRollo.mAppsDirty = true;
+            }
         }
         mLocks &= ~LOCK_ICONS_PENDING;
     }
@@ -672,7 +676,7 @@
         }
 
         final int N = list.size();
-        if (mRollo != null) {
+        if (mRollo != null && mRollo.mHasSurface) {
             mRollo.reallocAppsList(mRollo.mState.iconCount + N);
         }
 
@@ -684,13 +688,13 @@
                 index = -(index+1);
             }
             mAllAppsList.add(index, item);
-            if (mRollo != null) {
+            if (mRollo != null && mRollo.mHasSurface) {
                 mRollo.addApp(index, item);
                 mRollo.mState.iconCount++;
             }
         }
 
-        if (mRollo != null) {
+        if (mRollo != null && mRollo.mHasSurface) {
             mRollo.saveAppsList();
         }
     }
@@ -706,10 +710,10 @@
             final ApplicationInfo item = list.get(i);
             int index = findAppByComponent(mAllAppsList, item);
             if (index >= 0) {
+                int ic = mRollo != null ? mRollo.mState.iconCount : 666;
                 mAllAppsList.remove(index);
-                if (mRollo != null) {
+                if (mRollo != null && mRollo.mHasSurface) {
                     mRollo.removeApp(index);
-                    mRollo.mState.iconCount--;
                 }
             } else {
                 Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
@@ -717,7 +721,7 @@
             }
         }
 
-        if (mRollo != null) {
+        if (mRollo != null && mRollo.mHasSurface) {
             mRollo.saveAppsList();
         }
     }
@@ -1151,7 +1155,7 @@
             int[] labelIds = new int[count];
             mAllocLabelIds = Allocation.createSized(mRS, Element.USER_I32(mRS), count);
 
-            final int oldCount = mIcons.length;
+            final int oldCount = mRollo.mState.iconCount;
 
             System.arraycopy(mIcons, 0, icons, 0, oldCount);
             System.arraycopy(mIconIds, 0, iconIds, 0, oldCount);
@@ -1176,7 +1180,7 @@
             System.arraycopy(mLabels, index, mLabels, dest, count);
             System.arraycopy(mLabelIds, index, mLabelIds, dest, count);
 
-            if (mHasSurface ) {
+            if (mHasSurface) {
                 uploadAppIcon(index, item);
             } else {
                 mAppsDirty = true;
@@ -1195,7 +1199,9 @@
             System.arraycopy(mLabels, src, mLabels, index, count);
             System.arraycopy(mLabelIds, src, mLabelIds, index, count);
 
+            mRollo.mState.iconCount--;
             final int last = mState.iconCount - 1;
+
             mIcons[last] = null;
             mIconIds[last] = 0;
             mLabels[last] = null;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index ac94cca..374f0bf 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -693,7 +693,6 @@
     public boolean onInterceptTouchEvent(MotionEvent ev) {
         final boolean workspaceLocked = mLauncher.isWorkspaceLocked();
         final boolean allAppsVisible = mLauncher.isAllAppsVisible();
-        Log.d(TAG, "workspaceLocked=" + workspaceLocked + " allAppsVisible=" + allAppsVisible);
         if (workspaceLocked || allAppsVisible) {
             return false; // We don't want the events.  Let them fall through to the all apps view.
         }