diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index 696f705782c08..d8ec6508d77c0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -395,7 +395,6 @@ public class BubbleExpandedView extends LinearLayout { mPointerView.setBackground(mCurrentPointer); } - private String getBubbleKey() { return mBubble != null ? mBubble.getKey() : "null"; } @@ -519,16 +518,11 @@ public class BubbleExpandedView extends LinearLayout { + " bubble=" + getBubbleKey()); } mIsContentVisible = visibility; - - final float alpha = visibility ? 1f : 0f; - - mPointerView.setAlpha(alpha); if (mTaskView != null && !mIsAlphaAnimating) { - mTaskView.setAlpha(alpha); + mTaskView.setAlpha(visibility ? 1f : 0f); } } - @Nullable TaskView getTaskView() { return mTaskView; @@ -673,26 +667,48 @@ public class BubbleExpandedView extends LinearLayout { } /** - * Set the position that the tip of the triangle should point to. + * Sets the position of the pointer. + * + * When bubbles are showing "vertically" they display along the left / right sides of the + * screen with the expanded view beside them. + * + * If they aren't showing vertically they're positioned along the top of the screen with the + * expanded view below them. + * + * @param bubblePosition the x position of the bubble if showing on top, the y position of + * the bubble if showing vertically. + * @param onLeft whether the stack was on the left side of the screen when expanded. */ - public void setPointerPosition(float x, float y, boolean isLandscape, boolean onLeft) { + public void setPointerPosition(float bubblePosition, boolean onLeft) { // Pointer gets drawn in the padding - int paddingLeft = (isLandscape && onLeft) ? mPointerHeight : 0; - int paddingRight = (isLandscape && !onLeft) ? mPointerHeight : 0; - int paddingTop = isLandscape ? 0 : mExpandedViewPadding; + final boolean showVertically = mPositioner.showBubblesVertically(); + final int paddingLeft = (showVertically && onLeft) ? mPointerHeight : 0; + final int paddingRight = (showVertically && !onLeft) ? mPointerHeight : 0; + final int paddingTop = showVertically ? 0 : mExpandedViewPadding; setPadding(paddingLeft, paddingTop, paddingRight, 0); - if (isLandscape) { - // TODO: why setY vs setTranslationY ? linearlayout? - mPointerView.setY(y - (mPointerWidth / 2f)); - mPointerView.setTranslationX(onLeft ? -mPointerHeight : x - mExpandedViewPadding); - } else { - mPointerView.setTranslationY(0f); - mPointerView.setTranslationX(x - mExpandedViewPadding - (mPointerWidth / 2f)); - } - mCurrentPointer = isLandscape ? onLeft ? mLeftPointer : mRightPointer : mTopPointer; - updatePointerView(); - mPointerView.setVisibility(VISIBLE); + final float expandedViewY = mPositioner.getExpandedViewY(); + final float bubbleSize = mPositioner.getBubbleBitmapSize(); + final float bubbleCenter = showVertically + ? bubblePosition + (bubbleSize / 2f) - expandedViewY + : bubblePosition + (bubbleSize / 2f); + // Post because we need the width of the view + post(() -> { + float pointerY; + float pointerX; + if (showVertically) { + pointerY = bubbleCenter - (mPointerWidth / 2f); + pointerX = onLeft ? -mPointerHeight : getWidth() - mPaddingRight; + } else { + pointerY = 0; + pointerX = bubbleCenter - mPaddingLeft - (mPointerWidth / 2f); + } + mPointerView.setTranslationY(pointerY); + mPointerView.setTranslationX(pointerX); + mCurrentPointer = showVertically ? onLeft ? mLeftPointer : mRightPointer : mTopPointer; + updatePointerView(); + mPointerView.setVisibility(VISIBLE); + }); } /** 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 c4d33877f17d4..ea5eeaaf1f46f 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 @@ -2683,7 +2683,7 @@ public class BubbleStackView extends FrameLayout Log.d(TAG, "updateExpandedView: mIsExpanded=" + mIsExpanded); } boolean isOverflowExpanded = mExpandedBubble != null - && mBubbleOverflow.KEY.equals(mExpandedBubble.getKey()); + && BubbleOverflow.KEY.equals(mExpandedBubble.getKey()); int[] paddings = mPositioner.getExpandedViewPadding( mStackAnimationController.isStackOnLeftSide(), isOverflowExpanded); mExpandedViewContainer.setPadding(paddings[0], 0, paddings[1], 0); @@ -2695,6 +2695,7 @@ public class BubbleStackView extends FrameLayout mExpandedViewContainer.setTranslationX(0f); mExpandedBubble.getExpandedView().updateView( mExpandedViewContainer.getLocationOnScreen()); + updatePointerPosition(); } mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide(); @@ -2732,27 +2733,7 @@ public class BubbleStackView extends FrameLayout return; } float bubblePosition = mExpandedAnimationController.getBubbleXOrYForOrientation(index); - float expandedViewY = mPositioner.getExpandedViewY(); - if (mPositioner.showBubblesVertically()) { - float x = mStackOnLeftOrWillBe - ? mPositioner.getAvailableRect().left - : mPositioner.getAvailableRect().right - - mExpandedViewContainer.getPaddingRight() - - mPointerHeight; - float bubbleCenter = bubblePosition - expandedViewY + (mBubbleSize / 2f); - mExpandedBubble.getExpandedView().setPointerPosition( - x, - bubbleCenter, - true, - mStackOnLeftOrWillBe); - } else { - float bubbleCenter = bubblePosition + (mBubbleSize / 2f); - mExpandedBubble.getExpandedView().setPointerPosition( - bubbleCenter, - expandedViewY, - false, - mStackOnLeftOrWillBe); - } + mExpandedBubble.getExpandedView().setPointerPosition(bubblePosition, mStackOnLeftOrWillBe); } /**