Merge "Hide hotseat in landscape overview" into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
index 1064492..a4851ba 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
@@ -17,6 +17,7 @@
 
 import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
 import static com.android.launcher3.allapps.DiscoveryBounce.APPS_VIEW_SHOWN;
+import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
 
 import android.view.View;
 
@@ -33,6 +34,13 @@
 
     private static final int STATE_FLAGS = FLAG_DISABLE_ACCESSIBILITY;
 
+    private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) {
+        @Override
+        public float getPageAlpha(int pageIndex) {
+            return 0;
+        }
+    };
+
     public AllAppsState(int id) {
         super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, 0f, STATE_FLAGS);
     }
@@ -65,6 +73,6 @@
 
     @Override
     public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
-        return (i) -> 0;
+        return PAGE_ALPHA_PROVIDER;
     }
 }
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeUpController.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeUpController.java
new file mode 100644
index 0000000..92f89f6
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeUpController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+package com.android.launcher3.uioverrides;
+
+import static com.android.launcher3.LauncherState.OVERVIEW;
+
+import android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.touch.SwipeDetector;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.util.VerticalSwipeController;
+
+/**
+ * Extension of {@link VerticalSwipeController} which allows swipe up from OVERVIEW to ALL_APPS
+ * Note that the swipe down is handled by {@link TwoStepSwipeController}.
+ */
+public class OverviewSwipeUpController extends VerticalSwipeController {
+
+    public OverviewSwipeUpController(Launcher l) {
+        super(l, OVERVIEW);
+    }
+
+    @Override
+    protected boolean shouldInterceptTouch(MotionEvent ev) {
+        return mLauncher.isInState(OVERVIEW) && mLauncher.getDragLayer().isEventOverHotseat(ev);
+    }
+
+    @Override
+    protected int getSwipeDirection(MotionEvent ev) {
+        return SwipeDetector.DIRECTION_POSITIVE;
+    }
+
+    @Override
+    protected void onTransitionComplete(boolean wasFling, boolean stateChanged) {
+        if (stateChanged) {
+            // Transition complete. log the action
+            mLauncher.getUserEventDispatcher().logActionOnContainer(
+                    wasFling ? Touch.FLING : Touch.SWIPE,
+                    Direction.UP,
+                    ContainerType.OVERVIEW,
+                    mLauncher.getWorkspace().getCurrentPage());
+        }
+
+    }
+}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 5e280b6..9178d8a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -30,7 +30,15 @@
 public class UiFactory {
 
     public static TouchController[] createTouchControllers(Launcher launcher) {
-        return new TouchController[] {new TwoStepSwipeController(launcher)};
+
+        if (launcher.getDeviceProfile().isVerticalBarLayout()) {
+            // TODO: Allow swipe up from overview in transposed layout
+            return new TouchController[] {new TwoStepSwipeController(launcher)};
+        } else {
+            return new TouchController[] {
+                    new TwoStepSwipeController(launcher),
+                    new OverviewSwipeUpController(launcher)};
+        }
     }
 
     public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
diff --git a/res/drawable/all_apps_handle_landscape.xml b/res/drawable/all_apps_handle_landscape.xml
index 23826ab..15518ff 100644
--- a/res/drawable/all_apps_handle_landscape.xml
+++ b/res/drawable/all_apps_handle_landscape.xml
@@ -15,23 +15,26 @@
 -->
 
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="13dp"
-    android:height="13dp"
-    android:viewportWidth="13.0"
-    android:viewportHeight="13.0" >
+    android:width="@dimen/dynamic_grid_min_page_indicator_size"
+    android:height="@dimen/dynamic_grid_min_page_indicator_size"
+    android:viewportWidth="48.0"
+    android:viewportHeight="48.0" >
 
-    <path
-        android:pathData="M2 8.5L6.5 4L11 8.5"
-        android:strokeColor="?attr/workspaceAmbientShadowColor"
-        android:strokeWidth="4"
-        android:strokeLineCap="round"
-        android:strokeLineJoin="round" />
+    <group
+        android:translateX="17.5"
+        android:translateY="17.5">
+        <path
+            android:pathData="M2 8.5L6.5 4L11 8.5"
+            android:strokeColor="?attr/workspaceAmbientShadowColor"
+            android:strokeWidth="4"
+            android:strokeLineCap="round"
+            android:strokeLineJoin="round" />
 
-    <path
-        android:pathData="M2 8.5L6.5 4L11 8.5"
-        android:strokeColor="?attr/workspaceTextColor"
-        android:strokeWidth="2"
-        android:strokeLineCap="round"
-        android:strokeLineJoin="round" />
-
+        <path
+            android:pathData="M2 8.5L6.5 4L11 8.5"
+            android:strokeColor="?attr/workspaceTextColor"
+            android:strokeWidth="2"
+            android:strokeLineCap="round"
+            android:strokeLineJoin="round" />
+        </group>
 </vector>
diff --git a/res/drawable/all_apps_handle_portrait.xml b/res/drawable/all_apps_handle_portrait.xml
deleted file mode 100644
index 75aa448..0000000
--- a/res/drawable/all_apps_handle_portrait.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="16dp"
-    android:height="13dp"
-    android:viewportWidth="16.0"
-    android:viewportHeight="13.0" >
-
-    <path
-        android:pathData="M2 6h12"
-        android:strokeColor="?attr/workspaceAmbientShadowColor"
-        android:strokeWidth="4"
-        android:strokeLineCap="round" />
-
-    <path
-        android:pathData="M2 6h12"
-        android:strokeColor="?attr/workspaceTextColor"
-        android:strokeWidth="2"
-        android:strokeLineCap="round" />
-</vector>
\ No newline at end of file
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 4ea32b4..d21e45d 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -47,13 +47,8 @@
             android:theme="@style/HomeScreenElementTheme"
             android:layout_width="@dimen/dynamic_grid_min_page_indicator_size"
             android:layout_height="@dimen/dynamic_grid_min_page_indicator_size"
-            android:layout_gravity="bottom|left">
-            <ImageView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/all_apps_handle_landscape"
-                android:layout_gravity="center" />
-        </com.android.launcher3.pageindicators.PageIndicatorLandscape>
+            android:layout_gravity="bottom|left"
+            android:background="@drawable/all_apps_handle_landscape" />
 
         <include layout="@layout/gradient_bg" />
 
diff --git a/res/layout/page_indicator.xml b/res/layout/page_indicator.xml
index 2df511b..7de0cde 100644
--- a/res/layout/page_indicator.xml
+++ b/res/layout/page_indicator.xml
@@ -18,12 +18,4 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:theme="@style/HomeScreenElementTheme"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/dynamic_grid_min_page_indicator_size">
-        <ImageView
-            android:id="@+id/all_apps_handle"
-            android:layout_width="48dp"
-            android:layout_height="@dimen/dynamic_grid_min_page_indicator_size"
-            android:src="@drawable/all_apps_handle_portrait"
-            android:layout_gravity="top|center"
-            android:scaleType="centerInside"/>
-</com.android.launcher3.pageindicators.PageIndicatorLine>
+    android:layout_height="@dimen/dynamic_grid_min_page_indicator_size" />
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index b211207..1497b5a 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -15,6 +15,9 @@
 -->
 
 <resources>
+    <!-- Dynamic Grid -->
+    <dimen name="dynamic_grid_min_page_indicator_size">24dp</dimen>
+
     <!-- All Apps -->
     <dimen name="all_apps_button_scale_down">8dp</dimen>
     <dimen name="all_apps_empty_search_message_top_offset">64dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e22c7c2..93c5114 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -20,7 +20,7 @@
 
     <!-- Dynamic Grid -->
     <dimen name="dynamic_grid_edge_margin">8dp</dimen>
-    <dimen name="dynamic_grid_min_page_indicator_size">32dp</dimen>
+    <dimen name="dynamic_grid_min_page_indicator_size">24dp</dimen>
     <dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
     <dimen name="dynamic_grid_page_indicator_land_left_nav_bar_gutter_width">0dp</dimen>
     <dimen name="dynamic_grid_page_indicator_land_right_nav_bar_gutter_width">0dp</dimen>
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 09f9e82..20a6be2 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -16,6 +16,9 @@
 
 package com.android.launcher3;
 
+import static com.android.launcher3.LauncherState.ALL_APPS;
+import static com.android.launcher3.LauncherState.NORMAL;
+
 import android.content.Context;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
@@ -29,7 +32,9 @@
 
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.logging.UserEventDispatcher;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
 
 public class Hotseat extends FrameLayout
@@ -127,8 +132,13 @@
             allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
             allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
             if (mLauncher != null) {
-                mLauncher.setAllAppsButton(allAppsButton);
-                allAppsButton.setOnClickListener(mLauncher);
+                allAppsButton.setOnClickListener((v) -> {
+                    if (!mLauncher.isInState(ALL_APPS)) {
+                        mLauncher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+                                ControlType.ALL_APPS_BUTTON);
+                        mLauncher.getStateManager().goToState(ALL_APPS);
+                    }
+                });
                 allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
             }
 
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 0c573ac..44660ec 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -111,7 +111,6 @@
 import com.android.launcher3.logging.UserEventDispatcher;
 import com.android.launcher3.model.ModelWriter;
 import com.android.launcher3.notification.NotificationListener;
-import com.android.launcher3.pageindicators.PageIndicator;
 import com.android.launcher3.popup.PopupContainerWithArrow;
 import com.android.launcher3.popup.PopupDataProvider;
 import com.android.launcher3.shortcuts.DeepShortcutManager;
@@ -120,7 +119,6 @@
 import com.android.launcher3.userevent.nano.LauncherLogProto;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
-import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
 import com.android.launcher3.util.ActivityResultInfo;
 import com.android.launcher3.util.ComponentKey;
@@ -223,8 +221,6 @@
 
     @Thunk Hotseat mHotseat;
 
-    private View mAllAppsButton;
-
     private DropTargetBar mDropTargetBar;
 
     // Main container view for the all apps screen.
@@ -991,14 +987,6 @@
     }
 
     /**
-     * Sets the all apps button. This method is called from {@link Hotseat}.
-     * TODO: Get rid of this.
-     */
-    public void setAllAppsButton(View allAppsButton) {
-        mAllAppsButton = allAppsButton;
-    }
-
-    /**
      * Creates a view representing a shortcut.
      *
      * @param info The data structure describing the shortcut.
@@ -1707,9 +1695,6 @@
             if (v instanceof FolderIcon) {
                 onClickFolderIcon(v);
             }
-        } else if ((v instanceof PageIndicator) ||
-            (v == mAllAppsButton && mAllAppsButton != null)) {
-            onClickAllAppsButton(v);
         } else if (tag instanceof AppInfo) {
             startAppShortcutOrInfoActivity(v);
         } else if (tag instanceof LauncherAppWidgetInfo) {
@@ -1758,24 +1743,6 @@
         }
     }
 
-    /**
-     * Event handler for the "grid" button or "caret" that appears on the home screen, which
-     * enters all apps mode. In verticalBarLayout the caret can be seen when all apps is open, and
-     * so in that case reverses the action.
-     *
-     * @param v The view that was clicked.
-     */
-    protected void onClickAllAppsButton(View v) {
-        if (LOGD) Log.d(TAG, "onClickAllAppsButton");
-        if (!isInState(ALL_APPS)) {
-            getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
-                    ControlType.ALL_APPS_BUTTON);
-            mStateManager.goToState(ALL_APPS);
-        } else {
-            mStateManager.goToState(NORMAL);
-        }
-    }
-
     private void onClickPendingAppItem(final View v, final String packageName,
             boolean downloadStarted) {
         if (downloadStarted) {
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 01ab563..2beaca1 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -19,7 +19,10 @@
 import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
 import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
 
+import static com.android.launcher3.anim.Interpolators.ACCEL_2;
+
 import android.view.View;
+import android.view.animation.Interpolator;
 
 import com.android.launcher3.uioverrides.AllAppsState;
 import com.android.launcher3.states.SpringLoadedState;
@@ -41,7 +44,13 @@
     protected static final int FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED = 1 << 4;
     protected static final int FLAG_DISABLE_PAGE_CLIPPING = 1 << 5;
 
-    protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER = (i) -> 1f;
+    protected static final PageAlphaProvider DEFAULT_ALPHA_PROVIDER =
+            new PageAlphaProvider(ACCEL_2) {
+                @Override
+                public float getPageAlpha(int pageIndex) {
+                    return 1;
+                }
+            };
 
     private static final LauncherState[] sAllStates = new LauncherState[4];
 
@@ -153,16 +162,27 @@
         if (this != NORMAL || !launcher.getDeviceProfile().shouldFadeAdjacentWorkspaceScreens()) {
             return DEFAULT_ALPHA_PROVIDER;
         }
-        int centerPage = launcher.getWorkspace().getPageNearestToCenterOfScreen();
-        return (childIndex) ->  childIndex != centerPage ? 0 : 1f;
+        final int centerPage = launcher.getWorkspace().getPageNearestToCenterOfScreen();
+        return new PageAlphaProvider(ACCEL_2) {
+            @Override
+            public float getPageAlpha(int pageIndex) {
+                return  pageIndex != centerPage ? 0 : 1f;
+            }
+        };
     }
 
     protected static void dispatchWindowStateChanged(Launcher launcher) {
         launcher.getWindow().getDecorView().sendAccessibilityEvent(TYPE_WINDOW_STATE_CHANGED);
     }
 
-    public interface PageAlphaProvider {
+    public static abstract class PageAlphaProvider {
 
-        float getPageAlpha(int pageIndex);
+        public final Interpolator interpolator;
+
+        public PageAlphaProvider(Interpolator interpolator) {
+            this.interpolator = interpolator;
+        }
+
+        public abstract float getPageAlpha(int pageIndex);
     }
 }
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 2392c9b..8a20bb9 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -159,7 +159,7 @@
         propertySetter.setInt(cl.getScrimBackground(),
                 DRAWABLE_ALPHA, state.hasScrim ? 255 : 0, Interpolators.ZOOM_IN);
         propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA,
-                pageAlphaProvider.getPageAlpha(childIndex), Interpolators.DEACCEL_2);
+                pageAlphaProvider.getPageAlpha(childIndex), pageAlphaProvider.interpolator);
     }
 
     public static class PropertySetter {
diff --git a/src/com/android/launcher3/pageindicators/PageIndicator.java b/src/com/android/launcher3/pageindicators/PageIndicator.java
index be6bcc5..5e3d216 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicator.java
@@ -17,18 +17,17 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
-import android.widget.FrameLayout;
+import android.view.View;
 
 /**
  * Base class for a page indicator.
  */
-public abstract class PageIndicator extends FrameLayout {
+public abstract class PageIndicator extends View {
 
     protected int mNumPages = 1;
 
     public PageIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
-        setWillNotDraw(false);
     }
 
     public void setScroll(int currentScroll, int totalScroll) {}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java b/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java
index 7325235..2d5a4a9 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLandscape.java
@@ -15,17 +15,23 @@
  */
 package com.android.launcher3.pageindicators;
 
+import static com.android.launcher3.LauncherState.ALL_APPS;
+
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.View;
+import android.view.View.OnClickListener;
 
 import com.android.launcher3.Launcher;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 
 /**
  * Simply draws the caret drawable bottom-right aligned in the view. This ensures that we can have
  * a view with as large an area as we want (for touching) while maintaining a caret of size
  * all_apps_caret_size.  Used only for the landscape layout.
  */
-public class PageIndicatorLandscape extends PageIndicator {
+public class PageIndicatorLandscape extends PageIndicator implements OnClickListener {
     // all apps pull up handle drawable.
 
     public PageIndicatorLandscape(Context context) {
@@ -38,8 +44,17 @@
 
     public PageIndicatorLandscape(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
-        Launcher l = Launcher.getLauncher(context);
-        setOnClickListener(l);
-        setOnFocusChangeListener(l.mFocusHandler);
+        setOnClickListener(this);
+        setOnFocusChangeListener(Launcher.getLauncher(context).mFocusHandler);
+    }
+
+    @Override
+    public void onClick(View view) {
+        Launcher l = Launcher.getLauncher(getContext());
+        if (!l.isInState(ALL_APPS)) {
+            l.getUserEventDispatcher().logActionOnControl(
+                    Action.Touch.TAP, ControlType.ALL_APPS_BUTTON);
+            l.getStateManager().goToState(ALL_APPS);
+        }
     }
 }
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLine.java b/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
index 09a06b0..6c4b898 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLine.java
@@ -14,7 +14,6 @@
 import android.util.AttributeSet;
 import android.util.Property;
 import android.view.ViewConfiguration;
-import android.widget.ImageView;
 
 import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
@@ -54,7 +53,6 @@
     private Paint mLinePaint;
     private Launcher mLauncher;
     private final int mLineHeight;
-    private ImageView mAllAppsHandle;
 
     private static final Property<PageIndicatorLine, Integer> PAINT_ALPHA
             = new Property<PageIndicatorLine, Integer>(Integer.class, "paint_alpha") {
@@ -98,12 +96,7 @@
         }
     };
 
-    private Runnable mHideLineRunnable = new Runnable() {
-        @Override
-        public void run() {
-            animateLineToAlpha(0);
-        }
-    };
+    private Runnable mHideLineRunnable = () -> animateLineToAlpha(0);
 
     public PageIndicatorLine(Context context) {
         this(context, null);
@@ -129,20 +122,6 @@
     }
 
     @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-        mAllAppsHandle = findViewById(R.id.all_apps_handle);
-        mAllAppsHandle.setOnClickListener(mLauncher);
-        mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
-        mLauncher.setAllAppsButton(mAllAppsHandle);
-    }
-
-    @Override
-    public void setAccessibilityDelegate(AccessibilityDelegate delegate) {
-        mAllAppsHandle.setAccessibilityDelegate(delegate);
-    }
-
-    @Override
     protected void onDraw(Canvas canvas) {
         if (mTotalScroll == 0 || mNumPagesFloat == 0) {
             return;
@@ -159,11 +138,6 @@
     }
 
     @Override
-    public void setContentDescription(CharSequence contentDescription) {
-        mAllAppsHandle.setContentDescription(contentDescription);
-    }
-
-    @Override
     public void setScroll(int currentScroll, int totalScroll) {
         if (getAlpha() == 0) {
             return;
diff --git a/src/com/android/launcher3/VerticalSwipeController.java b/src/com/android/launcher3/util/VerticalSwipeController.java
similarity index 76%
rename from src/com/android/launcher3/VerticalSwipeController.java
rename to src/com/android/launcher3/util/VerticalSwipeController.java
index b3dc176..7b1632c 100644
--- a/src/com/android/launcher3/VerticalSwipeController.java
+++ b/src/com/android/launcher3/util/VerticalSwipeController.java
@@ -14,10 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.launcher3;
+package com.android.launcher3.util;
 
 import static com.android.launcher3.LauncherState.ALL_APPS;
-import static com.android.launcher3.LauncherState.NORMAL;
 import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
 import static com.android.launcher3.anim.SpringAnimationHandler.Y_DIRECTION;
 
@@ -28,21 +27,22 @@
 import android.util.Log;
 import android.view.MotionEvent;
 
+import com.android.launcher3.AbstractFloatingView;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.Utilities;
 import com.android.launcher3.allapps.AllAppsContainerView;
 import com.android.launcher3.anim.AnimatorPlaybackController;
 import com.android.launcher3.anim.SpringAnimationHandler;
 import com.android.launcher3.touch.SwipeDetector;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
-import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
-import com.android.launcher3.util.TouchController;
 
 import java.util.ArrayList;
 
 /**
- * Handles vertical touch gesture on the DragLayer
+ * Handles vertical touch gesture on the DragLayer allowing transitioning from
+ * {@link #mBaseState} to {@link LauncherState#ALL_APPS} and vice-versa.
  */
-public class VerticalSwipeController extends AnimatorListenerAdapter
+public abstract class VerticalSwipeController extends AnimatorListenerAdapter
         implements TouchController, SwipeDetector.Listener {
 
     private static final String TAG = "VerticalSwipeController";
@@ -53,11 +53,11 @@
     // Progress after which the transition is assumed to be a success in case user does not fling
     private static final float SUCCESS_TRANSITION_PROGRESS = 0.5f;
 
-    private final Launcher mLauncher;
+    protected final Launcher mLauncher;
     private final SwipeDetector mDetector;
+    private final LauncherState mBaseState;
 
     private boolean mNoIntercept;
-    private int mStartContainerType;
 
     private AnimatorPlaybackController mCurrentAnimation;
     private LauncherState mToState;
@@ -68,30 +68,25 @@
 
     private SpringAnimationHandler[] mSpringHandlers;
 
-    public VerticalSwipeController(Launcher l) {
+    public VerticalSwipeController(Launcher l, LauncherState baseState) {
         mLauncher = l;
         mDetector = new SwipeDetector(l, this, SwipeDetector.VERTICAL);
+        mBaseState = baseState;
     }
 
     private boolean canInterceptTouch(MotionEvent ev) {
-        if (!mLauncher.isInState(NORMAL) && !mLauncher.isInState(ALL_APPS)) {
-            // Don't listen for the swipe gesture if we are already in some other state.
-            return false;
-        }
         if (mCurrentAnimation != null) {
             // If we are already animating from a previous state, we can intercept.
             return true;
         }
-        if (mLauncher.isInState(ALL_APPS) && !mLauncher.getAppsView().shouldContainerScroll(ev)) {
-            return false;
-        }
         if (AbstractFloatingView.getTopOpenView(mLauncher) != null) {
             return false;
         }
-
-        return true;
+        return shouldInterceptTouch(ev);
     }
 
+    protected abstract boolean shouldInterceptTouch(MotionEvent ev);
+
     @Override
     public void onAnimationCancel(Animator animation) {
         if (mCurrentAnimation != null && animation == mCurrentAnimation.getTarget()) {
@@ -147,14 +142,7 @@
                     ignoreSlopWhenSettling = true;
                 }
             } else {
-                if (mLauncher.isInState(ALL_APPS)) {
-                    directionsToDetectScroll = SwipeDetector.DIRECTION_NEGATIVE;
-                    mStartContainerType = ContainerType.ALLAPPS;
-                } else {
-                    directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE;
-                    mStartContainerType = mLauncher.getDragLayer().isEventOverHotseat(ev) ?
-                            ContainerType.HOTSEAT : ContainerType.WORKSPACE;
-                }
+                directionsToDetectScroll = getSwipeDirection(ev);
             }
 
             mDetector.setDetectableScrollConditions(
@@ -173,6 +161,8 @@
         return mDetector.isDraggingOrSettling();
     }
 
+    protected abstract int getSwipeDirection(MotionEvent ev);
+
     @Override
     public boolean onControllerTouchEvent(MotionEvent ev) {
         for (SpringAnimationHandler h : mSpringHandlers) {
@@ -188,7 +178,7 @@
             long maxAccuracy = (long) (2 * range);
 
             // Build current animation
-            mToState = mLauncher.isInState(ALL_APPS) ? NORMAL : ALL_APPS;
+            mToState = mLauncher.isInState(ALL_APPS) ? mBaseState : ALL_APPS;
             mCurrentAnimation = mLauncher.getStateManager()
                     .createAnimationToNewWorkspace(mToState, maxAccuracy);
             mCurrentAnimation.getTarget().addListener(this);
@@ -206,7 +196,7 @@
     }
 
     private float getShiftRange() {
-        return mLauncher.mAllAppsController.getShiftRange();
+        return mLauncher.getAllAppsController().getShiftRange();
     }
 
     @Override
@@ -219,29 +209,26 @@
     @Override
     public void onDragEnd(float velocity, boolean fling) {
         final long animationDuration;
-        final int logAction;
         final LauncherState targetState;
         final float progress = mCurrentAnimation.getProgressFraction();
 
         if (fling) {
-            logAction = Touch.FLING;
             if (velocity < 0) {
                 targetState = ALL_APPS;
                 animationDuration = SwipeDetector.calculateDuration(velocity,
                         mToState == ALL_APPS ? (1 - progress) : progress);
             } else {
-                targetState = NORMAL;
+                targetState = mBaseState;
                 animationDuration = SwipeDetector.calculateDuration(velocity,
                         mToState == ALL_APPS ? progress : (1 - progress));
             }
             // snap to top or bottom using the release velocity
         } else {
-            logAction = Touch.SWIPE;
             if (progress > SUCCESS_TRANSITION_PROGRESS) {
                 targetState = mToState;
                 animationDuration = SwipeDetector.calculateDuration(velocity, 1 - progress);
             } else {
-                targetState = mToState == ALL_APPS ? NORMAL : ALL_APPS;
+                targetState = mToState == ALL_APPS ? mBaseState : ALL_APPS;
                 animationDuration = SwipeDetector.calculateDuration(velocity, progress);
             }
         }
@@ -253,21 +240,11 @@
             }
         }
 
-        mCurrentAnimation.setEndAction(new Runnable() {
-            @Override
-            public void run() {
-                if (targetState == mToState) {
-                    // Transition complete. log the action
-                    mLauncher.getUserEventDispatcher().logActionOnContainer(logAction,
-                            mToState == ALL_APPS ? Direction.UP : Direction.DOWN,
-                            mStartContainerType, mLauncher.getWorkspace().getCurrentPage());
-                } else {
-                    mLauncher.getStateManager().goToState(
-                            mToState == ALL_APPS ? NORMAL : ALL_APPS, false);
-                }
-                mDetector.finishedScrolling();
-                mCurrentAnimation = null;
-            }
+        mCurrentAnimation.setEndAction(() -> {
+            mLauncher.getStateManager().goToState(targetState, false);
+            onTransitionComplete(fling, targetState == mToState);
+            mDetector.finishedScrolling();
+            mCurrentAnimation = null;
         });
 
         float nextFrameProgress = Utilities.boundToRange(
@@ -279,4 +256,6 @@
         anim.setInterpolator(scrollInterpolatorForVelocity(velocity));
         anim.start();
     }
+
+    protected abstract void onTransitionComplete(boolean wasFling, boolean stateChanged);
 }
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
index bd5ddfe..d67156f 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
@@ -17,6 +17,7 @@
 
 import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
 import static com.android.launcher3.allapps.DiscoveryBounce.APPS_VIEW_SHOWN;
+import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
 
 import android.view.View;
 
@@ -34,6 +35,13 @@
 
     private static final int STATE_FLAGS = FLAG_DISABLE_ACCESSIBILITY;
 
+    private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) {
+        @Override
+        public float getPageAlpha(int pageIndex) {
+            return 0;
+        }
+    };
+
     public AllAppsState(int id) {
         super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, 0f, STATE_FLAGS);
     }
@@ -67,6 +75,6 @@
 
     @Override
     public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
-        return (i) -> 0;
+        return PAGE_ALPHA_PROVIDER;
     }
 }
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java
new file mode 100644
index 0000000..76b7e0d
--- /dev/null
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package com.android.launcher3.uioverrides;
+
+import static com.android.launcher3.LauncherState.ALL_APPS;
+import static com.android.launcher3.LauncherState.NORMAL;
+
+import android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.touch.SwipeDetector;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
+import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.util.VerticalSwipeController;
+
+/**
+ * Extension of {@link VerticalSwipeController} to switch between NORMAL and ALL_APPS state.
+ */
+public class AllAppsSwipeController extends VerticalSwipeController {
+
+    private int mStartContainerType;
+
+    public AllAppsSwipeController(Launcher l) {
+        super(l, NORMAL);
+    }
+
+    @Override
+    protected boolean shouldInterceptTouch(MotionEvent ev) {
+        if (!mLauncher.isInState(NORMAL) && !mLauncher.isInState(ALL_APPS)) {
+            // Don't listen for the swipe gesture if we are already in some other state.
+            return false;
+        }
+
+        if (mLauncher.isInState(ALL_APPS) && !mLauncher.getAppsView().shouldContainerScroll(ev)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    protected int getSwipeDirection(MotionEvent ev) {
+        if (mLauncher.isInState(ALL_APPS)) {
+            mStartContainerType = ContainerType.ALLAPPS;
+            return SwipeDetector.DIRECTION_NEGATIVE;
+        } else {
+            mStartContainerType = mLauncher.getDragLayer().isEventOverHotseat(ev) ?
+                    ContainerType.HOTSEAT : ContainerType.WORKSPACE;
+            return SwipeDetector.DIRECTION_POSITIVE;
+        }
+    }
+
+    @Override
+    protected void onTransitionComplete(boolean wasFling, boolean stateChanged) {
+        if (stateChanged) {
+            // Transition complete. log the action
+            mLauncher.getUserEventDispatcher().logActionOnContainer(
+                    wasFling ? Touch.FLING : Touch.SWIPE,
+                    mLauncher.isInState(ALL_APPS) ? Direction.UP : Direction.DOWN,
+                    mStartContainerType,
+                    mLauncher.getWorkspace().getCurrentPage());
+        }
+    }
+}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 51cf661..2e29015 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -22,14 +22,13 @@
 
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherStateManager.StateHandler;
-import com.android.launcher3.VerticalSwipeController;
 import com.android.launcher3.util.TouchController;
 
 public class UiFactory {
 
     public static TouchController[] createTouchControllers(Launcher launcher) {
         return new TouchController[] {
-                new VerticalSwipeController(launcher), new PinchToOverviewListener(launcher)};
+                new AllAppsSwipeController(launcher), new PinchToOverviewListener(launcher)};
     }
 
     public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {