Merge "Change overview animation to scale instead of translationX" into ub-launcher3-master
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
index 3b983d2..4013429 100644
--- a/protos/launcher_log.proto
+++ b/protos/launcher_log.proto
@@ -69,6 +69,7 @@
   EDITTEXT = 7;
   NOTIFICATION = 8;
   TASK = 9;         // Each page of Recents UI (QuickStep)
+  WEB_APP = 10;
 }
 
 // Used to define what type of container a Target would represent.
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 2b9db35..3c5033e 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index 8f2e104..e4a8f36 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -146,15 +146,18 @@
 
                     @Override
                     public AnimatorSet getAnimator(RemoteAnimationTargetCompat[] targetCompats) {
-                        Animator[] anims = composeRecentsLaunchAnimator(v, targetCompats);
                         AnimatorSet anim = new AnimatorSet();
-                        if (anims != null) {
-                            anim.playTogether(anims);
-                        } else {
-                            anim.play(getLauncherAnimators(v, targetCompats));
+                        // Set the state animation first so that any state listeners are called
+                        // before our internal listeners.
+                        mLauncher.getStateManager().setCurrentAnimation(anim);
+
+                        if (!composeRecentsLaunchAnimator(v, targetCompats, anim)) {
+                            if (launcherIsATargetWithMode(targetCompats, MODE_CLOSING)) {
+                                anim.play(getIconAnimator(v));
+                                anim.play(getLauncherContentAnimator(false /* show */));
+                            }
                             anim.play(getWindowAnimators(v, targetCompats));
                         }
-                        mLauncher.getStateManager().setCurrentAnimation(anim);
                         return anim;
                     }
                 };
@@ -233,11 +236,11 @@
     /**
      * Composes the animations for a launch from the recents list if possible.
      */
-    private Animator[] composeRecentsLaunchAnimator(View v,
-            RemoteAnimationTargetCompat[] targets) {
+    private boolean composeRecentsLaunchAnimator(View v,
+            RemoteAnimationTargetCompat[] targets, AnimatorSet target) {
         // Ensure recents is actually visible
         if (!mLauncher.getStateManager().getState().overviewUi) {
-            return null;
+            return false;
         }
 
         RecentsView recentsView = mLauncher.getOverviewPanel();
@@ -246,7 +249,7 @@
 
         TaskView taskView = findTaskViewToLaunch(mLauncher, v, targets);
         if (taskView == null) {
-            return null;
+            return false;
         }
 
         // Found a visible recents task that matches the opening app, lets launch the app from there
@@ -273,9 +276,10 @@
             };
         }
 
-        Animator windowAnim = getRecentsWindowAnimator(taskView, skipLauncherChanges, targets);
-        windowAnim.addListener(windowAnimEndListener);
-        return new Animator[] {launcherAnim, windowAnim};
+        target.play(getRecentsWindowAnimator(taskView, skipLauncherChanges, targets));
+        target.play(launcherAnim);
+        target.addListener(windowAnimEndListener);
+        return true;
     }
 
     /**
@@ -355,18 +359,6 @@
     }
 
     /**
-     * @return Animators that control the movements of the Launcher and icon of the opening target.
-     */
-    private AnimatorSet getLauncherAnimators(View v, RemoteAnimationTargetCompat[] targets) {
-        AnimatorSet launcherAnimators = new AnimatorSet();
-        launcherAnimators.play(getIconAnimator(v));
-        if (launcherIsATargetWithMode(targets, MODE_CLOSING)) {
-            launcherAnimators.play(getLauncherContentAnimator(false /* show */));
-        }
-        return launcherAnimators;
-    }
-
-    /**
      * Content is everything on screen except the background and the floating view (if any).
      *
      * @param show If true: Animate the content so that it moves upwards and fades in.
@@ -687,11 +679,9 @@
                 anim.play(getClosingWindowAnimators(targetCompats));
 
                 if (launcherIsATargetWithMode(targetCompats, MODE_OPENING)) {
-                    AnimatorSet contentAnimation = getLauncherResumeAnimation();
-                    anim.play(contentAnimation);
-
                     // Only register the content animation for cancellation when state changes
-                    mLauncher.getStateManager().setCurrentAnimation(contentAnimation);
+                    mLauncher.getStateManager().setCurrentAnimation(anim);
+                    createLauncherResumeAnimation(anim);
                 }
                 return anim;
             }
@@ -754,14 +744,14 @@
     }
 
     /**
-     * @return Animator that modifies Launcher as a result from {@link #getWallpaperOpenRunner}.
+     * Creates an animator that modifies Launcher as a result from {@link #getWallpaperOpenRunner}.
      */
-    private AnimatorSet getLauncherResumeAnimation() {
+    private void createLauncherResumeAnimation(AnimatorSet anim) {
         if (mLauncher.isInState(LauncherState.ALL_APPS)
                 || mLauncher.getDeviceProfile().isVerticalBarLayout()) {
             AnimatorSet contentAnimator = getLauncherContentAnimator(true /* show */);
             contentAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
-            return contentAnimator;
+            anim.play(contentAnimator);
         } else {
             AnimatorSet workspaceAnimator = new AnimatorSet();
 
@@ -799,12 +789,10 @@
             allAppsOvershoot.setDuration(153);
             allAppsOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
 
-            AnimatorSet resumeLauncherAnimation = new AnimatorSet();
-            resumeLauncherAnimation.play(workspaceAnimator);
-            resumeLauncherAnimation.playSequentially(allAppsSlideIn, allAppsOvershoot);
 
-            resumeLauncherAnimation.addListener(mReapplyStateListener);
-            return resumeLauncherAnimation;
+            anim.play(workspaceAnimator);
+            anim.playSequentially(allAppsSlideIn, allAppsOvershoot);
+            anim.addListener(mReapplyStateListener);
         }
     }
 
diff --git a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java
index 4bd4a11..0ab2df7 100644
--- a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java
+++ b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java
@@ -285,7 +285,8 @@
 
             // Also clean up in case the system has handled the UP and canceled the animation before
             // we had a chance to start the recents animation. In such a case, we will not receive
-            ActivityManagerWrapper.getInstance().cancelRecentsAnimation();
+            ActivityManagerWrapper.getInstance().cancelRecentsAnimation(
+                    true /* restoreHomeStackPosition */);
         }
         mVelocityTracker.recycle();
         mVelocityTracker = null;
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
index 4e11220..12f8d52 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
@@ -28,7 +28,9 @@
     public RecentsAnimationControllerCompat controller;
     public RemoteAnimationTargetCompat[] targets;
 
-    private boolean mInputConsumerEnabled;
+    private boolean mInputConsumerEnabled = false;
+    private boolean mBehindSystemBars = true;
+    private boolean mSplitScreenMinimized = false;
 
     public synchronized void setController(
             RecentsAnimationControllerCompat controller, RemoteAnimationTargetCompat[] targets) {
@@ -75,4 +77,42 @@
             });
         }
     }
+
+    public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) {
+        if (mBehindSystemBars == behindSystemBars) {
+            return;
+        }
+        mBehindSystemBars = behindSystemBars;
+        BackgroundExecutor.get().submit(() -> {
+            synchronized (this) {
+                TraceHelper.partitionSection("RecentsController",
+                        "Setting behind system bars on " + controller);
+                if (controller != null) {
+                    controller.setAnimationTargetsBehindSystemBars(behindSystemBars);
+                }
+            }
+        });
+    }
+
+    /**
+     * NOTE: As a workaround for conflicting animations (Launcher animating the task leash, and
+     * SystemUI resizing the docked stack, which resizes the task), we currently only set the
+     * minimized mode, and not the inverse.
+     * TODO: Synchronize the minimize animation with the launcher animation
+     */
+    public void setSplitScreenMinimizedForTransaction(boolean minimized) {
+        if (mSplitScreenMinimized || !minimized) {
+            return;
+        }
+        mSplitScreenMinimized = minimized;
+        BackgroundExecutor.get().submit(() -> {
+            synchronized (this) {
+                TraceHelper.partitionSection("RecentsController",
+                        "Setting minimize dock on " + controller);
+                if (controller != null) {
+                    controller.setSplitScreenMinimized(minimized);
+                }
+            }
+        });
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 1ded4dd..b610f4d 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -134,6 +134,8 @@
             if (triggeredFromAltTab) {
                 setupTouchConsumer(HIT_TARGET_NONE);
                 mEventQueue.onOverviewShownFromAltTab();
+            } else {
+                mOverviewCommandHelper.onOverviewShown();
             }
         }
 
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 611f7e0..36a9d56 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -497,6 +497,7 @@
                 TransactionCompat transaction = new TransactionCompat();
                 for (RemoteAnimationTargetCompat app : mRecentsAnimationWrapper.targets) {
                     if (app.mode == MODE_CLOSING) {
+                        mTmpMatrix.postTranslate(app.position.x, app.position.y);
                         transaction.setMatrix(app.leash, mTmpMatrix)
                                 .setWindowCrop(app.leash, mClipRect);
 
@@ -534,10 +535,10 @@
                     }
                 }
                 if (mRecentsAnimationWrapper.controller != null) {
-
                     // TODO: This logic is spartanic!
-                    mRecentsAnimationWrapper.controller.setAnimationTargetsBehindSystemBars(
-                            shift < 0.12f);
+                    boolean passedThreshold = shift > 0.12f;
+                    mRecentsAnimationWrapper.setAnimationTargetsBehindSystemBars(!passedThreshold);
+                    mRecentsAnimationWrapper.setSplitScreenMinimizedForTransaction(passedThreshold);
                 }
             };
             if (Looper.getMainLooper() == Looper.myLooper()) {
diff --git a/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java b/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java
index 82ec84e..5e9cd6e 100644
--- a/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java
+++ b/quickstep/src/com/android/quickstep/views/QuickstepDragIndicator.java
@@ -50,9 +50,7 @@
     @Override
     public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
         super.onInitializeAccessibilityNodeInfo(info);
-        if (isInOverview()) {
-            info.setContentDescription(getContext().getString(R.string.all_apps_button_label));
-        }
+        info.setContentDescription(getContext().getString(R.string.all_apps_button_label));
     }
 
     @Override
@@ -64,15 +62,9 @@
 
     @Override
     public void onClick(View view) {
-        if (isInOverview()) {
-            mLauncher.getUserEventDispatcher().logActionOnControl(
-                    Action.Touch.TAP, ControlType.ALL_APPS_BUTTON, ContainerType.TASKSWITCHER);
-            mLauncher.getStateManager().goToState(ALL_APPS);
-            super.onClick(view);
-        } else {
-            mLauncher.getUserEventDispatcher().logActionOnControl(
-                    Action.Touch.TAP, ControlType.ALL_APPS_BUTTON, ContainerType.WORKSPACE);
-            mLauncher.getStateManager().goToState(OVERVIEW);
-        }
+        mLauncher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
+                ControlType.ALL_APPS_BUTTON,
+                isInOverview() ? ContainerType.TASKSWITCHER : ContainerType.WORKSPACE);
+        mLauncher.getStateManager().goToState(ALL_APPS);
     }
 }
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f6b6abd..a791861 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1029,4 +1029,9 @@
         super.notifyPageSwitchListener(prevPage);
         getChildAt(mCurrentPage).sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
     }
+
+    @Override
+    protected String getCurrentPageDescription() {
+        return "";
+    }
 }
diff --git a/res/layout/launcher_preference.xml b/res/layout/launcher_preference.xml
deleted file mode 100644
index ed0ea7c..0000000
--- a/res/layout/launcher_preference.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.launcher3.views.HighlightableListView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@android:id/list"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:cacheColorHint="@android:color/transparent"
-    android:clipToPadding="false"
-    android:drawSelectorOnTop="false"
-    android:orientation="vertical"
-    android:scrollbarAlwaysDrawVerticalTrack="true"
-    android:scrollbarStyle="outsideOverlay" />
\ No newline at end of file
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ccc774a..b410f4f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -357,11 +357,6 @@
         if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0) {
             mUserEventDispatcher = null;
             initDeviceProfile(mDeviceProfile.inv);
-            FileLog.d(TAG, "Config changed, my orientation=" +
-                    getResources().getConfiguration().orientation +
-                    ", new orientation=" + newConfig.orientation +
-                    ", old orientation=" + mOldConfig.orientation +
-                    ", isTransposed=" + mDeviceProfile.isVerticalBarLayout());
             dispatchDeviceProfileChanged();
 
             getRootView().dispatchInsets();
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 8b7ba20..7d208d4 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -34,7 +34,6 @@
 import android.database.Cursor;
 import android.database.SQLException;
 import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
 import android.database.sqlite.SQLiteQueryBuilder;
 import android.database.sqlite.SQLiteStatement;
 import android.net.Uri;
@@ -56,7 +55,6 @@
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.logging.FileLog;
 import com.android.launcher3.model.DbDowngradeHelper;
-import com.android.launcher3.model.ModelWriter;
 import com.android.launcher3.provider.LauncherDbUtils;
 import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
 import com.android.launcher3.provider.RestoreDbTask;
@@ -320,11 +318,6 @@
 
     @Override
     public int delete(Uri uri, String selection, String[] selectionArgs) {
-        if (ModelWriter.DEBUG_DELETE) {
-            String args = selectionArgs == null ? null : TextUtils.join(",", selectionArgs);
-            FileLog.d(TAG, "Delete uri=" + uri + ", selection=" + selection
-                    + ", selectionArgs=" + args, new Exception());
-        }
         createDbIfNotExists();
         SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
 
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index ef285df..534c8ae 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -356,7 +356,11 @@
      * starting another animation and may block some launcher interactions while running.
      */
     public void setCurrentAnimation(AnimatorSet anim) {
+        boolean reapplyNeeded = mConfig.mCurrentAnimation != null;
         cancelAnimation();
+        if (reapplyNeeded) {
+            reapplyState();
+        }
         mConfig.setAnimation(anim);
     }
 
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 1e761e4..79993c1 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -41,6 +41,7 @@
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.view.animation.Interpolator;
+import android.widget.ScrollView;
 
 import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.pageindicators.PageIndicator;
@@ -1467,6 +1468,13 @@
         if (getNextPage() < getChildCount() -1) snapToPage(getNextPage() + 1);
     }
 
+    @Override
+    public CharSequence getAccessibilityClassName() {
+        // Some accessibility services have special logic for ScrollView. Since we provide same
+        // accessibility info as ScrollView, inform the service to handle use the same way.
+        return ScrollView.class.getName();
+    }
+
     /* Accessibility */
     @SuppressWarnings("deprecation")
     @Override
@@ -1479,7 +1487,6 @@
         if (getCurrentPage() > 0) {
             info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
         }
-        info.setClassName(getClass().getName());
 
         // Accessibility-wise, PagedView doesn't support long click, so disabling it.
         // Besides disabling the accessibility long-click, this also prevents this view from getting
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index 7fa0e52..c9bd32b 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -16,6 +16,7 @@
 
 package com.android.launcher3;
 
+import android.annotation.TargetApi;
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
@@ -26,22 +27,25 @@
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.os.Build;
 import android.os.Bundle;
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
 import android.provider.Settings;
 import android.text.TextUtils;
-import android.view.LayoutInflater;
 import android.view.View;
-import android.view.ViewGroup;
 import android.widget.Adapter;
+import android.widget.ListView;
 
 import com.android.launcher3.graphics.IconShapeOverride;
 import com.android.launcher3.notification.NotificationListener;
+import com.android.launcher3.util.ListViewHighlighter;
 import com.android.launcher3.util.SettingsObserver;
 import com.android.launcher3.views.ButtonPreference;
-import com.android.launcher3.views.HighlightableListView;
+
+import java.util.Objects;
 
 /**
  * Settings activity for Launcher. Currently implements the following setting: Allow rotation
@@ -85,12 +89,6 @@
         private boolean mPreferenceHighlighted = false;
 
         @Override
-        public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                Bundle savedInstanceState) {
-            return inflater.inflate(R.layout.launcher_preference, container, false);
-        }
-
-        @Override
         public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             if (savedInstanceState != null) {
@@ -145,12 +143,25 @@
         }
 
         private void highlightPreference() {
-            HighlightableListView list = getView().findViewById(android.R.id.list);
             Preference pref = findPreference(mPreferenceKey);
-            Adapter adapter = list.getAdapter();
-            if (adapter == null) {
+            if (pref == null || getPreferenceScreen() == null) {
                 return;
             }
+            PreferenceScreen screen = getPreferenceScreen();
+            if (Utilities.ATLEAST_OREO) {
+                screen = selectPreferenceRecursive(pref, screen);
+            }
+            if (screen == null) {
+                return;
+            }
+
+            View root = screen.getDialog() != null
+                    ? screen.getDialog().getWindow().getDecorView() : getView();
+            ListView list = root.findViewById(android.R.id.list);
+            if (list == null || list.getAdapter() == null) {
+                return;
+            }
+            Adapter adapter = list.getAdapter();
 
             // Find the position
             int position = -1;
@@ -160,7 +171,7 @@
                     break;
                 }
             }
-            list.highlightPosition(position);
+            new ListViewHighlighter(list, position);
             mPreferenceHighlighted = true;
         }
 
@@ -172,6 +183,25 @@
             }
             super.onDestroy();
         }
+
+        @TargetApi(Build.VERSION_CODES.O)
+        private PreferenceScreen selectPreferenceRecursive(
+                Preference pref, PreferenceScreen topParent) {
+            if (!(pref.getParent() instanceof PreferenceScreen)) {
+                return null;
+            }
+
+            PreferenceScreen parent = (PreferenceScreen) pref.getParent();
+            if (Objects.equals(parent.getKey(), topParent.getKey())) {
+                return parent;
+            } else if (selectPreferenceRecursive(parent, topParent) != null) {
+                ((PreferenceScreen) parent.getParent())
+                        .onItemClick(null, null, parent.getOrder(), 0);
+                return parent;
+            } else {
+                return null;
+            }
+        }
     }
 
     /**
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index 95e1034..278eefd 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -53,6 +53,7 @@
 import com.android.launcher3.shortcuts.ShortcutInfoCompat;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import com.android.launcher3.util.InstantAppResolver;
 import com.android.launcher3.widget.PendingAddShortcutInfo;
 import com.android.launcher3.widget.PendingAddWidgetInfo;
 import com.android.launcher3.widget.WidgetHostViewLoader;
@@ -82,6 +83,7 @@
     private Bundle mWidgetOptions;
 
     private boolean mFinishOnPause = false;
+    private InstantAppResolver mInstantAppResolver;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -95,6 +97,7 @@
 
         mApp = LauncherAppState.getInstance(this);
         mIdp = mApp.getInvariantDeviceProfile();
+        mInstantAppResolver = InstantAppResolver.newInstance(this);
 
         // Use the application context to get the device profile, as in multiwindow-mode, the
         // confirmation activity might be rotated.
@@ -298,7 +301,7 @@
     private void logCommand(int command) {
         getUserEventDispatcher().dispatchUserEvent(newLauncherEvent(
                 newCommandAction(command),
-                newItemTarget(mWidgetCell.getWidgetView()),
+                newItemTarget(mWidgetCell.getWidgetView(), mInstantAppResolver),
                 newContainerTarget(ContainerType.PINITEM)), null);
     }
 }
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
index d68ac15..01b1424 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -15,10 +15,12 @@
  */
 package com.android.launcher3.logging;
 
+import android.content.Context;
 import android.util.ArrayMap;
 import android.util.SparseArray;
 import android.view.View;
 
+import com.android.launcher3.AppInfo;
 import com.android.launcher3.ButtonDropTarget;
 import com.android.launcher3.ItemInfo;
 import com.android.launcher3.LauncherSettings;
@@ -29,6 +31,7 @@
 import com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+import com.android.launcher3.util.InstantAppResolver;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
@@ -127,18 +130,21 @@
         return t;
     }
 
-    public static Target newItemTarget(View v) {
+    public static Target newItemTarget(View v, InstantAppResolver instantAppResolver) {
         return (v.getTag() instanceof ItemInfo)
-                ? newItemTarget((ItemInfo) v.getTag())
+                ? newItemTarget((ItemInfo) v.getTag(), instantAppResolver)
                 : newTarget(Target.Type.ITEM);
     }
 
-    public static Target newItemTarget(ItemInfo info) {
+    public static Target newItemTarget(ItemInfo info, InstantAppResolver instantAppResolver) {
         Target t = newTarget(Target.Type.ITEM);
 
         switch (info.itemType) {
             case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
-                t.itemType = ItemType.APP_ICON;
+                t.itemType = (instantAppResolver != null && info instanceof AppInfo
+                        && instantAppResolver.isInstantApp(((AppInfo) info)) )
+                        ? ItemType.WEB_APP
+                        : ItemType.APP_ICON;
                 t.predictedRank = -100; // Never assigned
                 break;
             case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 627115d..90355bd 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -38,6 +38,7 @@
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+import com.android.launcher3.util.InstantAppResolver;
 import com.android.launcher3.util.LogConfig;
 
 import java.util.Locale;
@@ -78,6 +79,7 @@
         ued.mIsInLandscapeMode = dp.isVerticalBarLayout();
         ued.mIsInMultiWindowMode = dp.isMultiWindowMode;
         ued.mUuidStr = uuidStr;
+        ued.mInstantAppResolver = InstantAppResolver.newInstance(context);
         return ued;
     }
 
@@ -126,6 +128,7 @@
     private boolean mIsInMultiWindowMode;
     private boolean mIsInLandscapeMode;
     private String mUuidStr;
+    protected InstantAppResolver mInstantAppResolver;
 
     //                      APP_ICON    SHORTCUT    WIDGET
     // --------------------------------------------------------------
@@ -151,7 +154,7 @@
 
     public void logAppLaunch(View v, Intent intent) {
         LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP),
-                newItemTarget(v), newTarget(Target.Type.CONTAINER));
+                newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
 
         if (fillInLogContainerData(event, v)) {
             fillIntentInfo(event.srcTarget[0], intent);
@@ -184,7 +187,7 @@
 
     public void logNotificationLaunch(View v, PendingIntent intent) {
         LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.TAP),
-                newItemTarget(v), newTarget(Target.Type.CONTAINER));
+                newItemTarget(v, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
         if (fillInLogContainerData(event, v)) {
             event.srcTarget[0].packageNameHash = (mUuidStr + intent.getCreatorPackage()).hashCode();
         }
@@ -215,7 +218,7 @@
      */
     public void logActionCommand(int command, View itemView, int srcContainerType) {
         LauncherEvent event = newLauncherEvent(newCommandAction(command),
-                newItemTarget(itemView), newTarget(Target.Type.CONTAINER));
+                newItemTarget(itemView, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
 
         if (fillInLogContainerData(event, itemView)) {
             // TODO: Remove the following two lines once fillInLogContainerData can take in a
@@ -320,7 +323,7 @@
         }
         ItemInfo info = (ItemInfo) icon.getTag();
         LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.LONGPRESS),
-                newItemTarget(info), newTarget(Target.Type.CONTAINER));
+                newItemTarget(info, mInstantAppResolver), newTarget(Target.Type.CONTAINER));
         provider.fillInLogContainerData(icon, info, event.srcTarget[0], event.srcTarget[1]);
         dispatchUserEvent(event, null);
 
@@ -338,9 +341,11 @@
 
     public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) {
         LauncherEvent event = newLauncherEvent(newTouchAction(Action.Touch.DRAGDROP),
-                newItemTarget(dragObj.originalDragInfo), newTarget(Target.Type.CONTAINER));
+                newItemTarget(dragObj.originalDragInfo, mInstantAppResolver),
+                newTarget(Target.Type.CONTAINER));
         event.destTarget = new Target[] {
-                newItemTarget(dragObj.originalDragInfo), newDropTarget(dropTargetAsView)
+                newItemTarget(dragObj.originalDragInfo, mInstantAppResolver),
+                newDropTarget(dropTargetAsView)
         };
 
         dragObj.dragSource.fillInLogContainerData(null, dragObj.originalDragInfo,
diff --git a/src/com/android/launcher3/model/ModelWriter.java b/src/com/android/launcher3/model/ModelWriter.java
index 72c703b..eba7515 100644
--- a/src/com/android/launcher3/model/ModelWriter.java
+++ b/src/com/android/launcher3/model/ModelWriter.java
@@ -50,7 +50,6 @@
 public class ModelWriter {
 
     private static final String TAG = "ModelWriter";
-    public static final boolean DEBUG_DELETE = true;
 
     private final Context mContext;
     private final LauncherModel mModel;
@@ -257,14 +256,6 @@
      * Removes the specified items from the database
      */
     public void deleteItemsFromDatabase(final Iterable<? extends ItemInfo> items) {
-        if (DEBUG_DELETE) {
-            // Log it on the colling thread to get the proper stack trace
-            FileLog.d(TAG, "Starting item deletion", new Exception());
-            for (ItemInfo item : items) {
-                FileLog.d(TAG, "deleting item " + item);
-            }
-            FileLog.d(TAG, "Finished deleting items");
-        }
         ModelVerifier verifier = new ModelVerifier();
 
         mWorkerExecutor.execute(() -> {
@@ -282,11 +273,6 @@
      * Remove the specified folder and all its contents from the database.
      */
     public void deleteFolderAndContentsFromDatabase(final FolderInfo info) {
-        if (DEBUG_DELETE) {
-            // Log it on the colling thread to get the proper stack trace
-            FileLog.d(TAG, "Deleting folder " + info, new Exception());
-        }
-
         ModelVerifier verifier = new ModelVerifier();
 
         mWorkerExecutor.execute(() -> {
diff --git a/src/com/android/launcher3/util/ListViewHighlighter.java b/src/com/android/launcher3/util/ListViewHighlighter.java
new file mode 100644
index 0000000..ecad2af
--- /dev/null
+++ b/src/com/android/launcher3/util/ListViewHighlighter.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2018 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.util;
+
+import android.animation.ArgbEvaluator;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.support.v4.graphics.ColorUtils;
+import android.view.View;
+import android.view.View.OnLayoutChangeListener;
+import android.widget.AbsListView;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AbsListView.RecyclerListener;
+import android.widget.ListView;
+
+import com.android.launcher3.R;
+
+/**
+ * Utility class to scroll and highlight a list view item
+ */
+public class ListViewHighlighter implements OnScrollListener, RecyclerListener,
+        OnLayoutChangeListener {
+
+    private final ListView mListView;
+    private int mPosHighlight;
+
+    private boolean mColorAnimated = false;
+
+    public ListViewHighlighter(ListView listView, int posHighlight) {
+        mListView = listView;
+        mPosHighlight = posHighlight;
+        mListView.setOnScrollListener(this);
+        mListView.setRecyclerListener(this);
+        mListView.addOnLayoutChangeListener(this);
+
+        mListView.post(this::tryHighlight);
+    }
+
+    @Override
+    public void onLayoutChange(View v, int left, int top, int right, int bottom,
+            int oldLeft, int oldTop, int oldRight, int oldBottom) {
+        mListView.post(this::tryHighlight);
+    }
+
+    private void tryHighlight() {
+        if (mPosHighlight < 0 || mListView.getChildCount() == 0) {
+            return;
+        }
+        if (!highlightIfVisible(mListView.getFirstVisiblePosition(),
+                mListView.getLastVisiblePosition())) {
+            mListView.smoothScrollToPosition(mPosHighlight);
+        }
+    }
+
+    @Override
+    public void onScrollStateChanged(AbsListView absListView, int i) { }
+
+    @Override
+    public void onScroll(AbsListView view, int firstVisibleItem,
+            int visibleItemCount, int totalItemCount) {
+        highlightIfVisible(firstVisibleItem, firstVisibleItem + visibleItemCount);
+    }
+
+    private boolean highlightIfVisible(int start, int end) {
+        if (mPosHighlight < 0 || mListView.getChildCount() == 0) {
+            return false;
+        }
+        if (start > mPosHighlight || mPosHighlight > end) {
+            return false;
+        }
+        highlightView(mListView.getChildAt(mPosHighlight - start));
+
+        // finish highlight
+        mListView.setOnScrollListener(null);
+        mListView.removeOnLayoutChangeListener(this);
+
+        mPosHighlight = -1;
+        return true;
+    }
+
+    @Override
+    public void onMovedToScrapHeap(View view) {
+        unhighlightView(view);
+    }
+
+    private void highlightView(View view) {
+        if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
+            // already highlighted
+        } else {
+            view.setTag(R.id.view_highlighted, true);
+            view.setTag(R.id.view_unhighlight_background, view.getBackground());
+            view.setBackground(getHighlightBackground());
+            view.postDelayed(() -> {
+                unhighlightView(view);
+            }, 15000L);
+        }
+    }
+
+    private void unhighlightView(View view) {
+        if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
+            Object background = view.getTag(R.id.view_unhighlight_background);
+            if (background instanceof Drawable) {
+                view.setBackground((Drawable) background);
+            }
+            view.setTag(R.id.view_unhighlight_background, null);
+            view.setTag(R.id.view_highlighted, false);
+        }
+    }
+
+    private ColorDrawable getHighlightBackground() {
+        int color = ColorUtils.setAlphaComponent(Themes.getColorAccent(mListView.getContext()), 26);
+        if (mColorAnimated) {
+            return new ColorDrawable(color);
+        }
+        mColorAnimated = true;
+        ColorDrawable bg = new ColorDrawable(Color.WHITE);
+        ObjectAnimator anim = ObjectAnimator.ofInt(bg, "color", Color.WHITE, color);
+        anim.setEvaluator(new ArgbEvaluator());
+        anim.setDuration(200L);
+        anim.setRepeatMode(ValueAnimator.REVERSE);
+        anim.setRepeatCount(4);
+        anim.start();
+        return bg;
+    }
+}
diff --git a/src/com/android/launcher3/util/TraceHelper.java b/src/com/android/launcher3/util/TraceHelper.java
index ac381cc..4aa2f37 100644
--- a/src/com/android/launcher3/util/TraceHelper.java
+++ b/src/com/android/launcher3/util/TraceHelper.java
@@ -24,7 +24,6 @@
 import android.util.Log;
 import android.util.MutableLong;
 
-import com.android.launcher3.Utilities;
 import com.android.launcher3.config.FeatureFlags;
 
 /**
@@ -35,8 +34,7 @@
  */
 public class TraceHelper {
 
-    private static final boolean FORCE_LOG = Utilities.IS_DEBUG_DEVICE;
-    private static final boolean ENABLED = FORCE_LOG || FeatureFlags.IS_DOGFOOD_BUILD;
+    private static final boolean ENABLED = FeatureFlags.IS_DOGFOOD_BUILD;
 
     private static final boolean SYSTEM_TRACE = false;
     private static final ArrayMap<String, MutableLong> sUpTimes = ENABLED ? new ArrayMap<>() : null;
@@ -45,7 +43,7 @@
         if (ENABLED) {
             MutableLong time = sUpTimes.get(sectionName);
             if (time == null) {
-                time = new MutableLong((FORCE_LOG || isLoggable(sectionName, VERBOSE)) ? 0 : -1);
+                time = new MutableLong(isLoggable(sectionName, VERBOSE) ? 0 : -1);
                 sUpTimes.put(sectionName, time);
             }
             if (time.value >= 0) {
diff --git a/src/com/android/launcher3/views/HighlightableListView.java b/src/com/android/launcher3/views/HighlightableListView.java
deleted file mode 100644
index 7da979f..0000000
--- a/src/com/android/launcher3/views/HighlightableListView.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2018 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.views;
-
-import android.animation.ArgbEvaluator;
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.support.v4.graphics.ColorUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.HeaderViewListAdapter;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-
-import com.android.launcher3.R;
-import com.android.launcher3.util.Themes;
-
-import java.util.ArrayList;
-
-/**
- * Extension of list view with support for element highlighting.
- */
-public class HighlightableListView extends ListView {
-
-    private int mPosHighlight = -1;
-    private boolean mColorAnimated = false;
-
-    public HighlightableListView(Context context) {
-        super(context);
-    }
-
-    public HighlightableListView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public HighlightableListView(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-    }
-
-    @Override
-    public void setAdapter(ListAdapter adapter) {
-        super.setAdapter(new HighLightAdapter(adapter));
-    }
-
-    public void highlightPosition(int pos) {
-        if (mPosHighlight == pos) {
-            return;
-        }
-
-        mColorAnimated = false;
-        mPosHighlight = pos;
-        setSelection(mPosHighlight);
-
-        int start = getFirstVisiblePosition();
-        int end = getLastVisiblePosition();
-        if (start <= mPosHighlight && mPosHighlight <= end) {
-            highlightView(getChildAt(mPosHighlight - start));
-        }
-    }
-
-    private void highlightView(View view) {
-        if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
-            // already highlighted
-        } else {
-            view.setTag(R.id.view_highlighted, true);
-            view.setTag(R.id.view_unhighlight_background, view.getBackground());
-            view.setBackground(getHighlightBackground());
-            view.postDelayed(() -> {
-                mPosHighlight = -1;
-                unhighlightView(view);
-            }, 15000L);
-        }
-    }
-
-    private void unhighlightView(View view) {
-        if (Boolean.TRUE.equals(view.getTag(R.id.view_highlighted))) {
-            Object background = view.getTag(R.id.view_unhighlight_background);
-            if (background instanceof Drawable) {
-                view.setBackground((Drawable) background);
-            }
-            view.setTag(R.id.view_unhighlight_background, null);
-            view.setTag(R.id.view_highlighted, false);
-        }
-    }
-
-    private class HighLightAdapter extends HeaderViewListAdapter {
-        public HighLightAdapter(ListAdapter adapter) {
-            super(new ArrayList<>(), new ArrayList<>(), adapter);
-        }
-
-        @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
-            View view =  super.getView(position, convertView, parent);
-
-            if (position == mPosHighlight) {
-                highlightView(view);
-            } else {
-                unhighlightView(view);
-            }
-            return view;
-        }
-    }
-
-    private ColorDrawable getHighlightBackground() {
-        int color = ColorUtils.setAlphaComponent(Themes.getColorAccent(getContext()), 26);
-        if (mColorAnimated) {
-            return new ColorDrawable(color);
-        }
-        mColorAnimated = true;
-        ColorDrawable bg = new ColorDrawable(Color.WHITE);
-        ObjectAnimator anim = ObjectAnimator.ofInt(bg, "color", Color.WHITE, color);
-        anim.setEvaluator(new ArgbEvaluator());
-        anim.setDuration(200L);
-        anim.setRepeatMode(ValueAnimator.REVERSE);
-        anim.setRepeatCount(4);
-        anim.start();
-        return bg;
-    }
-}