Prepare for wiring bubble bar flyout
Implement BubbleBarFlyoutPositioner in BubbleBarViewController
Flag: com.android.wm.shell.enable_bubble_bar
Bug: 277815200
Test: builds successfully -- code is not wired up yet
Change-Id: Ib2d9b1f2f6e972f6ce949e10d50334a501c8c805
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index 7fed381..c5d649e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -1492,6 +1492,38 @@
return bubbles;
}
+ /**
+ * Returns the distance between the top left corner of the bubble bar to the center of the dot
+ * of the selected bubble.
+ */
+ PointF getSelectedBubbleDotDistanceFromTopLeft() {
+ if (mSelectedBubbleView == null) {
+ return new PointF(0, 0);
+ }
+ final int indexOfSelectedBubble = indexOfChild(mSelectedBubbleView);
+ final boolean onLeft = mBubbleBarLocation.isOnLeft(isLayoutRtl());
+ final float selectedBubbleTx = isExpanded()
+ ? getExpandedBubbleTranslationX(indexOfSelectedBubble, getChildCount(), onLeft)
+ : getCollapsedBubbleTranslationX(indexOfSelectedBubble, getChildCount(), onLeft);
+ PointF selectedBubbleDotCenter = mSelectedBubbleView.getDotCenter();
+
+ return new PointF(
+ selectedBubbleTx + selectedBubbleDotCenter.x,
+ mBubbleBarPadding + mPointerSize + selectedBubbleDotCenter.y);
+ }
+
+ int getSelectedBubbleDotColor() {
+ return mSelectedBubbleView == null ? 0 : mSelectedBubbleView.getDotColor();
+ }
+
+ int getPointerSize() {
+ return mPointerSize;
+ }
+
+ float getBubbleElevation() {
+ return mBubbleElevation;
+ }
+
/** Interface for BubbleBarView to communicate with its controller. */
interface Controller {
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index c164eec..da9dcf7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -42,6 +42,7 @@
import com.android.launcher3.taskbar.TaskbarInsetsController;
import com.android.launcher3.taskbar.TaskbarStashController;
import com.android.launcher3.taskbar.bubbles.animation.BubbleBarViewAnimator;
+import com.android.launcher3.taskbar.bubbles.flyout.BubbleBarFlyoutPositioner;
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
@@ -63,6 +64,8 @@
private static final float APP_ICON_SMALL_DP = 44f;
private static final float APP_ICON_MEDIUM_DP = 48f;
private static final float APP_ICON_LARGE_DP = 52f;
+ /** The dot size is defined as a percentage of the icon size. */
+ private static final float DOT_TO_BUBBLE_SIZE_RATIO = 0.228f;
private final SystemUiProxy mSystemUiProxy;
private final TaskbarActivityContext mActivity;
private final BubbleBarView mBarView;
@@ -208,6 +211,59 @@
};
}
+ private BubbleBarFlyoutPositioner createFlyoutPositioner() {
+ return new BubbleBarFlyoutPositioner() {
+
+ @Override
+ public boolean isOnLeft() {
+ return mBarView.getBubbleBarLocation().isOnLeft(mBarView.isLayoutRtl());
+ }
+
+ @Override
+ public float getTargetTy() {
+ return mBarView.getTranslationY() - mBarView.getHeight();
+ }
+
+ @Override
+ @NonNull
+ public PointF getDistanceToCollapsedPosition() {
+ // the flyout animates from the selected bubble dot. calculate the distance it needs
+ // to translate itself to its starting position.
+ PointF distanceToDotCenter = mBarView.getSelectedBubbleDotDistanceFromTopLeft();
+
+ // if we're gravitating left, return the distance between the top left corner of the
+ // bubble bar and the bottom left corner of the dot.
+ // if we're gravitating right, return the distance between the top right corner of
+ // the bubble bar and the bottom right corner of the dot.
+ float distanceX = isOnLeft()
+ ? distanceToDotCenter.x - getCollapsedSize() / 2
+ : mBarView.getWidth() - distanceToDotCenter.x - getCollapsedSize() / 2;
+ float distanceY = distanceToDotCenter.y + getCollapsedSize() / 2;
+ return new PointF(distanceX, distanceY);
+ }
+
+ @Override
+ public float getCollapsedSize() {
+ return mIconSize * DOT_TO_BUBBLE_SIZE_RATIO;
+ }
+
+ @Override
+ public int getCollapsedColor() {
+ return mBarView.getSelectedBubbleDotColor();
+ }
+
+ @Override
+ public float getCollapsedElevation() {
+ return mBarView.getBubbleElevation();
+ }
+
+ @Override
+ public float getDistanceToRevealTriangle() {
+ return getDistanceToCollapsedPosition().y - mBarView.getPointerSize();
+ }
+ };
+ }
+
private void onBubbleClicked(BubbleView bubbleView) {
bubbleView.markSeen();
BubbleBarItem bubble = bubbleView.getBubble();
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java
index 561df5c..707655c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java
@@ -22,6 +22,7 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Path;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
@@ -67,8 +68,7 @@
private float mAnimatingToDotScale;
// The current scale value of the dot
private float mDotScale;
-
- private boolean mProvideShadowOutline = true;
+ private boolean mDotSuppressedForBubbleUpdate = false;
// TODO: (b/273310265) handle RTL
// Whether the bubbles are positioned on the left or right side of the screen
@@ -300,6 +300,10 @@
}
void updateDotVisibility(boolean animate) {
+ if (mDotSuppressedForBubbleUpdate) {
+ // if the dot is suppressed for
+ return;
+ }
final float targetScale = hasUnseenContent() ? 1f : 0f;
if (animate) {
animateDotScale(targetScale);
@@ -317,6 +321,20 @@
}
}
+ /**
+ * Suppresses or un-suppresses drawing the dot due to an update for this bubble.
+ *
+ * <p>If the dot is being suppressed and is already visible, it remains visible because it is
+ * used as a starting point for the animation. If the dot is being unsuppressed, it is
+ * redrawn if needed.
+ */
+ public void suppressDotForBubbleUpdate(boolean suppress) {
+ mDotSuppressedForBubbleUpdate = suppress;
+ if (!suppress) {
+ showDotIfNeeded(/* animate= */ false);
+ }
+ }
+
boolean hasUnseenContent() {
return mBubble != null
&& mBubble instanceof BubbleBarBubble
@@ -353,8 +371,8 @@
}
void showDotIfNeeded(boolean animate) {
- // only show the dot if we have unseen content
- if (!hasUnseenContent()) {
+ // only show the dot if we have unseen content and it's not suppressed
+ if (!hasUnseenContent() || mDotSuppressedForBubbleUpdate) {
return;
}
if (animate) {
@@ -406,6 +424,23 @@
}).start();
}
+ /**
+ * Returns the distance from the top left corner of this bubble view to the center of its dot.
+ */
+ public PointF getDotCenter() {
+ float[] dotPosition =
+ mOnLeft ? mDotRenderer.getLeftDotPosition() : mDotRenderer.getRightDotPosition();
+ getDrawingRect(mTempBounds);
+ float dotCenterX = mTempBounds.width() * dotPosition[0];
+ float dotCenterY = mTempBounds.height() * dotPosition[1];
+ return new PointF(dotCenterX, dotCenterY);
+ }
+
+ /** Returns the dot color. */
+ public int getDotColor() {
+ return mDotColor;
+ }
+
@Override
public String toString() {
String toString = mBubble != null ? mBubble.getKey() : "null";