Merge "Hide bubble bar stash handle when the notification shade is open." into main

This commit is contained in:
Mykola Podolian authored and Android (Google) Code Review committed 2025-01-13 11:40:18 -08:00
commit 987de5534e
4 files changed
+67 -5

No files matched your search

@@ -140,6 +140,7 @@ import com.android.launcher3.util.ApplicationInfoWrapper;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.NavigationMode;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SettingsCache;
@@ -194,6 +195,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private WindowManager.LayoutParams mWindowLayoutParams;
private WindowManager.LayoutParams mLastUpdatedLayoutParams;
private boolean mIsFullscreen;
private boolean mIsNotificationShadeExpanded = false;
// The size we should return to when we call setTaskbarWindowFullscreen(false)
private int mLastRequestedNonFullscreenSize;
/**
@@ -1005,6 +1007,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
* Hides the taskbar icons and background when the notification shade is expanded.
*/
private void onNotificationShadeExpandChanged(boolean isExpanded, boolean skipAnim) {
boolean isExpandedUpdated = isExpanded != mIsNotificationShadeExpanded;
mIsNotificationShadeExpanded = isExpanded;
// Close all floating views within the Taskbar window to make sure nothing is shown over
// the notification shade.
if (isExpanded) {
@@ -1018,11 +1022,18 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
anim.play(mControllers.taskbarDragLayerController.getNotificationShadeBgTaskbar()
.animateToValue(alpha));
mControllers.bubbleControllers.ifPresent(controllers -> {
BubbleBarViewController bubbleBarViewController = controllers.bubbleBarViewController;
anim.play(bubbleBarViewController.getBubbleBarAlpha().get(0).animateToValue(alpha));
});
if (isExpandedUpdated) {
mControllers.bubbleControllers.ifPresent(controllers -> {
BubbleBarViewController bubbleBarViewController =
controllers.bubbleBarViewController;
anim.play(bubbleBarViewController.getBubbleBarAlpha().get(0).animateToValue(alpha));
MultiPropertyFactory<View>.MultiProperty handleAlpha =
controllers.bubbleStashController.getHandleViewAlpha();
if (handleAlpha != null) {
anim.play(handleAlpha.animateToValue(alpha));
}
});
}
anim.start();
if (skipAnim) {
anim.end();
@@ -24,6 +24,7 @@ import com.android.launcher3.taskbar.TaskbarInsetsController
import com.android.launcher3.taskbar.bubbles.BubbleBarView
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController
import com.android.launcher3.util.MultiPropertyFactory
import com.android.wm.shell.shared.animation.PhysicsAnimator
import com.android.wm.shell.shared.bubbles.BubbleBarLocation
import java.io.PrintWriter
@@ -172,6 +173,9 @@ interface BubbleStashController {
/** Returns bounds of the handle */
fun getHandleBounds(bounds: Rect)
/** Returns MultiValueAlpha of the handle view when the handle view is shown. */
fun getHandleViewAlpha(): MultiPropertyFactory<View>.MultiProperty? = null
/**
* Returns bubble bar Y position according to [isBubblesShowingOnHome] and
* [isBubblesShowingOnOverview] values. Default implementation only analyse
@@ -512,6 +512,14 @@ class TransientBubbleStashController(
}
}
override fun getHandleViewAlpha(): MultiPropertyFactory<View>.MultiProperty? =
// only return handle alpha if the bubble bar is stashed and has bubbles
if (isStashed && bubbleBarViewController.hasBubbles()) {
stashHandleViewAlpha
} else {
null
}
private fun Animator.updateTouchRegionOnAnimationEnd(): Animator {
doOnEnd { onIsStashedChanged() }
return this
@@ -507,6 +507,45 @@ class TransientBubbleStashControllerTest {
assertThat(height).isEqualTo(BUBBLE_BAR_HEIGHT)
}
@Test
fun getHandleViewAlpha_stashedHasBubbles_alphaPropertyReturned() {
// Given BubbleBar is stashed and has bubbles
whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
mTransientBubbleStashController.isStashed = true
// When handle view alpha property
val alphaProperty = mTransientBubbleStashController.getHandleViewAlpha()
// Then the stash handle alpha property should not be null
assertThat(alphaProperty).isNotNull()
}
@Test
fun getHandleViewAlpha_stashedHasNoBubblesBar_alphaPropertyIsNull() {
// Given BubbleBar is stashed and has no bubbles
whenever(bubbleBarViewController.hasBubbles()).thenReturn(false)
mTransientBubbleStashController.isStashed = true
// When handle view alpha property
val alphaProperty = mTransientBubbleStashController.getHandleViewAlpha()
// Then the stash handle alpha property should be null
assertThat(alphaProperty).isNull()
}
@Test
fun getHandleViewAlpha_unstashedHasBubbles_alphaPropertyIsNull() {
// Given BubbleBar is not stashed and has bubbles
whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
mTransientBubbleStashController.isStashed = false
// When handle view alpha property
val alphaProperty = mTransientBubbleStashController.getHandleViewAlpha()
// Then the stash handle alpha property should be null
assertThat(alphaProperty).isNull()
}
private fun advanceTimeBy(advanceMs: Long) {
// Advance animator for on-device tests
getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(advanceMs) }