Hide task bar icons when notification shade is expanded

Fixes: 199163951
Test: manual
Change-Id: Id2556aa5f08db55059c95d8c13cdc4d46b7d8c55
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 0b6f9c4..0316333 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -20,6 +20,8 @@
 import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
 
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
 import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
 import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
 
@@ -156,7 +158,8 @@
                 MATCH_PARENT,
                 mLastRequestedNonFullscreenHeight,
                 TYPE_NAVIGATION_BAR_PANEL,
-                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
+                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+                        | WindowManager.LayoutParams.FLAG_SLIPPERY,
                 PixelFormat.TRANSLUCENT);
         mWindowLayoutParams.setTitle(WINDOW_TITLE);
         mWindowLayoutParams.packageName = getPackageName();
@@ -311,6 +314,10 @@
                 systemUiStateFlags, forceUpdate);
         mControllers.taskbarViewController.setImeIsVisible(
                 mControllers.navbarButtonsViewController.isImeVisible());
+        boolean panelExpanded = (systemUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) != 0;
+        boolean inSettings = (systemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) != 0;
+        mControllers.taskbarViewController.setNotificationShadeIsExpanded(
+                panelExpanded || inSettings);
         mControllers.taskbarViewController.setRecentsButtonDisabled(
                 mControllers.navbarButtonsViewController.isRecentsDisabled());
         mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index f359a3d..4cd6814 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -49,7 +49,8 @@
     public static final int ALPHA_INDEX_KEYGUARD = 2;
     public static final int ALPHA_INDEX_STASH = 3;
     public static final int ALPHA_INDEX_RECENTS_DISABLED = 4;
-    private static final int NUM_ALPHA_CHANNELS = 5;
+    public static final int ALPHA_INDEX_NOTIFICATION_EXPANDED = 5;
+    private static final int NUM_ALPHA_CHANNELS = 6;
 
     private final TaskbarActivityContext mActivity;
     private final TaskbarView mTaskbarView;
@@ -107,6 +108,16 @@
     }
 
     /**
+     * Should be called when the notification shade is expanded, so we can hide taskbar icons as
+     * well. Note that we are animating icons to appear / disappear.
+     */
+    public void setNotificationShadeIsExpanded(boolean isNotificationShadeExpanded) {
+        mTaskbarIconAlpha.getProperty(ALPHA_INDEX_NOTIFICATION_EXPANDED)
+                .animateToValue(isNotificationShadeExpanded ? 0 : 1)
+                .start();
+    }
+
+    /**
      * Should be called when the recents button is disabled, so we can hide taskbar icons as well.
      */
     public void setRecentsButtonDisabled(boolean isDisabled) {
diff --git a/src/com/android/launcher3/util/MultiValueAlpha.java b/src/com/android/launcher3/util/MultiValueAlpha.java
index 8591872..bd39391 100644
--- a/src/com/android/launcher3/util/MultiValueAlpha.java
+++ b/src/com/android/launcher3/util/MultiValueAlpha.java
@@ -125,10 +125,13 @@
         }
 
         /**
-         * Creates and returns an Animator from the current value to the given value.
+         * Creates and returns an Animator from the current value to the given value. Future
+         * animator on the same target automatically cancels the previous one.
          */
         public Animator animateToValue(float value) {
-            return ObjectAnimator.ofFloat(this, VALUE, value);
+            ObjectAnimator animator = ObjectAnimator.ofFloat(this, VALUE, value);
+            animator.setAutoCancel(true);
+            return animator;
         }
     }
 }