summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ats Jenk <atsjenk@google.com> 2024-05-24 16:02:39 -0700
committer Ats Jenk <atsjenk@google.com> 2024-06-13 15:31:43 -0700
commitfe4a1db2dc7c320a961dff835fdf7c45caf8fdfd (patch)
treeb85ffb7be684aa3a9a72c6144f9bda05ae35e9c0
parent936749e834fcc5677f8ebcae038b5c9f16274ca4 (diff)
Animate bubble overflow when it opens from a shortcut
Flag: com.android.wm.shell.enable_retrievable_bubbles Bug: 340337839 Test: manual Change-Id: Ia1bc4da40ed94b18c40752454e83b539fbc9f870
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java92
1 files changed, 86 insertions, 6 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
index fac9bf6e2a4b..062c1c5210ba 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
@@ -134,6 +134,8 @@ public class BubbleStackView extends FrameLayout
private static final float EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT = 0.1f;
+ private static final float OPEN_OVERFLOW_ANIMATE_SCALE_AMOUNT = 0.5f;
+
private static final int EXPANDED_VIEW_ALPHA_ANIMATION_DURATION = 150;
/** Minimum alpha value for scrim when alpha is being changed via drag */
@@ -1549,10 +1551,20 @@ public class BubbleStackView extends FrameLayout
}
private void updateOverflowVisibility() {
- mBubbleOverflow.setVisible(mShowingOverflow
- && (mIsExpanded || mBubbleData.isShowingOverflow())
- ? VISIBLE
- : GONE);
+ int visibility = GONE;
+ if (mShowingOverflow) {
+ if (mIsExpanded || mBubbleData.isShowingOverflow()) {
+ visibility = VISIBLE;
+ }
+ }
+ if (Flags.enableRetrievableBubbles()) {
+ if (BubbleOverflow.KEY.equals(mBubbleData.getSelectedBubbleKey())
+ && !mBubbleData.hasBubbles()) {
+ // Hide overflow bubble icon if it is the only bubble
+ visibility = GONE;
+ }
+ }
+ mBubbleOverflow.setVisible(visibility);
}
private void updateOverflowDotVisibility(boolean expanding) {
@@ -2147,6 +2159,13 @@ public class BubbleStackView extends FrameLayout
if (mIsExpanded) {
hideCurrentInputMethod();
+ if (Flags.enableRetrievableBubbles()) {
+ if (mBubbleData.getBubbles().size() == 1) {
+ // First bubble, check if overflow visibility needs to change
+ updateOverflowVisibility();
+ }
+ }
+
// Make the container of the expanded view transparent before removing the expanded view
// from it. Otherwise a punch hole created by {@link android.view.SurfaceView} in the
// expanded view becomes visible on the screen. See b/126856255
@@ -2215,6 +2234,16 @@ public class BubbleStackView extends FrameLayout
}
/**
+ * Check if we only have overflow expanded. Which is the case when we are launching bubbles from
+ * background.
+ */
+ private boolean isOnlyOverflowExpanded() {
+ boolean overflowExpanded = mExpandedBubble != null && BubbleOverflow.KEY.equals(
+ mExpandedBubble.getKey());
+ return overflowExpanded && !mBubbleData.hasBubbles();
+ }
+
+ /**
* Monitor for swipe up gesture that is used to collapse expanded view
*/
void startMonitoringSwipeUpGesture() {
@@ -2434,7 +2463,7 @@ public class BubbleStackView extends FrameLayout
ProtoLog.d(WM_SHELL_BUBBLES, "animateExpansion, expandedBubble=%s",
mExpandedBubble != null ? mExpandedBubble.getKey() : "null");
cancelDelayedExpandCollapseSwitchAnimations();
- final boolean showVertically = mPositioner.showBubblesVertically();
+
mIsExpanded = true;
if (isStackEduVisible()) {
mStackEduView.hide(true /* fromExpansion */);
@@ -2444,8 +2473,17 @@ public class BubbleStackView extends FrameLayout
showScrim(true, null /* runnable */);
updateBubbleShadows(mIsExpanded);
mBubbleContainer.setActiveController(mExpandedAnimationController);
- updateBadges(false /* setBadgeForCollapsedStack */);
updateOverflowVisibility();
+
+ if (Flags.enableRetrievableBubbles() && isOnlyOverflowExpanded()) {
+ animateOverflowExpansion();
+ } else {
+ animateBubbleExpansion();
+ }
+ }
+
+ private void animateBubbleExpansion() {
+ updateBadges(false /* setBadgeForCollapsedStack */);
updatePointerPosition(false /* forIme */);
if (Flags.enableBubbleStashing()) {
mBubbleContainer.animate().translationX(0).start();
@@ -2469,6 +2507,7 @@ public class BubbleStackView extends FrameLayout
mExpandedViewContainer.setTranslationY(translationY);
mExpandedViewContainer.setAlpha(1f);
+ final boolean showVertically = mPositioner.showBubblesVertically();
// How far horizontally the bubble will be animating. We'll wait a bit longer for bubbles
// that are animating farther, so that the expanded view doesn't move as much.
final float relevantStackPosition = showVertically
@@ -2561,6 +2600,47 @@ public class BubbleStackView extends FrameLayout
mMainExecutor.executeDelayed(mDelayedAnimation, startDelay);
}
+ /**
+ * Animate expansion of overflow view when it is shown from the bubble shortcut.
+ * <p>
+ * Animates the view with a scale originating from the center of the view.
+ */
+ private void animateOverflowExpansion() {
+ PointF bubbleXY = mPositioner.getExpandedBubbleXY(0, getState());
+ final float translationY = mPositioner.getExpandedViewY(mExpandedBubble,
+ mPositioner.showBubblesVertically() ? bubbleXY.y : bubbleXY.x);
+ mExpandedViewContainer.setTranslationX(0f);
+ mExpandedViewContainer.setTranslationY(translationY);
+ mExpandedViewContainer.setAlpha(1f);
+
+ boolean stackOnLeft = mPositioner.isStackOnLeft(getStackPosition());
+ float width = mPositioner.getTaskViewContentWidth(stackOnLeft);
+ float height = mPositioner.getExpandedViewHeight(mExpandedBubble);
+ float scale = 1f - OPEN_OVERFLOW_ANIMATE_SCALE_AMOUNT;
+ // Scale from the center of the view
+ mExpandedViewContainerMatrix.setScale(scale, scale, width / 2f, height / 2f);
+ mExpandedViewContainer.setAnimationMatrix(mExpandedViewContainerMatrix);
+ mExpandedViewAlphaAnimator.start();
+ PhysicsAnimator.getInstance(mExpandedViewContainerMatrix).cancel();
+ PhysicsAnimator.getInstance(mExpandedViewContainerMatrix)
+ .spring(AnimatableScaleMatrix.SCALE_X,
+ AnimatableScaleMatrix.getAnimatableValueForScaleFactor(1f),
+ mScaleInSpringConfig)
+ .spring(AnimatableScaleMatrix.SCALE_Y,
+ AnimatableScaleMatrix.getAnimatableValueForScaleFactor(1f),
+ mScaleInSpringConfig)
+ .addUpdateListener((target, values) -> {
+ mExpandedViewContainer.setAnimationMatrix(mExpandedViewContainerMatrix);
+ }).withEndActions(() -> {
+ mExpandedViewContainer.setAnimationMatrix(null);
+ afterExpandedViewAnimation();
+ BubbleExpandedView expandedView = getExpandedView();
+ if (expandedView != null) {
+ expandedView.setSurfaceZOrderedOnTop(false);
+ }
+ }).start();
+ }
+
private void animateCollapse() {
cancelDelayedExpandCollapseSwitchAnimations();
ProtoLog.d(WM_SHELL_BUBBLES, "animateCollapse");