Merge "Updating overscroll assets" into jb-ub-now-indigo-rose
diff --git a/res/drawable-hdpi/active_page.png b/res/drawable-hdpi/active_page.png
deleted file mode 100644
index 58aa7f9..0000000
--- a/res/drawable-hdpi/active_page.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_allapps.png b/res/drawable-hdpi/ic_allapps.png
index 40d5827..f066d16 100644
--- a/res/drawable-hdpi/ic_allapps.png
+++ b/res/drawable-hdpi/ic_allapps.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_allapps_pressed.png b/res/drawable-hdpi/ic_allapps_pressed.png
index 6d87bbb..1675992 100644
--- a/res/drawable-hdpi/ic_allapps_pressed.png
+++ b/res/drawable-hdpi/ic_allapps_pressed.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_pageindicator_add.png b/res/drawable-hdpi/ic_pageindicator_add.png
new file mode 100644
index 0000000..c77a4f9
--- /dev/null
+++ b/res/drawable-hdpi/ic_pageindicator_add.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_pageindicator_current.png b/res/drawable-hdpi/ic_pageindicator_current.png
new file mode 100644
index 0000000..aac8d40
--- /dev/null
+++ b/res/drawable-hdpi/ic_pageindicator_current.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_pageindicator_default.png b/res/drawable-hdpi/ic_pageindicator_default.png
new file mode 100644
index 0000000..bafd94b
--- /dev/null
+++ b/res/drawable-hdpi/ic_pageindicator_default.png
Binary files differ
diff --git a/res/drawable-hdpi/inactive_page.png b/res/drawable-hdpi/inactive_page.png
deleted file mode 100644
index b70d9f4..0000000
--- a/res/drawable-hdpi/inactive_page.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/active_page.png b/res/drawable-mdpi/active_page.png
deleted file mode 100644
index 296a9a6..0000000
--- a/res/drawable-mdpi/active_page.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_allapps.png b/res/drawable-mdpi/ic_allapps.png
index a3cce14..6994b7b 100644
--- a/res/drawable-mdpi/ic_allapps.png
+++ b/res/drawable-mdpi/ic_allapps.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_allapps_pressed.png b/res/drawable-mdpi/ic_allapps_pressed.png
index 5c2076f..96581a5 100644
--- a/res/drawable-mdpi/ic_allapps_pressed.png
+++ b/res/drawable-mdpi/ic_allapps_pressed.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_pageindicator_add.png b/res/drawable-mdpi/ic_pageindicator_add.png
new file mode 100644
index 0000000..22420bd
--- /dev/null
+++ b/res/drawable-mdpi/ic_pageindicator_add.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_pageindicator_current.png b/res/drawable-mdpi/ic_pageindicator_current.png
new file mode 100644
index 0000000..ab5f4c8
--- /dev/null
+++ b/res/drawable-mdpi/ic_pageindicator_current.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_pageindicator_default.png b/res/drawable-mdpi/ic_pageindicator_default.png
new file mode 100644
index 0000000..c919ee8
--- /dev/null
+++ b/res/drawable-mdpi/ic_pageindicator_default.png
Binary files differ
diff --git a/res/drawable-mdpi/inactive_page.png b/res/drawable-mdpi/inactive_page.png
deleted file mode 100644
index 2225d25..0000000
--- a/res/drawable-mdpi/inactive_page.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/active_page.png b/res/drawable-xhdpi/active_page.png
deleted file mode 100644
index a1cfc35..0000000
--- a/res/drawable-xhdpi/active_page.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_allapps.png b/res/drawable-xhdpi/ic_allapps.png
index 961e3f0..549e30f 100644
--- a/res/drawable-xhdpi/ic_allapps.png
+++ b/res/drawable-xhdpi/ic_allapps.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_allapps_pressed.png b/res/drawable-xhdpi/ic_allapps_pressed.png
index 72ff3b9..a703b40 100644
--- a/res/drawable-xhdpi/ic_allapps_pressed.png
+++ b/res/drawable-xhdpi/ic_allapps_pressed.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_pageindicator_add.png b/res/drawable-xhdpi/ic_pageindicator_add.png
new file mode 100644
index 0000000..9647b8f
--- /dev/null
+++ b/res/drawable-xhdpi/ic_pageindicator_add.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_pageindicator_current.png b/res/drawable-xhdpi/ic_pageindicator_current.png
new file mode 100644
index 0000000..aed3d71
--- /dev/null
+++ b/res/drawable-xhdpi/ic_pageindicator_current.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_pageindicator_default.png b/res/drawable-xhdpi/ic_pageindicator_default.png
new file mode 100644
index 0000000..0887416
--- /dev/null
+++ b/res/drawable-xhdpi/ic_pageindicator_default.png
Binary files differ
diff --git a/res/drawable-xhdpi/inactive_page.png b/res/drawable-xhdpi/inactive_page.png
deleted file mode 100644
index 177b253..0000000
--- a/res/drawable-xhdpi/inactive_page.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_allapps.png b/res/drawable-xxhdpi/ic_allapps.png
index 0cd0f14..500f618 100644
--- a/res/drawable-xxhdpi/ic_allapps.png
+++ b/res/drawable-xxhdpi/ic_allapps.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_allapps_pressed.png b/res/drawable-xxhdpi/ic_allapps_pressed.png
index 99494d8..54eb057 100644
--- a/res/drawable-xxhdpi/ic_allapps_pressed.png
+++ b/res/drawable-xxhdpi/ic_allapps_pressed.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_pageindicator_add.png b/res/drawable-xxhdpi/ic_pageindicator_add.png
new file mode 100644
index 0000000..591b189
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_pageindicator_add.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_pageindicator_current.png b/res/drawable-xxhdpi/ic_pageindicator_current.png
new file mode 100644
index 0000000..08615f3
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_pageindicator_current.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_pageindicator_default.png b/res/drawable-xxhdpi/ic_pageindicator_default.png
new file mode 100644
index 0000000..9d4fbf8
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_pageindicator_default.png
Binary files differ
diff --git a/res/layout/custom_content_page_indicator_marker.xml b/res/layout/custom_content_page_indicator_marker.xml
index 1685992..8fe3f8f 100644
--- a/res/layout/custom_content_page_indicator_marker.xml
+++ b/res/layout/custom_content_page_indicator_marker.xml
@@ -16,20 +16,24 @@
 <com.android.launcher3.PageIndicatorMarker
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
+    android:layout_width="16dp"
+    android:layout_height="16dp"
     android:layout_gravity="center_vertical">
     <ImageView
         android:id="@+id/inactive"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="centerInside"
         android:src="@drawable/custom_content_page"
         />
     <ImageView
         android:id="@+id/active"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="centerInside"
         android:src="@drawable/custom_content_page"
         android:alpha="0"
+        android:scaleX="0.5"
+        android:scaleY="0.5"
         />
 </com.android.launcher3.PageIndicatorMarker>
diff --git a/res/layout/page_indicator_marker.xml b/res/layout/page_indicator_marker.xml
index 496f3bd..7c0c389 100644
--- a/res/layout/page_indicator_marker.xml
+++ b/res/layout/page_indicator_marker.xml
@@ -16,20 +16,24 @@
 <com.android.launcher3.PageIndicatorMarker
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
+    android:layout_width="16dp"
+    android:layout_height="16dp"
     android:layout_gravity="center_vertical">
     <ImageView
         android:id="@+id/inactive"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:src="@drawable/inactive_page"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="centerInside"
+        android:src="@drawable/ic_pageindicator_default"
         />
     <ImageView
         android:id="@+id/active"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:src="@drawable/active_page"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="centerInside"
+        android:src="@drawable/ic_pageindicator_current"
         android:alpha="0"
+        android:scaleX="0.5"
+        android:scaleY="0.5"
         />
 </com.android.launcher3.PageIndicatorMarker>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index aad9b9f..9777ea9 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -77,7 +77,6 @@
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.Menu;
-import android.view.MenuItem;
 import android.view.MotionEvent;
 import android.view.Surface;
 import android.view.View;
@@ -132,12 +131,6 @@
     static final boolean DEBUG_STRICT_MODE = false;
     static final boolean DEBUG_RESUME_TIME = false;
 
-    private static final int MENU_GROUP_WALLPAPER = 1;
-    private static final int MENU_WALLPAPER_SETTINGS = Menu.FIRST + 1;
-    private static final int MENU_MANAGE_APPS = MENU_WALLPAPER_SETTINGS + 1;
-    private static final int MENU_SYSTEM_SETTINGS = MENU_MANAGE_APPS + 1;
-    private static final int MENU_HELP = MENU_SYSTEM_SETTINGS + 1;
-
     private static final int REQUEST_CREATE_SHORTCUT = 1;
     private static final int REQUEST_CREATE_APPWIDGET = 5;
     private static final int REQUEST_PICK_APPLICATION = 6;
@@ -482,6 +475,33 @@
         return false;
     }
 
+    /**
+     * To be overridden by subclasses to create the custom content and call
+     * {@link #addToCustomContentPage}. This will only be invoked if
+     * {@link #hasCustomContentToLeft()} is {@code true}.
+     */
+    protected void addCustomContentToLeft() {
+    }
+
+    /**
+     * Invoked by subclasses to signal a change to the {@link #addCustomContentToLeft} value to
+     * ensure the custom content page is added or removed if necessary.
+     */
+    protected void invalidateHasCustomContentToLeft() {
+        if (mWorkspace.getScreenOrder().isEmpty()) {
+            // Not bound yet, wait for bindScreens to be called.
+            return;
+        }
+
+        if (!mWorkspace.hasCustomContent() && hasCustomContentToLeft()) {
+            // Create the custom content page and call the subclass to populate it.
+            mWorkspace.createCustomContentPage();
+            addCustomContentToLeft();
+        } else if (mWorkspace.hasCustomContent() && !hasCustomContentToLeft()) {
+            mWorkspace.removeCustomContentPage();
+        }
+    }
+
     private void updateGlobalIcons() {
         boolean searchVisible = false;
         boolean voiceVisible = false;
@@ -896,6 +916,9 @@
     }
 
     protected void onFinishBindingItems() {
+        if (hasCustomContentToLeft() && mWorkspace.hasCustomContent()) {
+            addCustomContentToLeft();
+        }
     }
 
     QSBScroller mQsbScroller = new QSBScroller() {
@@ -1851,66 +1874,12 @@
     }
 
     @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        if (isWorkspaceLocked()) {
-            return false;
-        }
-
-        super.onCreateOptionsMenu(menu);
-
-        Intent manageApps = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
-        manageApps.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
-                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
-        Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
-        settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
-                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
-        String helpUrl = getString(R.string.help_url);
-        Intent help = new Intent(Intent.ACTION_VIEW, Uri.parse(helpUrl));
-        help.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
-                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
-
-        menu.add(MENU_GROUP_WALLPAPER, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper)
-            .setIcon(android.R.drawable.ic_menu_gallery)
-            .setAlphabeticShortcut('W');
-        menu.add(0, MENU_MANAGE_APPS, 0, R.string.menu_manage_apps)
-            .setIcon(android.R.drawable.ic_menu_manage)
-            .setIntent(manageApps)
-            .setAlphabeticShortcut('M');
-        menu.add(0, MENU_SYSTEM_SETTINGS, 0, R.string.menu_settings)
-            .setIcon(android.R.drawable.ic_menu_preferences)
-            .setIntent(settings)
-            .setAlphabeticShortcut('P');
-        if (!helpUrl.isEmpty()) {
-            menu.add(0, MENU_HELP, 0, R.string.menu_help)
-                .setIcon(android.R.drawable.ic_menu_help)
-                .setIntent(help)
-                .setAlphabeticShortcut('H');
-        }
-        return true;
-    }
-
-    @Override
     public boolean onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
-
-        if (mAppsCustomizeTabHost.isTransitioning()) {
-            return false;
+        if (!mWorkspace.isInOverviewMode()) {
+            mWorkspace.enterOverviewMode();
         }
-        boolean allAppsVisible = (mAppsCustomizeTabHost.getVisibility() == View.VISIBLE);
-        menu.setGroupVisible(MENU_GROUP_WALLPAPER, !allAppsVisible);
-
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-        case MENU_WALLPAPER_SETTINGS:
-            startWallpaper();
-            return true;
-        }
-
-        return super.onOptionsItemSelected(item);
+        return false;
     }
 
     @Override
@@ -3607,7 +3576,8 @@
         }
 
         // Create the custom content page (this call updates mDefaultScreen which calls
-        // setCurrentPage() so ensure that all pages are added before calling this)
+        // setCurrentPage() so ensure that all pages are added before calling this).
+        // The actual content of the custom page will be added during onFinishBindingItems().
         if (!mWorkspace.hasCustomContent() && hasCustomContentToLeft()) {
             mWorkspace.createCustomContentPage();
         }
diff --git a/src/com/android/launcher3/PageIndicatorMarker.java b/src/com/android/launcher3/PageIndicatorMarker.java
index f64c14f..1ad0abb 100644
--- a/src/com/android/launcher3/PageIndicatorMarker.java
+++ b/src/com/android/launcher3/PageIndicatorMarker.java
@@ -57,26 +57,38 @@
         if (immediate) {
             mActiveMarker.animate().cancel();
             mActiveMarker.setAlpha(1f);
+            mActiveMarker.setScaleX(1f);
+            mActiveMarker.setScaleY(1f);
             mInactiveMarker.animate().cancel();
             mInactiveMarker.setAlpha(0f);
         } else {
-            mActiveMarker.animate().alpha(1f)
+            mActiveMarker.animate()
+                    .alpha(1f)
+                    .scaleX(1f)
+                    .scaleY(1f)
                     .setDuration(MARKER_FADE_DURATION).start();
-            mInactiveMarker.animate().alpha(0f)
+            mInactiveMarker.animate()
+                    .alpha(0f)
                     .setDuration(MARKER_FADE_DURATION).start();
         }
         mIsActive = true;
     }
+
     void inactivate(boolean immediate) {
         if (immediate) {
             mInactiveMarker.animate().cancel();
             mInactiveMarker.setAlpha(1f);
             mActiveMarker.animate().cancel();
             mActiveMarker.setAlpha(0f);
+            mActiveMarker.setScaleX(0.5f);
+            mActiveMarker.setScaleY(0.5f);
         } else {
             mInactiveMarker.animate().alpha(1f)
                     .setDuration(MARKER_FADE_DURATION).start();
-            mActiveMarker.animate().alpha(0f)
+            mActiveMarker.animate()
+                    .alpha(0f)
+                    .scaleX(0.5f)
+                    .scaleY(0.5f)
                     .setDuration(MARKER_FADE_DURATION).start();
         }
         mIsActive = false;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 6cb6a57..c0b2ae3 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -52,7 +52,6 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.ViewParent;
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.Interpolator;
 import android.widget.TextView;
@@ -540,6 +539,24 @@
         setCurrentPage(getCurrentPage() + 1);
     }
 
+    public void removeCustomContentPage() {
+        Launcher.addDumpLog(TAG, "10249126 - removeCustomContentPage()", true);
+
+        CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
+        if (customScreen == null) {
+            throw new RuntimeException("Expected custom content screen to exist");
+        }
+
+        mWorkspaceScreens.remove(CUSTOM_CONTENT_SCREEN_ID);
+        mScreenOrder.remove(CUSTOM_CONTENT_SCREEN_ID);
+        removeView(customScreen);
+        mCustomContentCallbacks = null;
+
+        // Ensure that the current page and default page are maintained.
+        mDefaultPage = mOriginalDefaultPage - 1;
+        setCurrentPage(getCurrentPage() - 1);
+    }
+
     public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks) {
         if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
             throw new RuntimeException("Expected custom content screen to exist");
@@ -1326,30 +1343,32 @@
     }
 
     private void updateStateForCustomContent(int screenCenter) {
+        float translationX = 0;
+        float progress = 0;
         if (hasCustomContent()) {
             int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);
             int scrollDelta = getScrollForPage(index + 1) - getScrollX();
-            float translationX = Math.max(scrollDelta, 0);
-            float progress = (1.0f * scrollDelta) /
+            translationX = Math.max(scrollDelta, 0);
+            progress = (1.0f * scrollDelta) /
                     (getScrollForPage(index + 1) - getScrollForPage(index));
             progress = Math.max(0, progress);
+        }
 
-            if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
-            mLastCustomContentScrollProgress = progress;
+        if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
+        mLastCustomContentScrollProgress = progress;
 
-            setBackgroundAlpha(progress * 0.8f);
+        setBackgroundAlpha(progress * 0.8f);
 
-            if (mLauncher.getHotseat() != null) {
-                mLauncher.getHotseat().setTranslationX(translationX);
-            }
+        if (mLauncher.getHotseat() != null) {
+            mLauncher.getHotseat().setTranslationX(translationX);
+        }
 
-            if (getPageIndicator() != null) {
-                getPageIndicator().setTranslationX(translationX);
-            }
+        if (getPageIndicator() != null) {
+            getPageIndicator().setTranslationX(translationX);
+        }
 
-            if (mCustomContentCallbacks != null) {
-                mCustomContentCallbacks.onScrollProgressChanged(progress);
-            }
+        if (mCustomContentCallbacks != null) {
+            mCustomContentCallbacks.onScrollProgressChanged(progress);
         }
     }
 
@@ -3823,7 +3842,7 @@
     @Override
     protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
         // We don't dispatch restoreInstanceState to our children using this code path.
-        // Some pages will be restored immediately as their items are bound immediately, and 
+        // Some pages will be restored immediately as their items are bound immediately, and
         // others we will need to wait until after their items are bound.
         mSavedStates = container;
     }