Only send bubble bar top coordinate to shell
Stop sending entire bubble bar bounds to shell.
Keeping the bounds in sync was error prone as bubble bar can expand and
collapse. Bubbles can be added/removed.
In each of these cases we had to make sure that shell gets updated.
Shell only needed the full bounds for collapse/expand animation. But
after updating the animation, shell only needs the top coordinate of the
bubble bar.
Bug: 330585402
Flag: com.android.wm.shell.enable_bubble_bar
Test: bubble bar drag
- drag bar from right to left
- expand the bar
- check that expanded view scales in from left edge
- collapse and drag bar back, check the animation
Test: selected bubble drag
- drag expanded bubble from right to left
- check that expanded view scales in from the left edge
- drag the bubble back to right, check animation
Test: other bubble drag
- drag a unselected bubble from right to left
- check that the selected bubble expands in from left edge
- drag the bubble back to right, check animation again
Test: drag bubble from right to left, observe that expanded view
expand animation originates from the bubble bar
Change-Id: Ib66cef8d3c04bce54a69e30e99edd408a31f018f
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
index 46c2e25..046f5b6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
@@ -31,8 +31,6 @@
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
-import static java.lang.Math.abs;
-
import android.annotation.BinderThread;
import android.annotation.Nullable;
import android.app.Notification;
@@ -47,7 +45,6 @@
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Point;
-import android.graphics.Rect;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -67,7 +64,6 @@
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.launcher3.shortcuts.ShortcutRequest;
-import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors.SimpleThreadFactory;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
@@ -153,8 +149,8 @@
private BubbleStashedHandleViewController mBubbleStashedHandleViewController;
private BubblePinController mBubblePinController;
- // Keep track of bubble bar bounds sent to shell to avoid sending duplicate updates
- private final Rect mLastSentBubbleBarBounds = new Rect();
+ // Cache last sent top coordinate to avoid sending duplicate updates to shell
+ private int mLastSentBubbleBarTop;
/**
* Similar to {@link BubbleBarUpdate} but rather than {@link BubbleInfo}s it uses
@@ -445,9 +441,8 @@
info.getFlags() | Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION);
mSelectedBubble.getView().updateDotVisibility(true /* animate */);
}
- Rect bounds = getExpandedBubbleBarDisplayBounds();
- mLastSentBubbleBarBounds.set(bounds);
- mSystemUiProxy.showBubble(getSelectedBubbleKey(), bounds);
+ mLastSentBubbleBarTop = mBarView.getRestingTopPositionOnScreen();
+ mSystemUiProxy.showBubble(getSelectedBubbleKey(), mLastSentBubbleBarTop);
} else {
Log.w(TAG, "Trying to show the selected bubble but it's null");
}
@@ -636,42 +631,14 @@
return mIconFactory.createBadgedIconBitmap(drawable).icon;
}
- private void onBubbleBarBoundsChanged(Rect newBounds) {
- Rect displayBounds = convertToDisplayBounds(newBounds);
- // Only send bounds over if they changed
- if (!displayBounds.equals(mLastSentBubbleBarBounds)) {
- mLastSentBubbleBarBounds.set(displayBounds);
- mSystemUiProxy.setBubbleBarBounds(displayBounds);
+ private void onBubbleBarBoundsChanged() {
+ int newTop = mBarView.getRestingTopPositionOnScreen();
+ if (newTop != mLastSentBubbleBarTop) {
+ mLastSentBubbleBarTop = newTop;
+ mSystemUiProxy.updateBubbleBarTopOnScreen(newTop);
}
}
- /**
- * Get bounds of the bubble bar as if it would be expanded.
- * Calculates the bounds instead of retrieving current view location as the view may be
- * animating.
- */
- private Rect getExpandedBubbleBarDisplayBounds() {
- return convertToDisplayBounds(mBarView.getBubbleBarBounds());
- }
-
- private Rect convertToDisplayBounds(Rect currentBarBounds) {
- Point displaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
- Rect displayBounds = new Rect();
- // currentBarBounds is only useful for distance from left or right edge.
- // It contains the current bounds, calculate the expanded bounds.
- if (mBarView.getBubbleBarLocation().isOnLeft(mBarView.isLayoutRtl())) {
- displayBounds.left = currentBarBounds.left;
- displayBounds.right = (int) (currentBarBounds.left + mBarView.expandedWidth());
- } else {
- displayBounds.left = (int) (currentBarBounds.right - mBarView.expandedWidth());
- displayBounds.right = currentBarBounds.right;
- }
- final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY());
- displayBounds.top = displaySize.y - currentBarBounds.height() - translation;
- displayBounds.bottom = displaySize.y - translation;
- return displayBounds;
- }
-
/** Interface for checking whether the IME is visible. */
public interface ImeVisibilityChecker {
/** Whether the IME is visible. */
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index f3ac1e4..b8501c3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -43,6 +43,7 @@
import com.android.launcher3.R;
import com.android.launcher3.anim.SpringAnimationBuilder;
+import com.android.launcher3.util.DisplayController;
import com.android.wm.shell.common.bubbles.BubbleBarLocation;
import java.util.List;
@@ -551,6 +552,15 @@
}
/**
+ * Get bubble bar top coordinate on screen when bar is resting
+ */
+ public int getRestingTopPositionOnScreen() {
+ int displayHeight = DisplayController.INSTANCE.get(getContext()).getInfo().currentSize.y;
+ int bubbleBarHeight = getBubbleBarBounds().height();
+ return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY();
+ }
+
+ /**
* Updates the bounds with translation that may have been applied and returns the result.
*/
public Rect getBubbleBarBounds() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 5f75b3b..f614dc6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -93,8 +93,6 @@
@Nullable
private BubbleBarBoundsChangeListener mBoundsChangeListener;
- private final Rect mPreviousBubbleBarBounds = new Rect();
-
public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) {
mActivity = activity;
mBarView = barView;
@@ -122,12 +120,8 @@
mBarView.addOnLayoutChangeListener(
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
- Rect bubbleBarBounds = mBarView.getBubbleBarBounds();
- if (!bubbleBarBounds.equals(mPreviousBubbleBarBounds)) {
- mPreviousBubbleBarBounds.set(bubbleBarBounds);
- if (mBoundsChangeListener != null) {
- mBoundsChangeListener.onBoundsChanged(bubbleBarBounds);
- }
+ if (mBoundsChangeListener != null) {
+ mBoundsChangeListener.onBoundsChanged();
}
});
@@ -497,7 +491,7 @@
* that a bubble is being dragged to dismiss.
* @param bubbleView dragged bubble view
*/
- public void onDragStart(@NonNull BubbleView bubbleView) {
+ public void onBubbleDragStart(@NonNull BubbleView bubbleView) {
if (bubbleView.getBubble() == null) return;
mSystemUiProxy.startBubbleDrag(bubbleView.getBubble().getKey());
@@ -507,20 +501,19 @@
/**
* Notifies SystemUI to expand the selected bubble when the bubble is released.
*/
- public void onDragRelease(BubbleBarLocation location) {
- // TODO(b/330585402): send new bubble bar bounds to shell for the animation
- mSystemUiProxy.stopBubbleDrag(location);
+ public void onBubbleDragRelease(BubbleBarLocation location) {
+ mSystemUiProxy.stopBubbleDrag(location, mBarView.getRestingTopPositionOnScreen());
}
/**
* Notifies {@link BubbleBarView} that drag and all animations are finished.
*/
- public void onDragBubbleEnded() {
+ public void onBubbleDragEnd() {
mBarView.setDraggedBubble(null);
}
/** Notifies that dragging the bubble bar ended. */
- public void onDragBubbleBarEnded() {
+ public void onBubbleBarDragEnd() {
// we may have changed the bubble bar translation Y value from the value it had at the
// beginning of the drag, so update the translation Y animator state
mBubbleBarTranslationY.updateValue(mBarView.getTranslationY());
@@ -576,6 +569,6 @@
*/
public interface BubbleBarBoundsChangeListener {
/** Called when bounds have changed */
- void onBoundsChanged(Rect newBounds);
+ void onBoundsChanged();
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java
index 604ae89..2ebc3e8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java
@@ -97,7 +97,7 @@
@Override
void onDragStart() {
mBubblePinController.setListener(mLocationChangeListener);
- mBubbleBarViewController.onDragStart(bubbleView);
+ mBubbleBarViewController.onBubbleDragStart(bubbleView);
mBubblePinController.onDragStart(
mBubbleBarViewController.getBubbleBarLocation().isOnLeft(
bubbleView.isLayoutRtl()));
@@ -113,7 +113,7 @@
@Override
protected void onDragRelease() {
mBubblePinController.onDragEnd();
- mBubbleBarViewController.onDragRelease(mReleasedLocation);
+ mBubbleBarViewController.onBubbleDragRelease(mReleasedLocation);
}
@Override
@@ -124,7 +124,7 @@
@Override
void onDragEnd() {
mBubbleBarController.updateBubbleBarLocation(mReleasedLocation);
- mBubbleBarViewController.onDragBubbleEnded();
+ mBubbleBarViewController.onBubbleDragEnd();
mBubblePinController.setListener(null);
}
@@ -192,7 +192,7 @@
bubbleBarView.setIsDragging(false);
// Restoring the initial pivot for the bubble bar view
bubbleBarView.setRelativePivot(initialRelativePivot.x, initialRelativePivot.y);
- mBubbleBarViewController.onDragBubbleBarEnded();
+ mBubbleBarViewController.onBubbleBarDragEnd();
mBubbleBarPinController.setListener(null);
}
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index da1d322..0ac3ec7 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -761,12 +761,12 @@
/**
* Tells SysUI to show the bubble with the provided key.
* @param key the key of the bubble to show.
- * @param bubbleBarBounds bounds of the bubble bar in display coordinates
+ * @param top top coordinate of bubble bar on screen
*/
- public void showBubble(String key, Rect bubbleBarBounds) {
+ public void showBubble(String key, int top) {
if (mBubbles != null) {
try {
- mBubbles.showBubble(key, bubbleBarBounds);
+ mBubbles.showBubble(key, top);
} catch (RemoteException e) {
Log.w(TAG, "Failed call showBubble");
}
@@ -815,12 +815,14 @@
/**
* Tells SysUI when the bubble stops being dragged.
* Should be called only when the bubble bar is expanded.
+ *
* @param location location of the bubble bar
+ * @param top new top coordinate for bubble bar on screen
*/
- public void stopBubbleDrag(BubbleBarLocation location) {
+ public void stopBubbleDrag(BubbleBarLocation location, int top) {
if (mBubbles == null) return;
try {
- mBubbles.stopBubbleDrag(location);
+ mBubbles.stopBubbleDrag(location, top);
} catch (RemoteException e) {
Log.w(TAG, "Failed call stopBubbleDrag");
}
@@ -864,16 +866,17 @@
}
/**
- * Tells SysUI the bounds for the bubble bar
- * @param bubbleBarBounds bounds of the bubble bar in display coordinates
+ * Tells SysUI the top coordinate of bubble bar on screen
+ *
+ * @param topOnScreen top coordinate for bubble bar on screen
*/
- public void setBubbleBarBounds(Rect bubbleBarBounds) {
+ public void updateBubbleBarTopOnScreen(int topOnScreen) {
try {
if (mBubbles != null) {
- mBubbles.setBubbleBarBounds(bubbleBarBounds);
+ mBubbles.updateBubbleBarTopOnScreen(topOnScreen);
}
} catch (RemoteException e) {
- Log.w(TAG, "Failed call setBubbleBarBounds");
+ Log.w(TAG, "Failed call updateBubbleBarTopOnScreen");
}
}