Don't crop bubble flyout in overview

When switching to overview we set the taskbar window size as part
of the taskbar animation. If a bubble is animating the window size
becomes too small and the bubble flyout gets cropped. This change
avoids updating the window size in the middle of a bubble animation.

Flag: com.android.wm.shell.enable_bubble_bar
Fixes: 377809168
Test: manual
       - create a bubble and wait for the flyout to show
       - switch to overview
       - observe the flyout is not cropped
Change-Id: Ic0a3f2c0fc534162ae5583e744a7bc400c3d921b
This commit is contained in:
Liran Binyamin
2024-11-08 11:55:27 -05:00
parent 495fe1d255
commit 0de5987efb
2 changed files with 40 additions and 6 deletions
@@ -196,6 +196,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private boolean mIsFullscreen;
// The size we should return to when we call setTaskbarWindowFullscreen(false)
private int mLastRequestedNonFullscreenSize;
/**
* When this is true, the taskbar window size is not updated. Requests to update the window
* size are stored in {@link #mLastRequestedNonFullscreenSize} and will take effect after
* bubbles no longer animate and {@link #setTaskbarWindowForAnimatingBubble()} is called.
*/
private boolean mIsTaskbarSizeFrozenForAnimatingBubble;
private NavigationMode mNavMode;
private boolean mImeDrawsImeNavBar;
@@ -496,6 +502,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
return getBubbleControllers() != null && BubbleBarController.isBubbleBarEnabled();
}
private boolean isBubbleBarAnimating() {
return mControllers
.bubbleControllers
.map(controllers -> controllers.bubbleBarViewController.isAnimatingNewBubble())
.orElse(false);
}
/**
* Returns if software keyboard is docked or input toolbar is placed at the taskbar area
*/
@@ -1061,6 +1074,25 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
setTaskbarWindowSize(fullscreen ? MATCH_PARENT : mLastRequestedNonFullscreenSize);
}
/**
* Updates the taskbar window size according to whether bubbles are animating.
*
* <p>This method should be called when bubbles start animating and again after the animation is
* complete.
*/
public void setTaskbarWindowForAnimatingBubble() {
if (isBubbleBarAnimating()) {
// the default window size accounts for the bubble flyout
setTaskbarWindowSize(getDefaultTaskbarWindowSize());
mIsTaskbarSizeFrozenForAnimatingBubble = true;
} else {
mIsTaskbarSizeFrozenForAnimatingBubble = false;
setTaskbarWindowSize(
mLastRequestedNonFullscreenSize != 0
? mLastRequestedNonFullscreenSize : getDefaultTaskbarWindowSize());
}
}
/**
* Called when drag ends or when a view is removed from the DragLayer.
*/
@@ -1097,11 +1129,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
size = mDeviceProfile.heightPx;
} else {
mLastRequestedNonFullscreenSize = size;
if (mIsFullscreen) {
// We still need to be fullscreen, so defer any change to our height until we call
// setTaskbarWindowFullscreen(false). For example, this could happen when dragging
// from the gesture region, as the drag will cancel the gesture and reset launcher's
// state, which in turn normally would reset the taskbar window height as well.
if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) {
// We either still need to be fullscreen or a bubble is still animating, so defer
// any change to our height until setTaskbarWindowFullscreen(false) is called or
// setTaskbarWindowForAnimatingBubble() is called after the bubble animation
// completed. For example, this could happen when dragging from the gesture region,
// as the drag will cancel the gesture and reset launcher's state, which in turn
// normally would reset the taskbar window height as well.
return;
}
}