Fix bubble bar flicker in initial animation
When the first bubble animates in we make the bubble bar visible
before translating it below the screen to prepare for the spring
animation. This change defers updating the visibility letting the
animator notify when it's safe to update visibility.
Flag: com.android.wm.shell.enable_bubble_bar
Fixes: 382296842
Test: atest BubbleBarViewAnimatorTest
Test: manual
- dismiss bubble bar
- send new bubble
- observe bubble bar does not flicker
Change-Id: Ib611771dd9f315ab57ef00f8f6cb982b8b88ea73
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
index 987937e..5b3c233 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
@@ -405,8 +405,12 @@
mBubbleBarViewController.showOverflow(true);
}
- // Adds and removals have happened, update visibility before any other visual changes.
- mBubbleBarViewController.setHiddenForBubbles(mBubbles.isEmpty());
+ // Update the visibility if this is the initial state or if there are no bubbles.
+ // If this is the initial bubble, the bubble bar will become visible as part of the
+ // animation.
+ if (update.initialState || mBubbles.isEmpty()) {
+ mBubbleBarViewController.setHiddenForBubbles(mBubbles.isEmpty());
+ }
mBubbleStashedHandleViewController.ifPresent(
controller -> controller.setHiddenForBubbles(mBubbles.isEmpty()));
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 67d7901..9b8fc18 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -170,7 +170,8 @@
mBubbleBarContainer, createFlyoutPositioner(), createFlyoutCallbacks());
mBubbleBarViewAnimator = new BubbleBarViewAnimator(
mBarView, mBubbleStashController, mBubbleBarFlyoutController,
- createBubbleBarParentViewController(), mBubbleBarController::showExpandedView);
+ createBubbleBarParentViewController(), mBubbleBarController::showExpandedView,
+ () -> setHiddenForBubbles(false));
mTaskbarViewPropertiesProvider = taskbarViewPropertiesProvider;
onBubbleBarConfigurationChanged(/* animate= */ false);
mActivity.addOnDeviceProfileChangeListener(
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt
index f5a6655..a40013c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt
@@ -42,6 +42,7 @@
private val bubbleBarFlyoutController: BubbleBarFlyoutController,
private val bubbleBarParentViewHeightUpdateNotifier: BubbleBarParentViewHeightUpdateNotifier,
private val onExpanded: Runnable,
+ private val onBubbleBarVisible: Runnable,
private val scheduler: Scheduler = HandlerScheduler(bubbleBarView),
) {
@@ -397,6 +398,7 @@
// prepare the bubble bar for the animation
bubbleBarView.translationY = bubbleBarView.height.toFloat()
bubbleBarView.visibility = VISIBLE
+ onBubbleBarVisible.run()
bubbleBarView.alpha = 1f
bubbleBarView.scaleX = 1f
bubbleBarView.scaleY = 1f
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt
index 29d142f..465aa5d 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt
@@ -23,6 +23,7 @@
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.View
+import android.view.View.INVISIBLE
import android.view.View.VISIBLE
import android.widget.FrameLayout
import android.widget.TextView
@@ -78,7 +79,7 @@
private lateinit var flyoutContainer: FrameLayout
private lateinit var bubbleStashController: BubbleStashController
private lateinit var flyoutController: BubbleBarFlyoutController
- private val onExpandedNoOp = Runnable {}
+ private val emptyRunnable = Runnable {}
private val flyoutView: View?
get() = flyoutContainer.findViewById(R.id.bubble_bar_flyout_view)
@@ -106,7 +107,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -162,7 +164,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -217,7 +220,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -264,7 +268,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -316,7 +321,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -355,7 +361,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -401,7 +408,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -453,7 +461,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -504,17 +513,21 @@
val barAnimator = PhysicsAnimator.getInstance(bubbleBarView)
+ var notifiedBubbleBarVisible = false
+ val onBubbleBarVisible = Runnable { notifiedBubbleBarVisible = true }
val animator =
BubbleBarViewAnimator(
bubbleBarView,
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = onBubbleBarVisible,
animatorScheduler,
)
InstrumentationRegistry.getInstrumentation().runOnMainSync {
+ bubbleBarView.visibility = INVISIBLE
animator.animateToInitialState(bubble, isInApp = true, isExpanding = false)
}
@@ -542,6 +555,8 @@
assertThat(bubbleBarView.alpha).isEqualTo(0)
assertThat(handle.translationY).isEqualTo(0)
assertThat(handle.alpha).isEqualTo(1)
+ assertThat(bubbleBarView.visibility).isEqualTo(VISIBLE)
+ assertThat(notifiedBubbleBarVisible).isTrue()
verify(bubbleStashController).stashBubbleBarImmediate()
}
@@ -567,7 +582,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -603,7 +619,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -649,7 +666,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -699,7 +717,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -747,7 +766,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -803,7 +823,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -858,7 +879,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -923,7 +945,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -983,7 +1006,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1053,7 +1077,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1129,7 +1154,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1216,7 +1242,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1330,7 +1357,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)