diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java index 266d0b9c98..475b51646b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java @@ -212,7 +212,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT * stashed handle to wrap around the hotseat items. */ public Animator createRevealAnimToIsStashed(boolean isStashed, Rect taskbarToHotseatOffsets) { - Rect visualBounds = new Rect(mControllers.taskbarViewController.getIconLayoutBounds()); + Rect visualBounds = mControllers.taskbarViewController.getIconLayoutVisualBounds(); float startRadius = mStashedHandleRadius; if (DisplayController.isTransientTaskbar(mActivity)) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java index 5e7c7cedf4..3b6f46bf2d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java @@ -28,6 +28,7 @@ import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; import com.android.launcher3.anim.AnimatedFloat; +import com.android.launcher3.taskbar.bubbles.BubbleControllers; import com.android.launcher3.util.DisplayController; import com.android.quickstep.SystemUiProxy; import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags; @@ -97,10 +98,20 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa private boolean shouldShowScrim() { final boolean bubblesExpanded = (mSysUiStateFlags & SYSUI_STATE_BUBBLES_EXPANDED) != 0; boolean isShadeVisible = (mSysUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE) != 0; + BubbleControllers bubbleControllers = mActivity.getBubbleControllers(); + boolean isBubbleControllersPresented = bubbleControllers != null; + // when the taskbar is in persistent mode, we hide the task bar icons on bubble bar expand, + // which makes the taskbar invisible, so need to check if the bubble bar is not on home + // to show the scrim view + boolean showScrimForBubbles = bubblesExpanded + && !mTaskbarVisible + && isBubbleControllersPresented + && !DisplayController.isTransientTaskbar(mActivity) + && !bubbleControllers.bubbleStashController.isBubblesShowingOnHome(); return bubblesExpanded && !mControllers.navbarButtonsViewController.isImeVisible() && !isShadeVisible && !mControllers.taskbarStashController.isStashed() - && mTaskbarVisible; + && (mTaskbarVisible || showScrimForBubbles); } private float getScrimAlpha() { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index e58069a7e4..fc76972105 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -669,8 +669,20 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar return isShown() && mIconLayoutBounds.contains(xInOurCoordinates, yInOurCoorindates); } + /** + * Gets visual bounds of the taskbar view. The visual bounds correspond to the taskbar touch + * area, rather than layout placement in the parent view. + */ + public Rect getIconLayoutVisualBounds() { + return new Rect(mIconLayoutBounds); + } + + /** Gets taskbar layout bounds in parent view. */ public Rect getIconLayoutBounds() { - return mIconLayoutBounds; + Rect actualBounds = new Rect(mIconLayoutBounds); + actualBounds.top = getTop(); + actualBounds.bottom = getBottom(); + return actualBounds; } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index ffa481988f..b8b85d120a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -96,7 +96,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar public static final int ALPHA_INDEX_NOTIFICATION_EXPANDED = 4; public static final int ALPHA_INDEX_ASSISTANT_INVOKED = 5; public static final int ALPHA_INDEX_SMALL_SCREEN = 6; - private static final int NUM_ALPHA_CHANNELS = 7; + + public static final int ALPHA_INDEX_BUBBLE_BAR = 7; + private static final int NUM_ALPHA_CHANNELS = 8; private static boolean sEnableModelLoadingForTests = true; @@ -272,6 +274,10 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar OneShotPreDrawListener.add(mTaskbarView, listener); } + public Rect getIconLayoutVisualBounds() { + return mTaskbarView.getIconLayoutVisualBounds(); + } + public Rect getIconLayoutBounds() { return mTaskbarView.getIconLayoutBounds(); } @@ -462,14 +468,14 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar if (mControllers.getSharedState().startTaskbarVariantIsTransient) { float transY = mTransientTaskbarDp.taskbarBottomMargin + (mTransientTaskbarDp.taskbarHeight - - mTaskbarView.getIconLayoutBounds().bottom) + - mTaskbarView.getIconLayoutVisualBounds().bottom) - (mPersistentTaskbarDp.taskbarHeight - mTransientTaskbarDp.taskbarIconSize) / 2f; taskbarIconTranslationYForPinningValue = mapRange(scale, 0f, transY); } else { float transY = -mTransientTaskbarDp.taskbarBottomMargin + (mPersistentTaskbarDp.taskbarHeight - - mTaskbarView.getIconLayoutBounds().bottom) + - mTaskbarView.getIconLayoutVisualBounds().bottom) - (mTransientTaskbarDp.taskbarHeight - mTransientTaskbarDp.taskbarIconSize) / 2f; taskbarIconTranslationYForPinningValue = mapRange(scale, transY, 0f); diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 4d0cad228e..a2746df3d9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -661,13 +661,25 @@ public class BubbleBarView extends FrameLayout { return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY(); } - /** - * Updates the bounds with translation that may have been applied and returns the result. - */ + /** Returns the bounds with translation that may have been applied. */ public Rect getBubbleBarBounds() { - mBubbleBarBounds.top = getTop() + (int) getTranslationY() + mPointerSize; - mBubbleBarBounds.bottom = getBottom() + (int) getTranslationY(); - return mBubbleBarBounds; + Rect bounds = new Rect(mBubbleBarBounds); + bounds.top = getTop() + (int) getTranslationY() + mPointerSize; + bounds.bottom = getBottom() + (int) getTranslationY(); + return bounds; + } + + /** Returns the expanded bounds with translation that may have been applied. */ + public Rect getBubbleBarExpandedBounds() { + Rect expandedBounds = getBubbleBarBounds(); + if (!isExpanded() || isExpanding()) { + if (mBubbleBarLocation.isOnLeft(isLayoutRtl())) { + expandedBounds.right = expandedBounds.left + (int) expandedWidth(); + } else { + expandedBounds.left = expandedBounds.right - (int) expandedWidth(); + } + } + return expandedBounds; } /** @@ -1279,6 +1291,13 @@ public class BubbleBarView extends FrameLayout { return mIsBarExpanded; } + /** + * Returns whether the bubble bar is expanding. + */ + public boolean isExpanding() { + return mWidthAnimator.isRunning() && mIsBarExpanded; + } + /** * Get width of the bubble bar as if it would be expanded. * diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 2cdc0ced86..3e8cd50c77 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -72,6 +72,7 @@ public class BubbleBarViewController { private BubbleDragController mBubbleDragController; private TaskbarStashController mTaskbarStashController; private TaskbarInsetsController mTaskbarInsetsController; + private TaskbarViewPropertiesProvider mTaskbarViewPropertiesProvider; private View.OnClickListener mBubbleClickListener; private View.OnClickListener mBubbleBarClickListener; private BubbleView.Controller mBubbleViewController; @@ -110,13 +111,16 @@ public class BubbleBarViewController { R.dimen.bubblebar_icon_size); } - public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers) { + /** Initializes controller. */ + public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers, + TaskbarViewPropertiesProvider taskbarViewPropertiesProvider) { mBubbleStashController = bubbleControllers.bubbleStashController; mBubbleBarController = bubbleControllers.bubbleBarController; mBubbleDragController = bubbleControllers.bubbleDragController; mTaskbarStashController = controllers.taskbarStashController; mTaskbarInsetsController = controllers.taskbarInsetsController; mBubbleBarViewAnimator = new BubbleBarViewAnimator(mBarView, mBubbleStashController); + mTaskbarViewPropertiesProvider = taskbarViewPropertiesProvider; onBubbleBarConfigurationChanged(/* animate= */ false); mActivity.addOnDeviceProfileChangeListener( dp -> onBubbleBarConfigurationChanged(/* animate= */ true)); @@ -347,6 +351,7 @@ public class BubbleBarViewController { if (hidden) { mBarView.setAlpha(0); mBarView.setExpanded(false); + updatePersistentTaskbar(/* isBubbleBarExpanded = */ false); } mActivity.bubbleBarVisibilityChanged(!hidden); } @@ -611,6 +616,7 @@ public class BubbleBarViewController { public void setExpanded(boolean isExpanded) { if (isExpanded != mBarView.isExpanded()) { mBarView.setExpanded(isExpanded); + updatePersistentTaskbar(isExpanded); if (!isExpanded) { mSystemUiProxy.collapseBubbles(); } else { @@ -621,6 +627,25 @@ public class BubbleBarViewController { } } + private void updatePersistentTaskbar(boolean isBubbleBarExpanded) { + if (mBubbleStashController.isTransientTaskBar()) return; + boolean hideTaskbar = isBubbleBarExpanded && isIntersectingTaskbar(); + mTaskbarViewPropertiesProvider + .getIconsAlpha() + .animateToValue(hideTaskbar ? 0 : 1) + .start(); + } + + /** Return {@code true} if expanded bubble bar would intersect the taskbar. */ + public boolean isIntersectingTaskbar() { + if (mBarView.isExpanding() || mBarView.isExpanded()) { + Rect taskbarViewBounds = mTaskbarViewPropertiesProvider.getTaskbarViewBounds(); + return mBarView.getBubbleBarExpandedBounds().intersect(taskbarViewBounds); + } else { + return false; + } + } + /** * Sets whether the bubble bar should be expanded. This method is used in response to UI events * from SystemUI. @@ -750,4 +775,14 @@ public class BubbleBarViewController { pw.println(" Bubble bar view is null!"); } } + + /** Interface for BubbleBarViewController to get the taskbar view properties. */ + public interface TaskbarViewPropertiesProvider { + + /** Returns the bounds of the taskbar. */ + Rect getTaskbarViewBounds(); + + /** Returns taskbar icons alpha */ + MultiPropertyFactory.MultiProperty getIconsAlpha(); + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleControllers.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleControllers.java index 8478dc2171..e00916af6c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleControllers.java @@ -15,8 +15,15 @@ */ package com.android.launcher3.taskbar.bubbles; +import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_BUBBLE_BAR; + +import android.graphics.Rect; +import android.view.View; + import com.android.launcher3.taskbar.TaskbarControllers; +import com.android.launcher3.taskbar.bubbles.BubbleBarViewController.TaskbarViewPropertiesProvider; import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController; +import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.RunnableList; import java.io.PrintWriter; @@ -79,7 +86,20 @@ public class BubbleControllers { bubbleStashedHandleViewController.orElse(null), taskbarControllers::runAfterInit ); - bubbleBarViewController.init(taskbarControllers, /* bubbleControllers = */ this); + bubbleBarViewController.init(taskbarControllers, /* bubbleControllers = */ this, + new TaskbarViewPropertiesProvider() { + @Override + public Rect getTaskbarViewBounds() { + return taskbarControllers.taskbarViewController.getIconLayoutBounds(); + } + + @Override + public MultiPropertyFactory.MultiProperty getIconsAlpha() { + return taskbarControllers.taskbarViewController + .getTaskbarIconAlpha() + .get(ALPHA_INDEX_BUBBLE_BAR); + } + }); bubbleDragController.init(/* bubbleControllers = */ this); bubbleDismissController.init(/* bubbleControllers = */ this); bubbleBarPinController.init(this);