Merge "Remove associated task views if task is removed while Overview is showing" into ub-launcher3-edmonton
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 13f41ee..70e545f 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
index 7c69a8d..6fece31 100644
--- a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
@@ -153,8 +153,13 @@
                 AbstractFloatingView.closeOpenViews(activity, true,
                         AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
 
+                final int navBarPosition = WindowManagerWrapper.getInstance().getNavBarPosition();
+                if (navBarPosition == WindowManagerWrapper.NAV_BAR_POS_INVALID) {
+                    return;
+                }
+                boolean dockTopOrLeft = navBarPosition != WindowManagerWrapper.NAV_BAR_POS_LEFT;
                 if (ActivityManagerWrapper.getInstance().startActivityFromRecents(taskId,
-                        ActivityOptionsCompat.makeSplitScreenOptions(true))) {
+                        ActivityOptionsCompat.makeSplitScreenOptions(dockTopOrLeft))) {
                     ISystemUiProxy sysUiProxy = RecentsModel.getInstance(activity).getSystemUiProxy();
                     try {
                         sysUiProxy.onSplitScreenInvoked();
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index c866880..c35ab97 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -192,8 +192,10 @@
             mCurrentFilter = new ColorMatrix();
         }
 
-        Themes.setColorScaleOnMatrix(getTextColor(), mSrcFilter);
-        Themes.setColorScaleOnMatrix(targetColor, mDstFilter);
+        int defaultTextColor = mOriginalTextColor.getDefaultColor();
+        Themes.setColorChangeOnMatrix(defaultTextColor, getTextColor(), mSrcFilter);
+        Themes.setColorChangeOnMatrix(defaultTextColor, targetColor, mDstFilter);
+
         ValueAnimator anim1 = ValueAnimator.ofObject(
                 new FloatArrayEvaluator(mCurrentFilter.getArray()),
                 mSrcFilter.getArray(), mDstFilter.getArray());
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index 89597b9..d225093 100644
--- a/src/com/android/launcher3/util/Themes.java
+++ b/src/com/android/launcher3/util/Themes.java
@@ -78,4 +78,23 @@
         target.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
                 Color.blue(color) / 255f, Color.alpha(color) / 255f);
     }
+
+    /**
+     * Changes a color matrix such that, when applied to srcColor, it produces dstColor.
+     *
+     * Note that values on the last column of target ColorMatrix can be negative, and may result in
+     * negative values when applied on a color. Such negative values will be automatically shifted
+     * up to 0 by the framework.
+     *
+     * @param srcColor The color to start from
+     * @param dstColor The color to create by applying target on srcColor
+     * @param target The ColorMatrix to transform the color
+     */
+    public static void setColorChangeOnMatrix(int srcColor, int dstColor, ColorMatrix target) {
+        target.reset();
+        target.getArray()[4] = Color.red(dstColor) - Color.red(srcColor);
+        target.getArray()[9] = Color.green(dstColor) - Color.green(srcColor);
+        target.getArray()[14] = Color.blue(dstColor) - Color.blue(srcColor);
+        target.getArray()[19] = Color.alpha(dstColor) - Color.alpha(srcColor);
+    }
 }