diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 8149f8139c..f082728576 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -1634,15 +1634,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext { mControllers.taskbarEduTooltipController.hide(); } - /** - * Called when we want to open bubblebar when user performs swipes up gesture. - */ - public void onSwipeToOpenBubblebar() { - mControllers.bubbleControllers.ifPresent(controllers -> { - controllers.bubbleStashController.showBubbleBar(/* expandBubbles= */ true); - }); - } - /** Returns {@code true} if Taskbar All Apps is open. */ public boolean isTaskbarAllAppsOpen() { return mControllers.taskbarAllAppsController.isOpen(); diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeController.kt index 2d3642b5c0..4b8924cde6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeController.kt @@ -91,7 +91,7 @@ class BubbleBarSwipeController { when { canUnstash() && swipeState.passedUnstash -> { swipeState.currentState = COLLAPSED - bubbleStashController.showBubbleBar(expandBubbles = false) + bubbleStashController.showBubbleBar(expandBubbles = false, bubbleBarGesture = true) } canStash() && !swipeState.passedUnstash -> { swipeState.currentState = STASHED @@ -103,7 +103,7 @@ class BubbleBarSwipeController { /** Finish tracking swipe gesture. Animate views back to resting state */ fun finish() { if (swipeState.passedUnstash && swipeState.startState in setOf(STASHED, COLLAPSED)) { - bubbleStashController.showBubbleBar(expandBubbles = true) + bubbleStashController.showBubbleBar(expandBubbles = true, bubbleBarGesture = true) } if (animatedSwipeTranslation.value == 0f) { reset() diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 833be61315..378776d0b7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -381,6 +381,7 @@ public class BubbleBarView extends FrameLayout { super.onInitializeAccessibilityNodeInfoInternal(info); // Always show only expand action as the menu is only for collapsed bubble bar info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND); + info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK); info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_dismiss_all, getResources().getString(R.string.bubble_bar_action_dismiss_all))); if (mBubbleBarLocation.isOnLeft(isLayoutRtl())) { @@ -395,10 +396,8 @@ public class BubbleBarView extends FrameLayout { @Override public boolean performAccessibilityActionInternal(int action, @androidx.annotation.Nullable Bundle arguments) { - if (super.performAccessibilityActionInternal(action, arguments)) { - return true; - } - if (action == AccessibilityNodeInfo.ACTION_EXPAND) { + if (action == AccessibilityNodeInfo.ACTION_EXPAND + || action == AccessibilityNodeInfo.ACTION_CLICK) { mController.expandBubbleBar(); return true; } @@ -416,7 +415,7 @@ public class BubbleBarView extends FrameLayout { BubbleBarLocation.UpdateSource.A11Y_ACTION_BAR); return true; } - return false; + return super.performAccessibilityActionInternal(action, arguments); } @SuppressLint("RtlHardcoded") diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index fd08078109..f6c04b1094 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -95,7 +95,6 @@ public class BubbleBarViewController { private TaskbarInsetsController mTaskbarInsetsController; private TaskbarViewPropertiesProvider mTaskbarViewPropertiesProvider; private View.OnClickListener mBubbleClickListener; - private View.OnClickListener mBubbleBarClickListener; private BubbleView.Controller mBubbleViewController; private BubbleBarOverflow mOverflowBubble; @@ -178,13 +177,11 @@ public class BubbleBarViewController { dp -> onBubbleBarConfigurationChanged(/* animate= */ true)); mBubbleBarScaleY.updateValue(1f); mBubbleClickListener = v -> onBubbleClicked((BubbleView) v); - mBubbleBarClickListener = v -> expandBubbleBar(); mBubbleDragController.setupBubbleBarView(mBarView); mOverflowBubble = bubbleControllers.bubbleCreator.createOverflow(mBarView); if (!Flags.enableOptionalBubbleOverflow()) { showOverflow(true); } - mBarView.setOnClickListener(mBubbleBarClickListener); mBarView.addOnLayoutChangeListener( (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged(); @@ -211,7 +208,8 @@ public class BubbleBarViewController { @Override public void expandBubbleBar() { - BubbleBarViewController.this.expandBubbleBar(); + BubbleBarViewController.this.setExpanded( + /* isExpanded= */ true, /* maybeShowEdu*/ true); } @Override @@ -332,7 +330,7 @@ public class BubbleBarViewController { @Override public void flyoutClicked() { interruptAnimationForTouch(); - expandBubbleBar(); + setExpanded(/* isExpanded= */ true, /* maybeShowEdu*/ true); } }; } @@ -360,25 +358,6 @@ public class BubbleBarViewController { mBubbleStashController.onNewBubbleAnimationInterrupted(false, mBarView.getTranslationY()); } - private void expandBubbleBar() { - if (mShouldShowEducation) { - mShouldShowEducation = false; - // Get the bubble bar bounds on screen - Rect bounds = new Rect(); - mBarView.getBoundsOnScreen(bounds); - // Calculate user education reference position in Screen coordinates - Point position = new Point(bounds.centerX(), bounds.top); - // Show user education relative to the reference point - mSystemUiProxy.showUserEducation(position); - } else { - // ensure that the bubble bar has the correct translation. we may have just interrupted - // the animation by touching the bubble bar. - mBubbleBarTranslationY.animateToValue(mBubbleStashController.getBubbleBarTranslationY()) - .start(); - setExpanded(true); - } - } - private void collapseBubbleBar() { setExpanded(false); mBubbleStashController.stashBubbleBar(); @@ -391,6 +370,22 @@ public class BubbleBarViewController { } } + /** Shows the education view if it was previously requested. */ + private boolean maybeShowEduView() { + if (mShouldShowEducation) { + mShouldShowEducation = false; + // Get the bubble bar bounds on screen + Rect bounds = new Rect(); + mBarView.getBoundsOnScreen(bounds); + // Calculate user education reference position in Screen coordinates + Point position = new Point(bounds.centerX(), bounds.top); + // Show user education relative to the reference point + mSystemUiProxy.showUserEducation(position); + return true; + } + return false; + } + /** Notifies that the IME became visible. */ public void onImeVisible() { if (isAnimatingNewBubble()) { @@ -946,13 +941,25 @@ public class BubbleBarViewController { mBarView.setSelectedBubble(newlySelected.getView()); } + /** @see #setExpanded(boolean, boolean) */ + public void setExpanded(boolean isExpanded) { + setExpanded(isExpanded, /* maybeShowEdu= */ false); + } + /** * Sets whether the bubble bar should be expanded (not unstashed, but have the contents * within it expanded). This method notifies SystemUI that the bubble bar is expanded and * showing a selected bubble. This method should ONLY be called from UI events originating * from Launcher. + * + * @param isExpanded whether the bar should be expanded + * @param maybeShowEdu whether we should show the edu view before expanding */ - public void setExpanded(boolean isExpanded) { + public void setExpanded(boolean isExpanded, boolean maybeShowEdu) { + // if we're trying to expand try showing the edu view instead + if (maybeShowEdu && isExpanded && !mBarView.isExpanded() && maybeShowEduView()) { + return; + } if (!mBubbleBarPinning.isAnimating() && isExpanded != mBarView.isExpanded()) { mBarView.setExpanded(isExpanded); adjustTaskbarAndHotseatToBubbleBarState(isExpanded); @@ -1012,7 +1019,11 @@ public class BubbleBarViewController { } } - /** Marks as should show education. */ + /** + * Stores a request to show the education view for later processing when appropriate. + * + * @see #maybeShowEduView() + */ public void prepareToShowEducation() { mShouldShowEducation = true; } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt index d9589bbf12..7c41d1dea4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt @@ -131,7 +131,17 @@ interface BubbleStashController { fun stashBubbleBar() /** Shows the bubble bar, and expands bubbles depending on [expandBubbles]. */ - fun showBubbleBar(expandBubbles: Boolean) + fun showBubbleBar(expandBubbles: Boolean) { + showBubbleBar(expandBubbles = expandBubbles, bubbleBarGesture = false) + } + + /** + * Shows the bubble bar, and expands bubbles depending on [expandBubbles]. + * + * Set [bubbleBarGesture] to true if this request originates from a touch gesture on the bubble + * bar. + */ + fun showBubbleBar(expandBubbles: Boolean, bubbleBarGesture: Boolean) // TODO(b/354218264): Move to BubbleBarViewAnimator /** diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt index 45f55688ef..6a460ab5a6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt @@ -180,8 +180,8 @@ class PersistentBubbleStashController( updateExpandedState(expand = false) } - override fun showBubbleBar(expandBubbles: Boolean) { - updateExpandedState(expandBubbles) + override fun showBubbleBar(expandBubbles: Boolean, bubbleBarGesture: Boolean) { + updateExpandedState(expand = expandBubbles, bubbleBarGesture = bubbleBarGesture) } override fun stashBubbleBarImmediate() { @@ -235,13 +235,14 @@ class PersistentBubbleStashController( // no op since does not have a handle view } - private fun updateExpandedState(expand: Boolean) { + private fun updateExpandedState(expand: Boolean, bubbleBarGesture: Boolean = false) { if (bubbleBarViewController.isHiddenForNoBubbles) { // If there are no bubbles the bar is invisible, nothing to do here. return } if (bubbleBarViewController.isExpanded != expand) { - bubbleBarViewController.isExpanded = expand + val maybeShowEdu = expand && bubbleBarGesture + bubbleBarViewController.setExpanded(expand, maybeShowEdu) } } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt index 22d504f864..37c4ef544f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt @@ -250,8 +250,12 @@ class TransientBubbleStashController( updateStashedAndExpandedState(stash = true, expand = false) } - override fun showBubbleBar(expandBubbles: Boolean) { - updateStashedAndExpandedState(stash = false, expandBubbles) + override fun showBubbleBar(expandBubbles: Boolean, bubbleBarGesture: Boolean) { + updateStashedAndExpandedState( + stash = false, + expand = expandBubbles, + bubbleBarGesture = bubbleBarGesture, + ) } override fun getDiffBetweenHandleAndBarCenters(): Float { @@ -481,7 +485,11 @@ class TransientBubbleStashController( } @VisibleForTesting - fun updateStashedAndExpandedState(stash: Boolean, expand: Boolean) { + fun updateStashedAndExpandedState( + stash: Boolean, + expand: Boolean, + bubbleBarGesture: Boolean = false, + ) { if (bubbleBarViewController.isHiddenForNoBubbles) { // If there are no bubbles the bar and handle are invisible, nothing to do here. return @@ -502,7 +510,8 @@ class TransientBubbleStashController( } } if (bubbleBarViewController.isExpanded != expand) { - bubbleBarViewController.isExpanded = expand + val maybeShowEdu = expand && bubbleBarGesture + bubbleBarViewController.setExpanded(expand, maybeShowEdu) } } diff --git a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java index 778c231056..6b61298eed 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/BubbleBarInputConsumer.java @@ -114,7 +114,8 @@ public class BubbleBarInputConsumer implements InputConsumer { if (isWithinTapTime && !swipeUpOnBubbleHandle && !mPassedTouchSlop && mStashedOrCollapsedOnDown) { // Taps on the handle / collapsed state should open the bar - mBubbleStashController.showBubbleBar(/* expandBubbles= */ true); + mBubbleStashController.showBubbleBar( + /* expandBubbles= */ true, /* bubbleBarGesture= */ true); } break; } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeControllerTest.kt index 2e471b8cdb..024ec4c060 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarSwipeControllerTest.kt @@ -36,6 +36,7 @@ import org.mockito.junit.MockitoRule import org.mockito.kotlin.any import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.atLeastOnce +import org.mockito.kotlin.eq import org.mockito.kotlin.never import org.mockito.kotlin.times import org.mockito.kotlin.verify @@ -206,7 +207,7 @@ class BubbleBarSwipeControllerTest { bubbleBarSwipeController.start() bubbleBarSwipeController.swipeTo(UP_ABOVE_UNSTASH) } - verify(bubbleStashController).showBubbleBar(expandBubbles = false) + verify(bubbleStashController).showBubbleBar(expandBubbles = false, bubbleBarGesture = true) } @Test @@ -227,11 +228,12 @@ class BubbleBarSwipeControllerTest { bubbleBarSwipeController.swipeTo(UP_ABOVE_UNSTASH) bubbleBarSwipeController.swipeTo(UP_BELOW_UNSTASH) } - verify(bubbleStashController).showBubbleBar(expandBubbles = false) + verify(bubbleStashController).showBubbleBar(expandBubbles = false, bubbleBarGesture = true) verify(bubbleStashController).stashBubbleBar() getInstrumentation().runOnMainSync { bubbleBarSwipeController.swipeTo(UP_ABOVE_UNSTASH) } - verify(bubbleStashController, times(2)).showBubbleBar(expandBubbles = false) + verify(bubbleStashController, times(2)) + .showBubbleBar(expandBubbles = false, bubbleBarGesture = true) } @Test @@ -241,9 +243,9 @@ class BubbleBarSwipeControllerTest { bubbleBarSwipeController.start() bubbleBarSwipeController.swipeTo(UP_ABOVE_UNSTASH) } - verify(bubbleStashController, never()).showBubbleBar(expandBubbles = true) + verify(bubbleStashController, never()).showBubbleBar(expandBubbles = eq(true), any()) getInstrumentation().runOnMainSync { bubbleBarSwipeController.finish() } - verify(bubbleStashController).showBubbleBar(expandBubbles = true) + verify(bubbleStashController).showBubbleBar(expandBubbles = true, bubbleBarGesture = true) } @Test @@ -253,12 +255,12 @@ class BubbleBarSwipeControllerTest { bubbleBarSwipeController.start() bubbleBarSwipeController.swipeTo(UP_ABOVE_UNSTASH) } - verify(bubbleStashController).showBubbleBar(expandBubbles = false) + verify(bubbleStashController).showBubbleBar(expandBubbles = false, bubbleBarGesture = true) getInstrumentation().runOnMainSync { bubbleBarSwipeController.swipeTo(UP_BELOW_UNSTASH) bubbleBarSwipeController.finish() } - verify(bubbleStashController, never()).showBubbleBar(expandBubbles = true) + verify(bubbleStashController, never()).showBubbleBar(expandBubbles = eq(true), any()) } @Test @@ -334,7 +336,7 @@ class BubbleBarSwipeControllerTest { bubbleBarSwipeController.swipeTo(UP_ABOVE_UNSTASH) bubbleBarSwipeController.finish() } - verify(bubbleStashController).showBubbleBar(expandBubbles = true) + verify(bubbleStashController).showBubbleBar(expandBubbles = true, bubbleBarGesture = true) } @Test diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt index f795ab1a7d..5f3d7de12b 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt @@ -37,6 +37,7 @@ import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule +import org.mockito.kotlin.any import org.mockito.kotlin.clearInvocations import org.mockito.kotlin.never import org.mockito.kotlin.verify @@ -342,6 +343,45 @@ class PersistentBubbleStashControllerTest { verify(taskbarInsetsController, never()).onTaskbarOrBubblebarWindowHeightOrInsetsChanged() } + @Test + fun showBubbleBar_expand_bubbleBarGesture() { + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + whenever(bubbleBarViewController.isExpanded).thenReturn(false) + + persistentTaskBarStashController.showBubbleBar( + expandBubbles = true, + bubbleBarGesture = true, + ) + + verify(bubbleBarViewController).setExpanded(true, true) + } + + @Test + fun showBubbleBar_expand_notBubbleBarGesture() { + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + whenever(bubbleBarViewController.isExpanded).thenReturn(false) + + persistentTaskBarStashController.showBubbleBar( + expandBubbles = true, + bubbleBarGesture = false, + ) + + verify(bubbleBarViewController).setExpanded(true, false) + } + + @Test + fun showBubbleBar_notExpanding_bubbleBarGesture() { + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + whenever(bubbleBarViewController.isExpanded).thenReturn(false) + + persistentTaskBarStashController.showBubbleBar( + expandBubbles = false, + bubbleBarGesture = true, + ) + + verify(bubbleBarViewController, never()).setExpanded(any(), any()) + } + private fun advanceTimeBy(advanceMs: Long) { // Advance animator for on-device tests getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(advanceMs) } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt index 1bbd12a3be..bd5426dbe5 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt @@ -361,6 +361,57 @@ class TransientBubbleStashControllerTest { verify(bubbleBarViewController).setHiddenForStashed(false) } + @Test + fun updateStashedAndExpandedState_expand_bubbleBarGesture() { + mTransientBubbleStashController.isStashed = true + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + whenever(bubbleBarViewController.isExpanded).thenReturn(false) + + getInstrumentation().runOnMainSync { + mTransientBubbleStashController.updateStashedAndExpandedState( + stash = false, + expand = true, + bubbleBarGesture = true, + ) + } + + verify(bubbleBarViewController).setExpanded(true, true) + } + + @Test + fun updateStashedAndExpandedState_expand_notBubbleBarGesture() { + mTransientBubbleStashController.isStashed = true + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + whenever(bubbleBarViewController.isExpanded).thenReturn(false) + + getInstrumentation().runOnMainSync { + mTransientBubbleStashController.updateStashedAndExpandedState( + stash = false, + expand = true, + bubbleBarGesture = false, + ) + } + + verify(bubbleBarViewController).setExpanded(true, false) + } + + @Test + fun updateStashedAndExpandedState_notExpanding_bubbleBarGesture() { + mTransientBubbleStashController.isStashed = true + whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false) + whenever(bubbleBarViewController.isExpanded).thenReturn(false) + + getInstrumentation().runOnMainSync { + mTransientBubbleStashController.updateStashedAndExpandedState( + stash = false, + expand = false, + bubbleBarGesture = true, + ) + } + + verify(bubbleBarViewController, never()).setExpanded(any(), any()) + } + @Test fun isSysuiLockedSwitchedToFalseForOverview_unlockAnimationIsShown() { // Given screen is locked and bubble bar has bubbles