Hide taskbar when certain floating views are open

Test: Open widgets, ensure taskbar hides
Bug: 171917176
Change-Id: Ib78182fe0ca1ea5ffbd28ab42f49ab8f0e535a18
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java
index 744339b..3ae8581 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java
@@ -19,7 +19,7 @@
 import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
 
-import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
+import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_TASKBAR;
 import static com.android.launcher3.AbstractFloatingView.TYPE_REPLACE_TASKBAR_WITH_HOTSEAT;
 import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
 import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -486,11 +486,15 @@
 
     private void replaceTaskbarWithHotseatOrViceVersa() {
         boolean replaceTaskbarWithHotseat = AbstractFloatingView.getTopOpenViewWithType(mLauncher,
-                TYPE_ALL & TYPE_REPLACE_TASKBAR_WITH_HOTSEAT) != null;
+                TYPE_REPLACE_TASKBAR_WITH_HOTSEAT) != null;
         if (!mLauncher.hasBeenResumed()) {
             replaceTaskbarWithHotseat = false;
         }
         setReplaceTaskbarWithHotseat(replaceTaskbarWithHotseat);
+
+        boolean hideTaskbar = AbstractFloatingView.getTopOpenViewWithType(mLauncher,
+                TYPE_HIDE_TASKBAR) != null;
+        mTaskbarVisibilityController.animateToVisibilityForFloatingView(hideTaskbar ? 0f : 1f);
     }
 
     private void setReplaceTaskbarWithHotseat(boolean replaceTaskbarWithHotseat) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarVisibilityController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarVisibilityController.java
index 715e4ca..2228eba 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarVisibilityController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarVisibilityController.java
@@ -31,6 +31,7 @@
 public class TaskbarVisibilityController {
 
     private static final long IME_VISIBILITY_ALPHA_DURATION = 120;
+    private static final long FLOATING_VIEW_VISIBILITY_ALPHA_DURATION = 120;
 
     private final BaseQuickstepLauncher mLauncher;
     private final TaskbarController.TaskbarVisibilityControllerCallbacks mTaskbarCallbacks;
@@ -44,6 +45,8 @@
             this::updateVisibilityAlpha);
     private AnimatedFloat mTaskbarVisibilityAlphaForIme = new AnimatedFloat(
             this::updateVisibilityAlpha);
+    private AnimatedFloat mTaskbarVisibilityAlphaForFloatingView = new AnimatedFloat(
+            this::updateVisibilityAlpha);
 
     public TaskbarVisibilityController(BaseQuickstepLauncher launcher,
             TaskbarController.TaskbarVisibilityControllerCallbacks taskbarCallbacks) {
@@ -59,6 +62,7 @@
         boolean isImeVisible = (SystemUiProxy.INSTANCE.get(mLauncher).getLastSystemUiStateFlags()
                 & QuickStepContract.SYSUI_STATE_IME_SHOWING) != 0;
         mTaskbarVisibilityAlphaForIme.updateValue(isImeVisible ? 0f : 1f);
+        mTaskbarVisibilityAlphaForFloatingView.updateValue(1f);
 
         onTaskbarBackgroundAlphaChanged();
         updateVisibilityAlpha();
@@ -82,6 +86,11 @@
                 .setDuration(IME_VISIBILITY_ALPHA_DURATION).start();
     }
 
+    protected void animateToVisibilityForFloatingView(float toAlpha) {
+        mTaskbarVisibilityAlphaForIme.animateToValue(mTaskbarVisibilityAlphaForFloatingView.value,
+                toAlpha).setDuration(FLOATING_VIEW_VISIBILITY_ALPHA_DURATION).start();
+    }
+
     private void onTaskbarBackgroundAlphaChanged() {
         mTaskbarCallbacks.updateTaskbarBackgroundAlpha(mTaskbarBackgroundAlpha.value);
         updateVisibilityAlpha();
@@ -93,7 +102,8 @@
         // LauncherState if Launcher is paused.
         float alphaDueToLauncher = Math.max(mTaskbarBackgroundAlpha.value,
                 mTaskbarVisibilityAlphaForLauncherState.value);
-        float alphaDueToOther = mTaskbarVisibilityAlphaForIme.value;
+        float alphaDueToOther = mTaskbarVisibilityAlphaForIme.value
+                * mTaskbarVisibilityAlphaForFloatingView.value;
         float taskbarAlpha = alphaDueToLauncher * alphaDueToOther;
         mTaskbarCallbacks.updateTaskbarVisibilityAlpha(taskbarAlpha);
 
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index e263c7a..d894bb4 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -101,6 +101,10 @@
     // When these types of floating views are open, hide the taskbar hotseat and show the real one.
     public static final int TYPE_REPLACE_TASKBAR_WITH_HOTSEAT = TYPE_FOLDER | TYPE_ACTION_POPUP;
 
+    // Hide the taskbar when these types of floating views are open.
+    public static final int TYPE_HIDE_TASKBAR = TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGETS_FULL_SHEET
+            | TYPE_ON_BOARD_POPUP;
+
     public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE & ~TYPE_LISTENER
             & ~TYPE_ALL_APPS_EDU;