Merge "Fixing wrong xml refenrece when the packageName is changed" into ub-launcher3-master
diff --git a/Android.mk b/Android.mk
index 13540f4..0dc7ff1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -135,6 +135,7 @@
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src) \
     $(call all-java-files-under, quickstep/src) \
+    $(call all-java-files-under, src_flags) \
     $(call all-proto-files-under, protos) \
     $(call all-proto-files-under, proto_overrides)
 
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index f9ce6e0..a76f4f9 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/res/drawable/task_thumbnail_background.xml b/quickstep/res/drawable/task_thumbnail_background.xml
new file mode 100644
index 0000000..27efd6c
--- /dev/null
+++ b/quickstep/res/drawable/task_thumbnail_background.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+    <solid android:color="#FF000000" />
+    <corners android:radius="6dp" />
+</shape>
diff --git a/quickstep/res/layout/overview_panel.xml b/quickstep/res/layout/overview_panel.xml
index 466470f..521551c 100644
--- a/quickstep/res/layout/overview_panel.xml
+++ b/quickstep/res/layout/overview_panel.xml
@@ -19,28 +19,33 @@
     android:theme="@style/HomeScreenElementTheme"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:paddingTop="20dp"
+    android:paddingBottom="20dp"
+    android:clipToPadding="false"
     android:layout_gravity="center_horizontal|bottom"
     android:gravity="top">
 
     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
+        android:paddingStart="40dp"
+        android:paddingEnd="40dp"
         android:orientation="horizontal">
 
-        <View
-            android:layout_width="300dp"
+        <com.android.quickstep.SimpleTaskView
+            android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:background="#44FF0000"
             android:layout_marginEnd="10dp"/>
 
-        <View
-            android:layout_width="300dp"
+        <com.android.quickstep.SimpleTaskView
+            android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:background="#4400FF00"
             android:layout_marginEnd="10dp"/>
 
-        <View
-            android:layout_width="300dp"
+        <com.android.quickstep.SimpleTaskView
+            android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:background="#440000FF" />
     </LinearLayout>
diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml
new file mode 100644
index 0000000..9d8aea7
--- /dev/null
+++ b/quickstep/res/layout/task.xml
@@ -0,0 +1,35 @@
+<?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.
+-->
+<com.android.quickstep.TaskView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <com.android.quickstep.TaskThumbnailView
+        android:id="@+id/snapshot"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scaleType="matrix"
+        android:background="@drawable/task_thumbnail_background"
+        android:elevation="4dp" />
+    <ImageView
+        android:id="@+id/icon"
+        android:layout_width="36dp"
+        android:layout_height="36dp"
+        android:layout_gravity="top|center_horizontal"
+        android:elevation="5dp"/>
+</com.android.quickstep.TaskView>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 51a8a5e..9bdd7a3 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -16,16 +16,11 @@
 package com.android.launcher3.uioverrides;
 
 import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
-import static com.android.launcher3.Utilities.isAccessibilityEnabled;
 
-import android.graphics.Rect;
 import android.view.View;
-import android.view.accessibility.AccessibilityNodeInfo;
 
-import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherState;
-import com.android.launcher3.Workspace;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
 import com.android.quickstep.RecentsView;
 
@@ -37,7 +32,7 @@
     // The percent to shrink the workspace during overview mode
     public static final float SCALE_FACTOR = 0.7f;
 
-    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT;
+    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE;
 
     public OverviewState(int id) {
         super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
@@ -46,7 +41,7 @@
     @Override
     public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
         // TODO: Find a better transition
-        return new float[] {SCALE_FACTOR, 0};
+        return new float[] {0f, 0};
     }
 
     @Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
new file mode 100644
index 0000000..da1eff9
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -0,0 +1,53 @@
+/*
+ * 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.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
+
+import android.animation.AnimatorSet;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager.AnimationConfig;
+import com.android.launcher3.LauncherStateManager.StateHandler;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
+import com.android.launcher3.anim.AnimationLayerSet;
+
+public class RecentsViewStateController implements StateHandler {
+
+    private final Launcher mLauncher;
+
+    public RecentsViewStateController(Launcher launcher) {
+        mLauncher = launcher;
+    }
+
+    @Override
+    public void setState(LauncherState state) {
+        setState(state, NO_ANIM_PROPERTY_SETTER);
+    }
+
+    @Override
+    public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+            AnimatorSet anim, AnimationConfig config) {
+        setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
+    }
+
+    private void setState(LauncherState state, PropertySetter setter) {
+        setter.setViewAlpha(null, mLauncher.getOverviewPanel(),
+                state == LauncherState.OVERVIEW ? 1 : 0);
+    }
+}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 540b200..c490c3f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -19,6 +19,7 @@
 import android.view.View.AccessibilityDelegate;
 
 import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherStateManager.StateHandler;
 import com.android.launcher3.VerticalSwipeController;
 import com.android.launcher3.util.TouchController;
 
@@ -31,4 +32,10 @@
     public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
         return null;
     }
+
+    public static StateHandler[] getStateHandler(Launcher launcher) {
+        return new StateHandler[] {
+                launcher.getAllAppsController(), launcher.getWorkspace(),
+                new RecentsViewStateController(launcher)};
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
new file mode 100644
index 0000000..e94d76f
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -0,0 +1,243 @@
+/*
+ * 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.quickstep;
+
+import android.animation.Animator;
+import android.animation.ObjectAnimator;
+import android.animation.RectEvaluator;
+import android.annotation.TargetApi;
+import android.app.ActivityManager.RunningTaskInfo;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.os.Build;
+import android.os.UserHandle;
+import android.support.annotation.BinderThread;
+import android.support.annotation.UiThread;
+import android.util.FloatProperty;
+import android.view.Choreographer;
+import android.view.Choreographer.FrameCallback;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.launcher3.Hotseat;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.AnimationSuccessListener;
+import com.android.launcher3.anim.Interpolators;
+import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.states.InternalStateHandler;
+import com.android.systemui.shared.recents.model.Task.TaskKey;
+import com.android.systemui.shared.system.ActivityManagerWrapper;
+
+@TargetApi(Build.VERSION_CODES.O)
+public class NavBarSwipeInteractionHandler extends InternalStateHandler implements FrameCallback {
+
+    private static FloatProperty<NavBarSwipeInteractionHandler> SHIFT =
+            new FloatProperty<NavBarSwipeInteractionHandler>("currentShift") {
+        @Override
+        public void setValue(NavBarSwipeInteractionHandler handler, float v) {
+            handler.setShift(v);
+        }
+
+        @Override
+        public Float get(NavBarSwipeInteractionHandler handler) {
+            return handler.mCurrentShift;
+        }
+    };
+
+    // The following constants need to be scaled based on density. The scaled versions will be
+    // assigned to the corresponding member variables below.
+    private static final int FLING_THRESHOLD_VELOCITY = 500;
+    private static final int MIN_FLING_VELOCITY = 250;
+
+    private static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
+
+    private final Rect mSourceRect = new Rect();
+    private final Rect mTargetRect = new Rect();
+    private final Rect mCurrentRect = new Rect();
+    private final RectEvaluator mRectEvaluator = new RectEvaluator(mCurrentRect);
+
+    private final Bitmap mTaskSnapshot;
+    private final RunningTaskInfo mTaskInfo;
+
+    private Launcher mLauncher;
+    private Choreographer mChoreographer;
+    private SnapshotDragView mDragView;
+    private RecentsView mRecentsView;
+    private Hotseat mHotseat;
+
+    private float mStartDelta;
+    private float mLastDelta;
+
+    // Shift in the range of [0, 1].
+    // 0 => preview snapShot is completely visible, and hotseat is completely translated down
+    // 1 => preview snapShot is completely aligned with the recents view and hotseat is completely
+    // visible.
+    private float mCurrentShift;
+
+    // These are updated on the binder thread, and eventually picked up on doFrame
+    private volatile float mCurrentDisplacement;
+    private volatile float mEndVelocity;
+    private volatile boolean mTouchEnded = false;
+
+    NavBarSwipeInteractionHandler(Bitmap taskSnapShot, RunningTaskInfo taskInfo) {
+        mTaskSnapshot = taskSnapShot;
+        mTaskInfo = taskInfo;
+    }
+
+    @Override
+    public void onLauncherResume() {
+        mStartDelta = mCurrentDisplacement;
+        mLastDelta = mStartDelta;
+        mChoreographer = Choreographer.getInstance();
+
+        scheduleNextFrame();
+    }
+
+    @Override
+    public void onNewIntent(Launcher launcher) {
+        mLauncher = launcher;
+
+        // Go immediately
+        launcher.getStateManager().goToState(LauncherState.OVERVIEW, false);
+
+        // Optimization
+        launcher.getAppsView().setVisibility(View.GONE);
+
+        mDragView = new SnapshotDragView(launcher, mTaskSnapshot);
+        launcher.getDragLayer().addView(mDragView);
+        mDragView.setPivotX(0);
+        mDragView.setPivotY(0);
+        mRecentsView = launcher.getOverviewPanel();
+        mRecentsView.scrollTo(0, 0);
+        mHotseat = launcher.getHotseat();
+    }
+
+    /**
+     * This is updated on the binder thread and is picked up on the UI thread during the next
+     * scheduled frame.
+     * TODO: Instead of continuously scheduling frames, post the motion events to UI thread
+     * (can ignore all continuous move events until the last move).
+     */
+    @BinderThread
+    public void updateDisplacement(float displacement) {
+        mCurrentDisplacement = displacement;
+    }
+
+    @BinderThread
+    public void endTouch(float endVelocity) {
+        mEndVelocity = endVelocity;
+        mTouchEnded = true;
+    }
+
+    @UiThread
+    private void scheduleNextFrame() {
+        if (!mTouchEnded) {
+            mChoreographer.postFrameCallback(this);
+        } else {
+            animateToFinalShift();
+        }
+    }
+
+    @Override
+    public void doFrame(long l) {
+        mLastDelta = mCurrentDisplacement;
+
+        float translation = Utilities.boundToRange(mStartDelta - mLastDelta, 0,
+                mHotseat.getHeight());
+        int hotseatHeight = mHotseat.getHeight();
+        float shift = hotseatHeight == 0 ? 0 : translation / hotseatHeight;
+        setShift(shift);
+        scheduleNextFrame();
+    }
+
+    @UiThread
+    private void setShift(float shift) {
+        if (mTargetRect.isEmpty()) {
+            DragLayer dl = mLauncher.getDragLayer();
+
+            // Init target rect.
+            View targetView = ((ViewGroup) mRecentsView.getChildAt(0)).getChildAt(0);
+            dl.getViewRectRelativeToSelf(targetView, mTargetRect);
+            mSourceRect.set(0, 0, dl.getWidth(), dl.getHeight());
+        }
+
+        mCurrentShift = shift;
+        int hotseatHeight = mHotseat.getHeight();
+        mHotseat.setTranslationY((1 - shift) * hotseatHeight);
+
+        mRectEvaluator.evaluate(shift, mSourceRect, mTargetRect);
+
+        mDragView.setTranslationX(mCurrentRect.left);
+        mDragView.setTranslationY(mCurrentRect.top);
+        mDragView.setScaleX((float) mCurrentRect.width() / mSourceRect.width());
+        mDragView.setScaleY((float) mCurrentRect.width() / mSourceRect.width());
+    }
+
+    @UiThread
+    private void animateToFinalShift() {
+        float flingThreshold = Utilities.pxFromDp(FLING_THRESHOLD_VELOCITY,
+                    mLauncher.getResources().getDisplayMetrics());
+        boolean isFling = Math.abs(mEndVelocity) > flingThreshold;
+
+        long duration = 200;
+        final float endShift;
+        if (!isFling) {
+            endShift = mCurrentShift >= MIN_PROGRESS_FOR_OVERVIEW ? 1 : 0;
+        } else {
+            endShift = mEndVelocity < 0 ? 1 : 0;
+            float minFlingVelocity = Utilities.pxFromDp(MIN_FLING_VELOCITY,
+                    mLauncher.getResources().getDisplayMetrics());
+            if (Math.abs(mEndVelocity) > minFlingVelocity) {
+                float distanceToTravel = (endShift - mCurrentShift) * mHotseat.getHeight();
+
+                // we want the page's snap velocity to approximately match the velocity at
+                // which the user flings, so we scale the duration by a value near to the
+                // derivative of the scroll interpolator at zero, ie. 5. We use 4 to make
+                // it a little slower.
+                duration = 4 * Math.round(1000 * Math.abs(distanceToTravel / mEndVelocity));
+            }
+        }
+
+        ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHIFT, endShift)
+                .setDuration(duration);
+        anim.setInterpolator(Interpolators.SCROLL);
+        anim.addListener(new AnimationSuccessListener() {
+            @Override
+            public void onAnimationSuccess(Animator animator) {
+                if (Float.compare(mCurrentShift, 0) == 0) {
+                    resumeLastTask();
+                } else {
+                    mDragView.close(false);
+                }
+            }
+        });
+        anim.start();
+    }
+
+    @UiThread
+    private void resumeLastTask() {
+        // TODO: These should be done as part of ActivityOptions#OnAnimationStarted
+        mHotseat.setTranslationY(0);
+        mLauncher.setOnResumeCallback(() -> mDragView.close(false));
+
+        // TODO: Task key should be received from Recents model
+        TaskKey taskKey = new TaskKey(mTaskInfo.id, 0, null, UserHandle.myUserId(), 0);
+        ActivityManagerWrapper.getInstance()
+                .startActivityFromRecentsAsync(taskKey, null, null, null);
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 8f75980..a0340b6 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -40,7 +40,7 @@
         plan.preloadPlan(new RecentsTaskLoader(this, 1, 1, 0), -1, UserHandle.myUserId());
 
         mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
-        mAdapter.addAll(plan.getTaskStack().getStackTasks());
+        mAdapter.addAll(plan.getTaskStack().getTasks());
         setListAdapter(mAdapter);
     }
 }
diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java
index e474ecb..d7559da 100644
--- a/quickstep/src/com/android/quickstep/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/RecentsView.java
@@ -17,13 +17,20 @@
 package com.android.quickstep;
 
 import android.content.Context;
+import android.graphics.Rect;
 import android.util.AttributeSet;
 import android.widget.HorizontalScrollView;
 
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.Insettable;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
+
 /**
  * A placeholder view for recents
  */
-public class RecentsView extends HorizontalScrollView {
+public class RecentsView extends HorizontalScrollView implements Insettable {
+
     public RecentsView(Context context) {
         this(context, null);
     }
@@ -35,7 +42,23 @@
     public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
         setAlpha(0);
+        setVisibility(INVISIBLE);
     }
 
     public void setViewVisible(boolean isVisible) { }
+
+    @Override
+    public void setInsets(Rect insets) {
+        MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
+        lp.topMargin = insets.top;
+        lp.bottomMargin = insets.bottom;
+        lp.leftMargin = insets.left;
+        lp.rightMargin = insets.right;
+
+        DeviceProfile dp = Launcher.getLauncher(getContext()).getDeviceProfile();
+        if (!dp.isVerticalBarLayout()) {
+             lp.bottomMargin += dp.hotseatBarSizePx + getResources().getDimensionPixelSize(
+                     R.dimen.dynamic_grid_min_page_indicator_size);
+        }
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/SimpleTaskView.java b/quickstep/src/com/android/quickstep/SimpleTaskView.java
new file mode 100644
index 0000000..8425fa3
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/SimpleTaskView.java
@@ -0,0 +1,52 @@
+/*
+ * 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.quickstep;
+
+import android.content.Context;
+import android.graphics.Point;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.WindowManager;
+
+/**
+ * A simple view which keeps its size proportional to the display size
+ */
+public class SimpleTaskView extends View {
+
+    private static final Point sTempPoint = new Point();
+
+    public SimpleTaskView(Context context) {
+        super(context);
+    }
+
+    public SimpleTaskView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public SimpleTaskView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        int height = MeasureSpec.getSize(heightMeasureSpec);
+        getContext().getSystemService(WindowManager.class)
+                .getDefaultDisplay().getRealSize(sTempPoint);
+
+        int width = (int) ((float) height * sTempPoint.x / sTempPoint.y);
+        setMeasuredDimension(width, height);
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/SnapshotDragView.java b/quickstep/src/com/android/quickstep/SnapshotDragView.java
new file mode 100644
index 0000000..791fe9f
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/SnapshotDragView.java
@@ -0,0 +1,83 @@
+/*
+ * 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.quickstep;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.view.MotionEvent;
+
+import com.android.launcher3.AbstractFloatingView;
+import com.android.launcher3.Insettable;
+import com.android.launcher3.Launcher;
+
+/**
+ * Floating view which shows the task snapshot allowing it to be dragged and placed.
+ */
+public class SnapshotDragView extends AbstractFloatingView implements Insettable {
+
+    private final Launcher mLauncher;
+    private final Bitmap mSnapshot;
+
+    public SnapshotDragView(Launcher launcher, Bitmap snapshot) {
+        super(launcher, null);
+        mLauncher = launcher;
+        mSnapshot = snapshot;
+        setWillNotDraw(false);
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        if (mSnapshot != null) {
+            setMeasuredDimension(mSnapshot.getWidth(), mSnapshot.getHeight());
+        } else {
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        }
+    }
+
+    @Override
+    public void setInsets(Rect insets) {
+
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        if (mSnapshot != null) {
+            canvas.drawBitmap(mSnapshot, 0, 0, null);
+        }
+    }
+
+    @Override
+    public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+        return false;
+    }
+
+    @Override
+    protected void handleClose(boolean animate) {
+        // We dont suupport animate.
+        mLauncher.getDragLayer().removeView(this);
+    }
+
+    @Override
+    public void logActionCommand(int command) {
+        // We should probably log the weather
+    }
+
+    @Override
+    protected boolean isOfType(int type) {
+        return (type & TYPE_QUICKSTEP_PREVIEW) != 0;
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
new file mode 100644
index 0000000..96c93c2
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
@@ -0,0 +1,185 @@
+/*
+ * 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.quickstep;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorMatrixColorFilter;
+import android.graphics.LightingColorFilter;
+import android.graphics.Matrix;
+import android.graphics.Outline;
+import android.graphics.Paint;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.graphics.Shader;
+import android.util.AttributeSet;
+import android.view.Display;
+import android.view.View;
+import android.view.ViewOutlineProvider;
+import android.widget.FrameLayout;
+
+import com.android.systemui.shared.recents.model.ThumbnailData;
+
+/**
+ * A task in the Recents view.
+ */
+public class TaskThumbnailView extends FrameLayout {
+
+    private ThumbnailData mThumbnailData;
+
+    private Rect mThumbnailRect = new Rect();
+    private float mThumbnailScale;
+
+    private Matrix mMatrix = new Matrix();
+    private Paint mDrawPaint = new Paint();
+    protected Paint mBgFillPaint = new Paint();
+    protected BitmapShader mBitmapShader;
+
+    private float mDimAlpha;
+    private LightingColorFilter mLightingColorFilter = new LightingColorFilter(Color.WHITE, 0);
+
+    public TaskThumbnailView(Context context) {
+        this(context, null);
+    }
+
+    public TaskThumbnailView(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public TaskThumbnailView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        setWillNotDraw(false);
+        setDimAlpha(1f);
+        setClipToOutline(true);
+    }
+
+    /**
+     * Updates this thumbnail.
+     */
+    public void setThumbnail(ThumbnailData thumbnailData) {
+        if (thumbnailData != null && thumbnailData.thumbnail != null) {
+            Bitmap bm = thumbnailData.thumbnail;
+            bm.prepareToDraw();
+            mThumbnailScale = thumbnailData.scale;
+            mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
+            mDrawPaint.setShader(mBitmapShader);
+            mThumbnailRect.set(0, 0,
+                    bm.getWidth() - thumbnailData.insets.left - thumbnailData.insets.right,
+                    bm.getHeight() - thumbnailData.insets.top - thumbnailData.insets.bottom);
+            mThumbnailData = thumbnailData;
+            updateThumbnailMatrix();
+            updateThumbnailPaintFilter();
+        } else {
+            mBitmapShader = null;
+            mDrawPaint.setShader(null);
+            mThumbnailRect.setEmpty();
+            mThumbnailData = null;
+        }
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        int viewWidth = getMeasuredWidth();
+        int viewHeight = getMeasuredHeight();
+        int thumbnailWidth = Math.min(viewWidth,
+                (int) (mThumbnailRect.width() * mThumbnailScale));
+        int thumbnailHeight = Math.min(viewHeight,
+                (int) (mThumbnailRect.height() * mThumbnailScale));
+
+        if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {
+            int topOffset = 0;
+            // Draw the background, there will be some small overdraw with the thumbnail
+            if (thumbnailWidth < viewWidth) {
+                // Portrait thumbnail on a landscape task view
+                canvas.drawRect(Math.max(0, thumbnailWidth), topOffset, viewWidth, viewHeight,
+                        mBgFillPaint);
+            }
+            if (thumbnailHeight < viewHeight) {
+                // Landscape thumbnail on a portrait task view
+                canvas.drawRect(0, Math.max(topOffset, thumbnailHeight), viewWidth, viewHeight,
+                        mBgFillPaint);
+            }
+
+            // Draw the thumbnail
+            canvas.drawRect(0, topOffset, thumbnailWidth, thumbnailHeight, mDrawPaint);
+        } else {
+            canvas.drawRect(0, 0, viewWidth, viewHeight, mBgFillPaint);
+        }
+    }
+
+    void updateThumbnailPaintFilter() {
+        int mul = (int) ((1.0f - mDimAlpha) * 255);
+        if (mBitmapShader != null) {
+            mLightingColorFilter = new LightingColorFilter(Color.WHITE,
+                    Color.argb(255, mul, mul, mul));
+            mDrawPaint.setColorFilter(mLightingColorFilter);
+            mDrawPaint.setColor(0xFFffffff);
+            mBgFillPaint.setColorFilter(mLightingColorFilter);
+        } else {
+            int grey = mul;
+            mDrawPaint.setColorFilter(null);
+            mDrawPaint.setColor(Color.argb(255, grey, grey, grey));
+        }
+        invalidate();
+    }
+
+    public void updateThumbnailMatrix() {
+        mThumbnailScale = 1f;
+        if (mBitmapShader != null && mThumbnailData != null) {
+            if (getMeasuredWidth() == 0) {
+                // If we haven't measured , skip the thumbnail drawing and only draw the background
+                // color
+                mThumbnailScale = 0f;
+            } else {
+                float invThumbnailScale = 1f / mThumbnailScale;
+                final Configuration configuration =
+                        getContext().getApplicationContext().getResources().getConfiguration();
+                final Point displaySize = new Point();
+                getDisplay().getRealSize(displaySize);
+                if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
+                    if (mThumbnailData.orientation == Configuration.ORIENTATION_PORTRAIT) {
+                        // If we are in the same orientation as the screenshot, just scale it to the
+                        // width of the task view
+                        mThumbnailScale = (float) getMeasuredWidth() / mThumbnailRect.width();
+                    } else {
+                        // Scale the landscape thumbnail up to app size, then scale that to the task
+                        // view size to match other portrait screenshots
+                        mThumbnailScale = invThumbnailScale *
+                                ((float) getMeasuredWidth() / displaySize.x);
+                    }
+                } else {
+                    // Otherwise, scale the screenshot to fit 1:1 in the current orientation
+                    mThumbnailScale = invThumbnailScale;
+                }
+            }
+            mMatrix.setTranslate(-mThumbnailData.insets.left * mThumbnailScale,
+                    -mThumbnailData.insets.top * mThumbnailScale);
+            mMatrix.postScale(mThumbnailScale, mThumbnailScale);
+            mBitmapShader.setLocalMatrix(mMatrix);
+        }
+        invalidate();
+    }
+
+    public void setDimAlpha(float dimAlpha) {
+        mDimAlpha = dimAlpha;
+        updateThumbnailPaintFilter();
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/TaskView.java b/quickstep/src/com/android/quickstep/TaskView.java
new file mode 100644
index 0000000..ea584f0
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/TaskView.java
@@ -0,0 +1,88 @@
+/*
+ * 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.quickstep;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+
+import com.android.launcher3.R;
+import com.android.systemui.shared.recents.model.Task;
+import com.android.systemui.shared.recents.model.Task.TaskCallbacks;
+import com.android.systemui.shared.recents.model.ThumbnailData;
+import com.android.systemui.shared.system.ActivityManagerWrapper;
+
+/**
+ * A task in the Recents view.
+ */
+public class TaskView extends FrameLayout implements TaskCallbacks {
+
+    private Task mTask;
+    private TaskThumbnailView mSnapshotView;
+    private ImageView mIconView;
+
+    public TaskView(Context context) {
+        this(context, null);
+    }
+
+    public TaskView(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public TaskView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        setWillNotDraw(false);
+        setOnClickListener((view) -> {
+            if (mTask != null) {
+                ActivityManagerWrapper.getInstance().startActivityFromRecentsAsync(mTask.key,
+                        null, null, null);
+            }
+        });
+    }
+
+    @Override
+    protected void onFinishInflate() {
+        mSnapshotView = findViewById(R.id.snapshot);
+        mIconView = findViewById(R.id.icon);
+    }
+
+    /**
+     * Updates this task view to the given {@param task}.
+     */
+    public void bind(Task task) {
+        mTask = task;
+        task.addCallback(this);
+    }
+
+    @Override
+    public void onTaskDataLoaded(Task task, ThumbnailData thumbnailData) {
+        mSnapshotView.setThumbnail(thumbnailData);
+        mSnapshotView.setDimAlpha(1f);
+        mIconView.setImageDrawable(task.icon);
+    }
+
+    @Override
+    public void onTaskDataUnloaded() {
+        // Do nothing
+    }
+
+    @Override
+    public void onTaskWindowingModeChanged() {
+        // Do nothing
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 091ab54..dcfa53b 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -15,17 +15,201 @@
  */
 package com.android.quickstep;
 
+import static android.view.MotionEvent.INVALID_POINTER_ID;
+
+import static com.android.launcher3.states.InternalStateHandler.EXTRA_STATE_HANDLER;
+
+import android.app.ActivityManager.RunningTaskInfo;
+import android.app.ActivityOptions;
 import android.app.Service;
+import android.content.ComponentName;
 import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
+import android.graphics.Point;
+import android.graphics.PointF;
+import android.graphics.Rect;
+import android.os.Bundle;
 import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.Display;
+import android.view.MotionEvent;
+import android.view.VelocityTracker;
+import android.view.ViewConfiguration;
+import android.view.WindowManager;
+
+import com.android.systemui.shared.recents.IOverviewProxy;
+import com.android.systemui.shared.recents.ISystemUiProxy;
+import com.android.systemui.shared.system.ActivityManagerWrapper;
 
 /**
  * Service connected by system-UI for handling touch interaction.
  */
 public class TouchInteractionService extends Service {
 
+    private static final String TAG = "TouchInteractionService";
+
+    private final IBinder mMyBinder = new IOverviewProxy.Stub() {
+
+        @Override
+        public void onMotionEvent(MotionEvent ev) {
+            handleMotionEvent(ev);
+        }
+
+        @Override
+        public void onBind(ISystemUiProxy iSystemUiProxy) throws RemoteException {
+            mISystemUiProxy = iSystemUiProxy;
+        }
+    };
+
+    private ActivityManagerWrapper mAM;
+    private RunningTaskInfo mRunningTask;
+    private Intent mHomeIntent;
+    private ComponentName mLauncher;
+
+    private final PointF mDownPos = new PointF();
+    private final PointF mLastPos = new PointF();
+    private int mActivePointerId = INVALID_POINTER_ID;
+    private VelocityTracker mVelocityTracker;
+    private int mTouchSlop;
+    private NavBarSwipeInteractionHandler mInteractionHandler;
+
+    private ISystemUiProxy mISystemUiProxy;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        mAM = ActivityManagerWrapper.getInstance();
+
+        mHomeIntent = new Intent(Intent.ACTION_MAIN)
+                .addCategory(Intent.CATEGORY_HOME)
+                .setPackage(getPackageName())
+                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        ResolveInfo info = getPackageManager().resolveActivity(mHomeIntent, 0);
+        mLauncher = new ComponentName(getPackageName(), info.activityInfo.name);
+        mHomeIntent.setComponent(mLauncher);
+    }
+
     @Override
     public IBinder onBind(Intent intent) {
-        return null;
+        Log.d(TAG, "Touch service connected");
+        return mMyBinder;
+    }
+
+    private void handleMotionEvent(MotionEvent ev) {
+        if (ev.getActionMasked() != MotionEvent.ACTION_DOWN && mVelocityTracker == null) {
+            return;
+        }
+        switch (ev.getActionMasked()) {
+            case MotionEvent.ACTION_DOWN: {
+                mActivePointerId = ev.getPointerId(0);
+                mDownPos.set(ev.getX(), ev.getY());
+                mLastPos.set(mDownPos);
+                mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
+
+                mRunningTask = mAM.getRunningTask();
+                if (mRunningTask == null || mRunningTask.topActivity.equals(mLauncher)) {
+                    // TODO: We could drive all-apps in this case. For now just ignore swipe.
+                    break;
+                }
+
+                if (mVelocityTracker == null) {
+                    mVelocityTracker = VelocityTracker.obtain();
+                } else {
+                    mVelocityTracker.clear();
+                }
+                mVelocityTracker.addMovement(ev);
+                if (mInteractionHandler != null) {
+                    mInteractionHandler.endTouch(0);
+                    mInteractionHandler = null;
+                }
+                break;
+            }
+            case MotionEvent.ACTION_POINTER_UP: {
+                int ptrIdx = ev.getActionIndex();
+                int ptrId = ev.getPointerId(ptrIdx);
+                if (ptrId == mActivePointerId) {
+                    final int newPointerIdx = ptrIdx == 0 ? 1 : 0;
+                    mDownPos.set(
+                            ev.getX(newPointerIdx) - (mLastPos.x - mDownPos.x),
+                            ev.getY(newPointerIdx) - (mLastPos.y - mDownPos.y));
+                    mLastPos.set(ev.getX(newPointerIdx), ev.getY(newPointerIdx));
+                    mActivePointerId = ev.getPointerId(newPointerIdx);
+                    mVelocityTracker.clear();
+                }
+                break;
+            }
+            case MotionEvent.ACTION_MOVE: {
+                int pointerIndex = ev.findPointerIndex(mActivePointerId);
+                if (pointerIndex == INVALID_POINTER_ID) {
+                    break;
+                }
+                mVelocityTracker.addMovement(ev);
+                mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
+
+                float displacement = ev.getY(pointerIndex) - mDownPos.y;
+                if (mInteractionHandler == null) {
+                    if (Math.abs(displacement) >= mTouchSlop) {
+                        startTouchTracking();
+                    }
+                } else {
+                    // Move
+                    mInteractionHandler.updateDisplacement(displacement);
+                }
+                break;
+            }
+            case MotionEvent.ACTION_CANCEL:
+                // TODO: Should be different than ACTION_UP
+            case MotionEvent.ACTION_UP: {
+
+                endInteraction();
+                break;
+            }
+        }
+    }
+
+    private void startTouchTracking() {
+        mInteractionHandler = new NavBarSwipeInteractionHandler(getCurrentTaskSnapshot(), mRunningTask);
+
+        Bundle extras = new Bundle();
+        extras.putBinder(EXTRA_STATE_HANDLER, mInteractionHandler);
+        Intent homeIntent = new Intent(mHomeIntent).putExtras(extras);
+
+        // TODO: Call ActivityManager#startRecentsActivity instead, so that the system knows that
+        // recents was started and not Home.
+        startActivity(homeIntent,
+                ActivityOptions.makeCustomAnimation(this, 0, 0).toBundle());
+    }
+
+    private void endInteraction() {
+        if (mInteractionHandler != null) {
+            mVelocityTracker.computeCurrentVelocity(1000,
+                    ViewConfiguration.get(this).getScaledMaximumFlingVelocity());
+
+            mInteractionHandler.endTouch(mVelocityTracker.getXVelocity(mActivePointerId));
+            mInteractionHandler = null;
+        }
+        mVelocityTracker.recycle();
+        mVelocityTracker = null;
+    }
+
+    private Bitmap getCurrentTaskSnapshot() {
+        if (mISystemUiProxy == null) {
+            Log.e(TAG, "Never received systemUIProxy");
+            return null;
+        }
+        Display display = getSystemService(WindowManager.class).getDefaultDisplay();
+        Point size = new Point();
+        display.getRealSize(size);
+
+        // TODO: We are using some hardcoded layers for now, to best approximate the activity layers
+        try {
+            return mISystemUiProxy.screenshot(new Rect(), size.x, size.y, 0, 100000, false,
+                    display.getRotation());
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error capturing snapshot", e);
+            return null;
+        }
     }
 }
diff --git a/res/layout/deep_shortcut.xml b/res/layout/deep_shortcut.xml
index 4a2ad42..4a3db1f 100644
--- a/res/layout/deep_shortcut.xml
+++ b/res/layout/deep_shortcut.xml
@@ -35,6 +35,7 @@
         android:textColor="?android:attr/textColorPrimary"
         android:fontFamily="sans-serif"
         launcher:layoutHorizontal="true"
+        launcher:deferShadowGeneration="true"
         launcher:iconDisplay="shortcut_popup"
         launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size" />
 
diff --git a/res/layout/system_shortcut.xml b/res/layout/system_shortcut.xml
index 04f3d02..1888e22 100644
--- a/res/layout/system_shortcut.xml
+++ b/res/layout/system_shortcut.xml
@@ -34,6 +34,7 @@
         android:fontFamily="sans-serif"
         launcher:iconDisplay="shortcut_popup"
         launcher:layoutHorizontal="true"
+        launcher:deferShadowGeneration="true"
         android:focusable="false" />
 
     <View
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index eb12dc8..957ec19 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -15,7 +15,10 @@
 -->
 
 <resources>
-<!-- Dynamic Grid -->
+
+    <dimen name="click_shadow_elevation">4dp</dimen>
+
+    <!-- Dynamic Grid -->
     <dimen name="dynamic_grid_edge_margin">8dp</dimen>
     <dimen name="dynamic_grid_min_page_indicator_size">32dp</dimen>
     <dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 62e0fb1..26024e5 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -20,7 +20,6 @@
 import android.content.Context;
 import android.support.annotation.IntDef;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.LinearLayout;
@@ -42,7 +41,8 @@
             TYPE_ACTION_POPUP,
             TYPE_WIDGETS_BOTTOM_SHEET,
             TYPE_WIDGET_RESIZE_FRAME,
-            TYPE_WIDGETS_FULL_SHEET
+            TYPE_WIDGETS_FULL_SHEET,
+            TYPE_QUICKSTEP_PREVIEW
     })
     @Retention(RetentionPolicy.SOURCE)
     public @interface FloatingViewType {}
@@ -51,9 +51,11 @@
     public static final int TYPE_WIDGETS_BOTTOM_SHEET = 1 << 2;
     public static final int TYPE_WIDGET_RESIZE_FRAME = 1 << 3;
     public static final int TYPE_WIDGETS_FULL_SHEET = 1 << 4;
+    public static final int TYPE_QUICKSTEP_PREVIEW = 1 << 5;
 
     public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP
-            | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET;
+            | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET
+            | TYPE_QUICKSTEP_PREVIEW;
 
     protected boolean mIsOpen;
 
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index a5422aa..9796d18 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -21,9 +21,12 @@
 import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.LauncherActivityInfo;
+import android.os.Build;
+import android.os.Process;
 import android.os.UserHandle;
 
 import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.util.ComponentKey;
 import com.android.launcher3.util.PackageManagerHelper;
 
@@ -59,17 +62,12 @@
         this.componentName = info.getComponentName();
         this.container = ItemInfo.NO_ID;
         this.user = user;
-        if (PackageManagerHelper.isAppSuspended(info.getApplicationInfo())) {
-            runtimeStatusFlags |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
-        }
-        if (quietModeEnabled) {
-            runtimeStatusFlags |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
-        }
-
         intent = makeLaunchIntent(info);
-        runtimeStatusFlags |= (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0
-                ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
 
+        if (quietModeEnabled) {
+            runtimeStatusFlags |= FLAG_DISABLED_QUIET_USER;
+        }
+        updateRuntimeFlagsForActivityTarget(this, info);
     }
 
     public AppInfo(AppInfo info) {
@@ -102,4 +100,21 @@
                 .setComponent(cn)
                 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
     }
+
+    public static void updateRuntimeFlagsForActivityTarget(
+            ItemInfoWithIcon info, LauncherActivityInfo lai) {
+        ApplicationInfo appInfo = lai.getApplicationInfo();
+        if (PackageManagerHelper.isAppSuspended(appInfo)) {
+            info.runtimeStatusFlags |= FLAG_DISABLED_SUSPENDED;
+        }
+        info.runtimeStatusFlags |= (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
+                ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
+
+        if (FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.ATLEAST_OREO
+                && appInfo.targetSdkVersion >= Build.VERSION_CODES.O
+                && Process.myUserHandle().equals(lai.getUser())) {
+            // The icon for a non-primary user is badged, hence it's not exactly an adaptive icon.
+            info.runtimeStatusFlags |= FLAG_ADAPTIVE_ICON;
+        }
+    }
 }
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 3162286..79a34a0 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -385,16 +385,7 @@
 
     @Override
     public void setPressedIcon(BubbleTextView icon, Bitmap background) {
-        if (icon == null || background == null) {
-            mTouchFeedbackView.setBitmap(null);
-            mTouchFeedbackView.animate().cancel();
-        } else {
-            if (mTouchFeedbackView.setBitmap(background)) {
-                mTouchFeedbackView.alignWithIconView(icon, mShortcutsAndWidgets,
-                        null /* clipAgainstView */);
-                mTouchFeedbackView.animateShadow();
-            }
-        }
+        mTouchFeedbackView.setPressedIcon(icon, background);
     }
 
     void setIsDragOverlapping(boolean isDragOverlapping) {
diff --git a/src/com/android/launcher3/ClickShadowView.java b/src/com/android/launcher3/ClickShadowView.java
index aad1112..5391b4d 100644
--- a/src/com/android/launcher3/ClickShadowView.java
+++ b/src/com/android/launcher3/ClickShadowView.java
@@ -16,15 +16,28 @@
 
 package com.android.launcher3;
 
+import static com.android.launcher3.FastBitmapDrawable.CLICK_FEEDBACK_DURATION;
+import static com.android.launcher3.FastBitmapDrawable.CLICK_FEEDBACK_INTERPOLATOR;
+import static com.android.launcher3.LauncherAnimUtils.ELEVATION;
+import static com.android.launcher3.graphics.HolographicOutlineHelper.ADAPTIVE_ICON_SHADOW_BITMAP;
+
+import android.animation.ObjectAnimator;
+import android.annotation.TargetApi;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Color;
+import android.graphics.Outline;
 import android.graphics.Paint;
 import android.graphics.Rect;
+import android.graphics.drawable.AdaptiveIconDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.util.Property;
 import android.view.View;
 import android.view.ViewDebug;
 import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
 
 public class ClickShadowView extends View {
 
@@ -32,6 +45,8 @@
     private static final int SHADOW_LOW_ALPHA = 30;
     private static final int SHADOW_HIGH_ALPHA = 60;
 
+    private static float sAdaptiveIconScaleFactor = 1f;
+
     private final Paint mPaint;
 
     @ViewDebug.ExportedProperty(category = "launcher")
@@ -40,6 +55,10 @@
     private final float mShadowPadding;
 
     private Bitmap mBitmap;
+    private ObjectAnimator mAnim;
+
+    private Drawable mAdaptiveIcon;
+    private ViewOutlineProvider mOutlineProvider;
 
     public ClickShadowView(Context context) {
         super(context);
@@ -50,6 +69,10 @@
         mShadowOffset = getResources().getDimension(R.dimen.click_shadow_high_shift);
     }
 
+    public static void setAdaptiveIconScaleFactor(float factor) {
+        sAdaptiveIconScaleFactor = factor;
+    }
+
     /**
      * @return extra space required by the view to show the shadow.
      */
@@ -57,11 +80,64 @@
         return (int) (SHADOW_SIZE_FACTOR * mShadowPadding);
     }
 
+    public void setPressedIcon(BubbleTextView icon, Bitmap background) {
+        if (icon == null) {
+            setBitmap(null);
+            cancelAnim();
+            return;
+        }
+        if (background == null) {
+            if (mBitmap == ADAPTIVE_ICON_SHADOW_BITMAP) {
+                // clear animation shadow
+            }
+            setBitmap(null);
+            cancelAnim();
+            icon.setOutlineProvider(null);
+        } else if (setBitmap(background)) {
+            if (mBitmap == ADAPTIVE_ICON_SHADOW_BITMAP) {
+                setupAdaptiveShadow(icon);
+                cancelAnim();
+                startAnim(icon, ELEVATION,
+                        getResources().getDimension(R.dimen.click_shadow_elevation));
+            } else {
+                alignWithIconView(icon);
+                startAnim(this, ALPHA, 1);
+            }
+        }
+    }
+
+    @TargetApi(Build.VERSION_CODES.O)
+    private void setupAdaptiveShadow(final BubbleTextView view) {
+        if (mAdaptiveIcon == null) {
+            mAdaptiveIcon = new AdaptiveIconDrawable(null, null);
+            mOutlineProvider = new ViewOutlineProvider() {
+                @Override
+                public void getOutline(View view, Outline outline) {
+                    mAdaptiveIcon.getOutline(outline);
+                }
+            };
+        }
+
+        int iconWidth = view.getRight() - view.getLeft();
+        int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
+        int drawableWidth = view.getIcon().getBounds().width();
+
+        Rect bounds = new Rect();
+        bounds.left = view.getCompoundPaddingLeft() + (iconHSpace - drawableWidth) / 2;
+        bounds.right = bounds.left + drawableWidth;
+        bounds.top = view.getPaddingTop();
+        bounds.bottom = bounds.top + view.getIcon().getBounds().height();
+        Utilities.scaleRectAboutCenter(bounds, sAdaptiveIconScaleFactor);
+
+        mAdaptiveIcon.setBounds(bounds);
+        view.setOutlineProvider(mOutlineProvider);
+    }
+
     /**
      * Applies the new bitmap.
      * @return true if the view was invalidated.
      */
-    public boolean setBitmap(Bitmap b) {
+    private boolean setBitmap(Bitmap b) {
         if (b != mBitmap){
             mBitmap = b;
             invalidate();
@@ -80,48 +156,51 @@
         }
     }
 
-    public void animateShadow() {
-        setAlpha(0);
-        animate().alpha(1)
-            .setDuration(FastBitmapDrawable.CLICK_FEEDBACK_DURATION)
-            .setInterpolator(FastBitmapDrawable.CLICK_FEEDBACK_INTERPOLATOR)
-            .start();
+    private void cancelAnim() {
+        if (mAnim != null) {
+            mAnim.cancel();
+            mAnim.setCurrentPlayTime(0);
+            mAnim = null;
+        }
+    }
+
+    private void startAnim(View target, Property<View, Float> property, float endValue) {
+        cancelAnim();
+        property.set(target, 0f);
+        mAnim = ObjectAnimator.ofFloat(target, property, endValue);
+        mAnim.setDuration(CLICK_FEEDBACK_DURATION)
+                .setInterpolator(CLICK_FEEDBACK_INTERPOLATOR);
+        mAnim.start();
     }
 
     /**
      * Aligns the shadow with {@param view}
-     * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
+     * Note: {@param view} must be a descendant of my parent.
      */
-    public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
-        float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
-        float topShift = view.getTop() + viewParent.getTop() - getTop();
+    private void alignWithIconView(BubbleTextView view) {
+        int[] coords = new int[] {0, 0};
+        Utilities.getDescendantCoordRelativeToAncestor(
+                (ViewGroup) view.getParent(), (View) getParent(), coords, false);
+
+        float leftShift = view.getLeft() + coords[0] - getLeft();
+        float topShift = view.getTop() + coords[1] - getTop();
         int iconWidth = view.getRight() - view.getLeft();
         int iconHeight = view.getBottom() - view.getTop();
         int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
         float drawableWidth = view.getIcon().getBounds().width();
 
-        if (clipAgainstView != null) {
-            // Set the bounds to clip against
-            int[] coords = new int[] {0, 0};
-            Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
-                    coords, false);
-            int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
-            int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
-            setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
-        } else {
-            // Reset the clip bounds
-            setClipBounds(null);
-        }
+        // Set the bounds to clip against
+        int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
+        int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
+        setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
 
         setTranslationX(leftShift
-                + viewParent.getTranslationX()
                 + view.getCompoundPaddingLeft() * view.getScaleX()
                 + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
                 + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
                 - mShadowPadding  /* extra shadow size */
                 );
         setTranslationY(topShift
-                + viewParent.getTranslationY()
                 + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
                 + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
                 - mShadowPadding  /* extra shadow size */
diff --git a/src/com/android/launcher3/ItemInfoWithIcon.java b/src/com/android/launcher3/ItemInfoWithIcon.java
index 1c4e88b..fea4dda 100644
--- a/src/com/android/launcher3/ItemInfoWithIcon.java
+++ b/src/com/android/launcher3/ItemInfoWithIcon.java
@@ -67,7 +67,6 @@
             FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED |
             FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER;
 
-
     /**
      * The item points to a system app.
      */
@@ -81,6 +80,12 @@
     public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
 
     /**
+     * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable}
+     * that can be optimized in various way.
+     */
+    public static final int FLAG_ADAPTIVE_ICON = 1 << 8;
+
+    /**
      * Status associated with the system state of the underlying item. This is calculated every
      * time a new info is created and not persisted on the disk.
      */
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 75968ae..b1b3452 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -63,6 +63,7 @@
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.os.AsyncTask;
+import android.os.Binder;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Parcelable;
@@ -123,6 +124,7 @@
 import com.android.launcher3.popup.PopupDataProvider;
 import com.android.launcher3.shortcuts.DeepShortcutManager;
 import com.android.launcher3.states.AllAppsState;
+import com.android.launcher3.states.InternalStateHandler;
 import com.android.launcher3.userevent.nano.LauncherLogProto;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -222,15 +224,12 @@
     @Thunk DragLayer mDragLayer;
     private DragController mDragController;
 
-    public View mWeightWatcher;
-
     private AppWidgetManagerCompat mAppWidgetManager;
     private LauncherAppWidgetHost mAppWidgetHost;
 
     private final int[] mTmpAddItemCellCoordinates = new int[2];
 
     @Thunk Hotseat mHotseat;
-    private ViewGroup mOverviewPanel;
 
     private View mAllAppsButton;
 
@@ -240,6 +239,9 @@
     @Thunk AllAppsContainerView mAppsView;
     AllAppsTransitionController mAllAppsController;
 
+    // UI and state for the overview panel
+    private ViewGroup mOverviewPanel;
+
     // We need to store the orientation Launcher was created with, due to a bug (b/64916689)
     // that results in widgets being inflated in the wrong orientation.
     private int mOrientation;
@@ -339,7 +341,7 @@
 
         mDragController = new DragController(this);
         mAllAppsController = new AllAppsTransitionController(this);
-        mStateManager = new LauncherStateManager(this, mAllAppsController);
+        mStateManager = new LauncherStateManager(this);
 
         mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);
 
@@ -1287,6 +1289,10 @@
         }
     }
 
+    public AllAppsTransitionController getAllAppsController() {
+        return mAllAppsController;
+    }
+
     public DragLayer getDragLayer() {
         return mDragLayer;
     }
@@ -1303,8 +1309,8 @@
         return mHotseat;
     }
 
-    public ViewGroup getOverviewPanel() {
-        return mOverviewPanel;
+    public <T extends ViewGroup> T getOverviewPanel() {
+        return (T) mOverviewPanel;
     }
 
     public DropTargetBar getDropTargetBar() {
@@ -1401,6 +1407,7 @@
                 });
             }
         }
+        InternalStateHandler.handleIntent(this, intent);
 
         TraceHelper.endSection("NEW_INTENT");
     }
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index dfe51af..9869fdf 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -164,4 +164,17 @@
                     view.setScaleY(scale);
                 }
             };
+
+    public static final Property<View, Float> ELEVATION =
+            new Property<View, Float>(Float.class, "elevation") {
+                @Override
+                public Float get(View view) {
+                    return view.getElevation();
+                }
+
+                @Override
+                public void set(View view, Float elevation) {
+                    view.setElevation(elevation);
+                }
+            };
 }
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index bb09a9f..d6cd8a3 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -36,9 +36,8 @@
 
     protected static final int FLAG_SHOW_SCRIM = 1 << 0;
     protected static final int FLAG_MULTI_PAGE = 1 << 1;
-    protected static final int FLAG_HIDE_HOTSEAT = 1 << 2;
-    protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 3;
-    protected static final int FLAG_DO_NOT_RESTORE = 1 << 4;
+    protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 2;
+    protected static final int FLAG_DO_NOT_RESTORE = 1 << 3;
 
     private static final LauncherState[] sAllStates = new LauncherState[4];
 
@@ -80,7 +79,6 @@
      * @see WorkspaceStateTransitionAnimation
      */
     public final boolean hasScrim;
-    public final boolean hideHotseat;
     public final int transitionDuration;
 
     /**
@@ -97,7 +95,6 @@
 
         this.hasScrim = (flags & FLAG_SHOW_SCRIM) != 0;
         this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
-        this.hideHotseat = (flags & FLAG_HIDE_HOTSEAT) != 0;
         this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0
                 ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                 : IMPORTANT_FOR_ACCESSIBILITY_AUTO;
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index b99df71..f016e8d 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -29,6 +29,7 @@
 import com.android.launcher3.anim.AnimationLayerSet;
 import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.uioverrides.UiFactory;
 
 /**
  * TODO: figure out what kind of tests we can write for this
@@ -78,21 +79,26 @@
     private final AnimationConfig mConfig = new AnimationConfig();
     private final Handler mUiHandler;
     private final Launcher mLauncher;
-    private final AllAppsTransitionController mAllAppsController;
 
+    private StateHandler[] mStateHandlers;
     private LauncherState mState = NORMAL;
 
-    public LauncherStateManager(
-            Launcher l, AllAppsTransitionController allAppsController) {
+    public LauncherStateManager(Launcher l) {
         mUiHandler = new Handler(Looper.getMainLooper());
         mLauncher = l;
-        mAllAppsController = allAppsController;
     }
 
     public LauncherState getState() {
         return mState;
     }
 
+    private StateHandler[] getStateHandlers() {
+        if (mStateHandlers == null) {
+            mStateHandlers = UiFactory.getStateHandler(mLauncher);
+        }
+        return mStateHandlers;
+    }
+
     /**
      * @see #goToState(LauncherState, boolean, Runnable)
      */
@@ -148,8 +154,9 @@
 
         if (!animated) {
             setState(state);
-            mAllAppsController.setFinalProgress(state.verticalProgress);
-            mLauncher.getWorkspace().setState(state);
+            for (StateHandler handler : getStateHandlers()) {
+                handler.setState(state);
+            }
             mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
 
             // Run any queued runnable
@@ -190,14 +197,12 @@
 
     protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
             final Runnable onCompleteRunnable) {
-
         final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
         final AnimationLayerSet layerViews = new AnimationLayerSet();
 
-        mAllAppsController.animateToFinalProgress(state.verticalProgress, animation, mConfig);
-        mLauncher.getWorkspace().setStateWithAnimation(state,
-                layerViews, animation, mConfig);
-
+        for (StateHandler handler : getStateHandlers()) {
+            handler.setStateWithAnimation(state, layerViews, animation, mConfig);
+        }
         animation.addListener(layerViews);
         animation.addListener(new AnimationSuccessListener() {
 
@@ -285,4 +290,18 @@
             mCurrentAnimation.addListener(this);
         }
     }
+
+    public interface StateHandler {
+
+        /**
+         * Updates the UI to {@param state} without any animations
+         */
+        void setState(LauncherState state);
+
+        /**
+         * Sets the UI to {@param state} by animating any changes.
+         */
+        void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+                AnimatorSet anim, AnimationConfig config);
+    }
 }
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index daa9bd0..93fe17c 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -105,7 +105,7 @@
 public class Workspace extends PagedView
         implements DropTarget, DragSource, View.OnTouchListener,
         DragController.DragListener, ViewGroup.OnHierarchyChangeListener,
-        Insettable {
+        Insettable, LauncherStateManager.StateHandler {
     private static final String TAG = "Launcher.Workspace";
 
     /** The value that {@link #mTransitionProgress} must be greater than for
@@ -296,7 +296,6 @@
 
         mLauncher = Launcher.getLauncher(context);
         mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
-        final Resources res = getResources();
         DeviceProfile grid = mLauncher.getDeviceProfile();
         mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
         mWallpaperManager = WallpaperManager.getInstance(context);
@@ -1558,6 +1557,7 @@
     /**
      * Sets the current workspace {@link LauncherState} and updates the UI without any animations
      */
+    @Override
     public void setState(LauncherState toState) {
         onStartStateTransition(toState);
         mStateTransitionAnimation.setState(toState);
@@ -1567,6 +1567,7 @@
     /**
      * Sets the current workspace {@link LauncherState}, then animates the UI
      */
+    @Override
     public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
             AnimatorSet anim, AnimationConfig config) {
         StateTransitionListener listener = new StateTransitionListener(toState);
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index e14461e..8edec40 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -90,7 +90,7 @@
  */
 public class WorkspaceStateTransitionAnimation {
 
-    private static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
+    public static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
 
     public final int mWorkspaceScrimAlpha;
 
@@ -141,14 +141,6 @@
                     propertySetter);
         }
 
-        float finalHotseatAlpha = state.hideHotseat ? 0f : 1f;
-
-        // This is true when transitioning between:
-        // - Overview <-> Workspace
-        propertySetter.setViewAlpha(null, mLauncher.getOverviewPanel(), 1 - finalHotseatAlpha);
-        propertySetter.setViewAlpha(mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha),
-                mLauncher.getHotseat(), finalHotseatAlpha);
-
         propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_IN);
         propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
                 finalWorkspaceTranslationY, Interpolators.ZOOM_IN);
@@ -176,7 +168,7 @@
         }
     }
 
-    private static class PropertySetter {
+    public static class PropertySetter {
 
         public void setViewAlpha(Animator anim, View view, float alpha) {
             if (anim != null) {
@@ -204,13 +196,14 @@
         }
     }
 
-    private static class AnimatedPropertySetter extends PropertySetter {
+    public static class AnimatedPropertySetter extends PropertySetter {
 
         private final long mDuration;
         private final AnimationLayerSet mLayerViews;
         private final AnimatorSet mStateAnimator;
 
-        AnimatedPropertySetter(long duration, AnimationLayerSet layerView, AnimatorSet anim) {
+        public AnimatedPropertySetter(
+                long duration, AnimationLayerSet layerView, AnimatorSet anim) {
             mDuration = duration;
             mLayerViews = layerView;
             mStateAnimator = anim;
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a1f37ba..81f5842 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -157,14 +157,7 @@
 
     @Override
     public void setPressedIcon(BubbleTextView icon, Bitmap background) {
-        if (icon == null || background == null) {
-            mTouchFeedbackView.setBitmap(null);
-            mTouchFeedbackView.animate().cancel();
-        } else if (mTouchFeedbackView.setBitmap(background)) {
-            View rv = findViewById(R.id.apps_list_view);
-            mTouchFeedbackView.alignWithIconView(icon, (ViewGroup) icon.getParent(), rv);
-            mTouchFeedbackView.animateShadow();
-        }
+        mTouchFeedbackView.setPressedIcon(icon, background);
     }
 
     /**
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 9b64043..eb26704 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -15,10 +15,12 @@
 import com.android.launcher3.Hotseat;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager;
 import com.android.launcher3.LauncherStateManager.AnimationConfig;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.Workspace;
+import com.android.launcher3.anim.AnimationLayerSet;
 import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.graphics.GradientView;
@@ -35,7 +37,8 @@
  * If release velocity < THRES1, snap according to either top or bottom depending on whether it's
  * closer to top or closer to the page indicator.
  */
-public class AllAppsTransitionController implements SearchUiManager.OnScrollRangeChangeListener {
+public class AllAppsTransitionController
+        implements SearchUiManager.OnScrollRangeChangeListener, LauncherStateManager.StateHandler {
 
     private static final Property<AllAppsTransitionController, Float> PROGRESS =
             new Property<AllAppsTransitionController, Float>(Float.class, "progress") {
@@ -122,8 +125,8 @@
      *
      * @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace
      *
-     * @see #setFinalProgress(float)
-     * @see #animateToFinalProgress(float, AnimatorSet, AnimationConfig)
+     * @see #setState(LauncherState)
+     * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSet, AnimationConfig)
      */
     public void setProgress(float progress) {
         mProgress = progress;
@@ -161,33 +164,32 @@
     }
 
     /**
-     * Sets the vertical transition progress to {@param progress} and updates all the dependent UI
+     * Sets the vertical transition progress to {@param state} and updates all the dependent UI
      * accordingly.
      */
-    public void setFinalProgress(float progress) {
-        setProgress(progress);
+    @Override
+    public void setState(LauncherState state) {
+        setProgress(state.verticalProgress);
         onProgressAnimationEnd();
     }
 
     /**
      * Creates an animation which updates the vertical transition progress and updates all the
      * dependent UI using various animation events
-     *
-     * @param progress the final vertical progress at the end of the animation
-     * @param animationOut the target AnimatorSet where this animation should be added
-     * @param outConfig an in/out configuration which can be shared with other animations
      */
-    public void animateToFinalProgress(
-            float progress, AnimatorSet animationOut, AnimationConfig outConfig) {
-        if (Float.compare(mProgress, progress) == 0) {
+    @Override
+    public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+            AnimatorSet animationOut, AnimationConfig config) {
+        if (Float.compare(mProgress, toState.verticalProgress) == 0) {
             // Fail fast
             onProgressAnimationEnd();
             return;
         }
 
-        Interpolator interpolator = outConfig.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
-        ObjectAnimator anim = ObjectAnimator.ofFloat(this, PROGRESS, mProgress, progress);
-        anim.setDuration(outConfig.duration);
+        Interpolator interpolator = config.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
+        ObjectAnimator anim = ObjectAnimator.ofFloat(
+                this, PROGRESS, mProgress, toState.verticalProgress);
+        anim.setDuration(config.duration);
         anim.setInterpolator(interpolator);
         anim.addListener(new AnimationSuccessListener() {
             @Override
diff --git a/src/com/android/launcher3/graphics/HolographicOutlineHelper.java b/src/com/android/launcher3/graphics/HolographicOutlineHelper.java
index 9e67f56..fdf2d67 100644
--- a/src/com/android/launcher3/graphics/HolographicOutlineHelper.java
+++ b/src/com/android/launcher3/graphics/HolographicOutlineHelper.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3.graphics;
 
+import static com.android.launcher3.ItemInfoWithIcon.FLAG_ADAPTIVE_ICON;
+
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BlurMaskFilter;
@@ -29,6 +31,7 @@
 import android.util.SparseArray;
 
 import com.android.launcher3.BubbleTextView;
+import com.android.launcher3.ItemInfoWithIcon;
 import com.android.launcher3.R;
 
 /**
@@ -37,6 +40,12 @@
  */
 public class HolographicOutlineHelper {
 
+    /**
+     * Bitmap used as shadow for Adaptive icons
+     */
+    public static final Bitmap ADAPTIVE_ICON_SHADOW_BITMAP =
+            Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
+
     private static HolographicOutlineHelper sInstance;
 
     private final Canvas mCanvas = new Canvas();
@@ -63,6 +72,11 @@
     }
 
     public Bitmap createMediumDropShadow(BubbleTextView view) {
+        if (view.getTag() instanceof ItemInfoWithIcon &&
+                ((((ItemInfoWithIcon) view.getTag()).runtimeStatusFlags & FLAG_ADAPTIVE_ICON)
+                        != 0)) {
+            return ADAPTIVE_ICON_SHADOW_BITMAP;
+        }
         Drawable drawable = view.getIcon();
         if (drawable == null) {
             return null;
@@ -119,7 +133,7 @@
     }
 
     public void recycleShadowBitmap(Bitmap bitmap) {
-        if (bitmap != null) {
+        if (bitmap != null && bitmap != ADAPTIVE_ICON_SHADOW_BITMAP) {
             mBitmapCache.put((bitmap.getWidth() << 16) | bitmap.getHeight(), bitmap);
         }
     }
diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java
index 47f370a..ccef9b7 100644
--- a/src/com/android/launcher3/model/LoaderCursor.java
+++ b/src/com/android/launcher3/model/LoaderCursor.java
@@ -16,15 +16,11 @@
 
 package com.android.launcher3.model;
 
-import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO;
-import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_YES;
-
 import android.content.ComponentName;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
 import android.content.Intent.ShortcutIconResource;
-import android.content.pm.ApplicationInfo;
 import android.content.pm.LauncherActivityInfo;
 import android.database.Cursor;
 import android.database.CursorWrapper;
@@ -36,6 +32,7 @@
 import android.util.Log;
 import android.util.LongSparseArray;
 
+import com.android.launcher3.AppInfo;
 import com.android.launcher3.IconCache;
 import com.android.launcher3.InvariantDeviceProfile;
 import com.android.launcher3.ItemInfo;
@@ -52,7 +49,6 @@
 import com.android.launcher3.util.ContentWriter;
 import com.android.launcher3.util.GridOccupancy;
 import com.android.launcher3.util.LongArrayMap;
-import com.android.launcher3.util.PackageManagerHelper;
 
 import java.net.URISyntaxException;
 import java.security.InvalidParameterException;
@@ -206,7 +202,6 @@
         return TextUtils.isEmpty(title) ? "" : Utilities.trim(title);
     }
 
-
     /**
      * Make an ShortcutInfo object for a restored application or shortcut item that points
      * to a package that is not yet installed on the system.
@@ -279,12 +274,7 @@
         }
 
         if (lai != null) {
-            ApplicationInfo appInfo = lai.getApplicationInfo();
-            if (PackageManagerHelper.isAppSuspended(appInfo)) {
-                info.runtimeStatusFlags |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
-            }
-            info.runtimeStatusFlags |= (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
-                    ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
+            AppInfo.updateRuntimeFlagsForActivityTarget(info, lai);
         }
 
         // from the db
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index c2cfebb..310416f 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -25,6 +25,7 @@
 import android.content.pm.LauncherActivityInfo;
 import android.content.pm.PackageInstaller;
 import android.graphics.Bitmap;
+import android.graphics.drawable.AdaptiveIconDrawable;
 import android.os.Handler;
 import android.os.Process;
 import android.os.UserHandle;
@@ -35,6 +36,7 @@
 
 import com.android.launcher3.AllAppsList;
 import com.android.launcher3.AppInfo;
+import com.android.launcher3.ClickShadowView;
 import com.android.launcher3.FolderInfo;
 import com.android.launcher3.IconCache;
 import com.android.launcher3.InstallShortcutReceiver;
@@ -52,6 +54,7 @@
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.folder.Folder;
 import com.android.launcher3.folder.FolderIconPreviewVerifier;
+import com.android.launcher3.graphics.IconNormalizer;
 import com.android.launcher3.graphics.LauncherIcons;
 import com.android.launcher3.logging.FileLog;
 import com.android.launcher3.provider.ImportDataTask;
@@ -145,7 +148,9 @@
 
         TraceHelper.beginSection(TAG);
         try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
-            TraceHelper.partitionSection(TAG, "step 1.1: loading workspace");
+            TraceHelper.partitionSection(TAG, "step 1.1: loading UI resources");
+            loadUiResources();
+            TraceHelper.partitionSection(TAG, "step 1.2: loading workspace");
             loadWorkspace();
 
             verifyNotStopped();
@@ -208,6 +213,14 @@
         this.notify();
     }
 
+    public void loadUiResources() {
+        if (Utilities.ATLEAST_OREO) {
+            ClickShadowView.setAdaptiveIconScaleFactor(
+                    IconNormalizer.getInstance(mApp.getContext()).getScale(
+                            new AdaptiveIconDrawable(null, null), null, null, null));
+        }
+    }
+
     private void loadWorkspace() {
         final Context context = mApp.getContext();
         final ContentResolver contentResolver = context.getContentResolver();
diff --git a/src/com/android/launcher3/states/InternalStateHandler.java b/src/com/android/launcher3/states/InternalStateHandler.java
new file mode 100644
index 0000000..a90ed36
--- /dev/null
+++ b/src/com/android/launcher3/states/InternalStateHandler.java
@@ -0,0 +1,43 @@
+/*
+ * 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.states;
+
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.Launcher.OnResumeCallback;
+
+/**
+ * Utility class to sending state handling logic to Launcher from within the same process
+ */
+public abstract class InternalStateHandler extends Binder implements OnResumeCallback {
+
+    public static final String EXTRA_STATE_HANDLER = "launcher.state_handler";
+
+    public abstract void onNewIntent(Launcher launcher);
+
+    public static void handleIntent(Launcher launcher, Intent intent) {
+        IBinder stateBinder = intent.getExtras().getBinder(EXTRA_STATE_HANDLER);
+        if (stateBinder instanceof InternalStateHandler) {
+            InternalStateHandler handler = (InternalStateHandler) stateBinder;
+            launcher.setOnResumeCallback(handler);
+            handler.onNewIntent(launcher);
+        }
+        intent.getExtras().remove(EXTRA_STATE_HANDLER);
+    }
+}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
index 1fb56e7..3ce1014 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
@@ -15,12 +15,14 @@
  */
 package com.android.launcher3.uioverrides;
 
+import static com.android.launcher3.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
+
+import android.animation.AnimatorSet;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
 import android.graphics.Rect;
 import android.util.AttributeSet;
-import android.util.Log;
 import android.view.View;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
@@ -28,14 +30,20 @@
 
 import com.android.launcher3.Insettable;
 import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager;
+import com.android.launcher3.LauncherStateManager.AnimationConfig;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
+import com.android.launcher3.anim.AnimationLayerSet;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 import com.android.launcher3.widget.WidgetsFullSheet;
 
 public class OverviewPanel extends LinearLayout implements Insettable, View.OnClickListener,
-        View.OnLongClickListener {
+        View.OnLongClickListener, LauncherStateManager.StateHandler {
 
     // Out of 100, the percent of space the overview bar should try and take vertically.
     private static final float OVERVIEW_ICON_ZONE_RATIO = 0.22f;
@@ -154,10 +162,30 @@
         getContext().startActivity(intent, mLauncher.getActivityLaunchOptions(v));
     }
 
+    @Override
+    public void setState(LauncherState state) {
+        setState(state, NO_ANIM_PROPERTY_SETTER);
+    }
+
+    @Override
+    public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+            AnimatorSet anim, AnimationConfig config) {
+        setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
+    }
+
+    private void setState(LauncherState state, PropertySetter setter) {
+        boolean isOverview = state == LauncherState.OVERVIEW;
+        float finalHotseatAlpha = isOverview ? 0 : 1;
+
+        setter.setViewAlpha(null, this, isOverview ? 1 : 0);
+        setter.setViewAlpha(
+                mLauncher.getWorkspace().createHotseatAlphaAnimator(finalHotseatAlpha),
+                mLauncher.getHotseat(), finalHotseatAlpha);
+    }
 
     public static int getButtonBarHeight(Launcher launcher) {
         int zoneHeight = (int) (OVERVIEW_ICON_ZONE_RATIO *
-                launcher.getDeviceProfile().availableWidthPx);
+                launcher.getDeviceProfile().availableHeightPx);
         Resources res = launcher.getResources();
         int overviewModeMinIconZoneHeightPx =
                 res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_min_icon_zone_height);
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
index 9e2ad98..c339634 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
@@ -36,7 +36,7 @@
     // The percent to shrink the workspace during overview mode
     public static final float SCALE_FACTOR = 0.7f;
 
-    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT;
+    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE;
 
     public OverviewState(int id) {
         super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 6776150..8521334 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -19,6 +19,7 @@
 import android.view.View.AccessibilityDelegate;
 
 import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherStateManager.StateHandler;
 import com.android.launcher3.VerticalSwipeController;
 import com.android.launcher3.util.TouchController;
 
@@ -32,4 +33,10 @@
     public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
         return new OverviewAccessibilityDelegate();
     }
+
+    public static StateHandler[] getStateHandler(Launcher launcher) {
+        return new StateHandler[] {
+                (OverviewPanel) launcher.getOverviewPanel(),
+                launcher.getAllAppsController(), launcher.getWorkspace() };
+    }
 }