Resetting AllApps to first page when turning screen off/hitting home.

Change-Id: If988bbcf48c54aad3603425bb290fde011e9bd75
diff --git a/src/com/android/launcher2/AllApps2D.java b/src/com/android/launcher2/AllApps2D.java
index 329109f..854c1ee 100644
--- a/src/com/android/launcher2/AllApps2D.java
+++ b/src/com/android/launcher2/AllApps2D.java
@@ -341,6 +341,10 @@
     
     public void surrender() {
     }
+
+    public void reset() {
+        // Do nothing
+    }
 }
 
 
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index d42481b..a8aea18 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -1470,4 +1470,8 @@
             sRS.contextDump();
         }
     }
+
+    public void reset() {
+        // Do nothing
+    }
 }
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 87d255e..3924c57 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -450,6 +450,11 @@
         // do nothing?
     }
 
+    public void reset() {
+        setCurrentPage(0);
+        invalidatePageData();
+    }
+
     private void setupPage(PagedViewCellLayout layout) {
         layout.setCellCount(mCellCountX, mCellCountY);
         layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight,
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index ee7bfc0..059d0ae 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -248,6 +248,10 @@
         mAllApps.surrender();
     }
 
+    public void reset() {
+        mAllApps.reset();
+    }
+
     @Override
     public boolean onTouchEvent(MotionEvent ev) {
         if (ev.getY() > mAllApps.getBottom()) {
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
index 007ecf8..3a74c71 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/android/launcher2/AllAppsView.java
@@ -41,6 +41,9 @@
 
     public void updateApps(ArrayList<ApplicationInfo> list);
     
+    // Resets the AllApps page to the front
+    public void reset();
+
     public void dumpState();
 
     public void surrender();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index fc17643..a68bd9b 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1253,6 +1253,11 @@
             if (Intent.ACTION_SCREEN_OFF.equals(action)) {
                 mUserPresent = false;
                 updateRunning();
+
+                // Reset AllApps to it's initial state
+                if (mAllAppsGrid != null) {
+                    mAllAppsGrid.reset();
+                }
             } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
                 mUserPresent = true;
                 updateRunning();
@@ -1424,6 +1429,11 @@
                         INPUT_METHOD_SERVICE);
                 imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
             }
+
+            // Reset AllApps to it's initial state
+            if (mAllAppsGrid != null) {
+                mAllAppsGrid.reset();
+            }
         }
     }