Adds DynamicAnimation-based movement to the bubbles.
See go/bubble-stack-design for a high level overview of these changes. This is a large CL, but required in order to allow continued development and team testing without breaking functionality over the course of multiple CL submissions.
To integrate the new animations, the following changes have been made to existing code:
* (BubbleStackView) The bubble container (and thus, the stack view) are MATCH_PARENT to allow the bubbles to independently translate anywhere on the screen.
* (BubbleStackView) Start position is set by the stack controller, not BubbleStackView.
* (BubbleStackView) Expand positon is set by the expansion controller, not BubbleStackView.
* (BubbleStackView/BubbleTouchHandler) Added the methods onDragStart/onDragged/onDragFinish, and onBubbleDragStart/onBubbleDragged/onBubbleDragFinish, for cleaner dispatch of touch events to the appropriate animation controller.
* (BubbleStackView/BubbleController) The stack view's getBoundsOnScreen returns the first bubble's bounds, if the stack is not expanded.
* (BubbleStackView) applyCurrentState no longer manages translation of bubbles, or the expanded view, these are controlled by animation.
* (BubbleMovementHelper) Deleted, no longer needed.
* (Everywhere) Changed uses of Point to PointF, since translation values are floats anyway.
Known issues to be fixed in subsequent, far smaller CLs:
* (b/123022862) Bubble dragging out/dismissing is not animated, and the bubbles can be deposited anywhere. Tap outside the stack to collapse them back to normal.
* (b/123023502) New bubbles added while the stack is expanded are not positioned properly.
* (b/123022982) Expanded view arrow is sometimes in the wrong position.
* (b/123023410) If the stack is expanded while animating, it collapses to its original position even if not along the edge of the screen.
* (b/123023904) The expanded view doesn't animate out, it disappears instantly.
* (b/123026584) Bounds in landscape are a bit wonky.
Bug: 111236845
Test: atest SystemUITests
Test: physics-animation-testing.md
Change-Id: Icaca09e5db89c635c9bb7ca82d7d2714362e344e
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index a457dee..b7bee30 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -18,9 +18,8 @@
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-import static com.android.systemui.bubbles.BubbleMovementHelper.EDGE_OVERLAP;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.NotificationAlertingManager.alertAgain;
@@ -229,10 +228,6 @@
}
mStackView.stackDismissed();
- // Reset the position of the stack (TODO - or should we save / respect last user position?)
- Point startPoint = getStartPoint(mStackView.getStackWidth(), mDisplaySize);
- mStackView.setPosition(startPoint.x, startPoint.y);
-
updateVisibility();
mNotificationEntryManager.updateNotifications();
}
@@ -249,16 +244,14 @@
BubbleView bubble = mBubbles.get(notif.key);
mStackView.updateBubble(bubble, notif, updatePosition);
} else {
- boolean setPosition = mStackView != null && mStackView.getVisibility() != VISIBLE;
if (mStackView == null) {
- setPosition = true;
mStackView = new BubbleStackView(mContext);
ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
// XXX: Bug when you expand the shade on top of expanded bubble, there is no scrim
// between bubble and the shade
int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1;
sbv.addView(mStackView, bubblePosition,
- new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
+ new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
if (mExpandListener != null) {
mStackView.setExpandListener(mExpandListener);
}
@@ -273,11 +266,6 @@
}
mBubbles.put(bubble.getKey(), bubble);
mStackView.addBubble(bubble);
- if (setPosition) {
- // Need to add the bubble to the stack before we can know the width
- Point startPoint = getStartPoint(mStackView.getStackWidth(), mDisplaySize);
- mStackView.setPosition(startPoint.x, startPoint.y);
- }
}
updateVisibility();
}
@@ -423,24 +411,6 @@
return mStackView;
}
- // TODO: factor in PIP location / maybe last place user had it
- /**
- * Gets an appropriate starting point to position the bubble stack.
- */
- private static Point getStartPoint(int size, Point displaySize) {
- final int x = displaySize.x - size + EDGE_OVERLAP;
- final int y = displaySize.y / 4;
- return new Point(x, y);
- }
-
- /**
- * Gets an appropriate position for the bubble when the stack is expanded.
- */
- static Point getExpandPoint(BubbleStackView view, int size, Point displaySize) {
- // Same place for now..
- return new Point(EDGE_OVERLAP, size);
- }
-
/**
* Whether the notification has been developer configured to bubble and is allowed by the user.
*/