Merge "Bubbles: fix some issues with the pointer" into sc-dev am: 16529a2613 am: c4ce4f0355

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14359193

Change-Id: Ic0a655d292be00d5bdbca31d9e6c624141e2f9da
This commit is contained in:
Mady Mellor
2021-05-04 16:51:35 +00:00
committed by Automerger Merge Worker
2 changed files with 42 additions and 45 deletions

View File

@@ -395,7 +395,6 @@ public class BubbleExpandedView extends LinearLayout {
mPointerView.setBackground(mCurrentPointer); mPointerView.setBackground(mCurrentPointer);
} }
private String getBubbleKey() { private String getBubbleKey() {
return mBubble != null ? mBubble.getKey() : "null"; return mBubble != null ? mBubble.getKey() : "null";
} }
@@ -519,16 +518,11 @@ public class BubbleExpandedView extends LinearLayout {
+ " bubble=" + getBubbleKey()); + " bubble=" + getBubbleKey());
} }
mIsContentVisible = visibility; mIsContentVisible = visibility;
final float alpha = visibility ? 1f : 0f;
mPointerView.setAlpha(alpha);
if (mTaskView != null && !mIsAlphaAnimating) { if (mTaskView != null && !mIsAlphaAnimating) {
mTaskView.setAlpha(alpha); mTaskView.setAlpha(visibility ? 1f : 0f);
} }
} }
@Nullable @Nullable
TaskView getTaskView() { TaskView getTaskView() {
return mTaskView; 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 // Pointer gets drawn in the padding
int paddingLeft = (isLandscape && onLeft) ? mPointerHeight : 0; final boolean showVertically = mPositioner.showBubblesVertically();
int paddingRight = (isLandscape && !onLeft) ? mPointerHeight : 0; final int paddingLeft = (showVertically && onLeft) ? mPointerHeight : 0;
int paddingTop = isLandscape ? 0 : mExpandedViewPadding; final int paddingRight = (showVertically && !onLeft) ? mPointerHeight : 0;
final int paddingTop = showVertically ? 0 : mExpandedViewPadding;
setPadding(paddingLeft, paddingTop, paddingRight, 0); setPadding(paddingLeft, paddingTop, paddingRight, 0);
if (isLandscape) { final float expandedViewY = mPositioner.getExpandedViewY();
// TODO: why setY vs setTranslationY ? linearlayout? final float bubbleSize = mPositioner.getBubbleBitmapSize();
mPointerView.setY(y - (mPointerWidth / 2f)); final float bubbleCenter = showVertically
mPointerView.setTranslationX(onLeft ? -mPointerHeight : x - mExpandedViewPadding); ? bubblePosition + (bubbleSize / 2f) - expandedViewY
} else { : bubblePosition + (bubbleSize / 2f);
mPointerView.setTranslationY(0f); // Post because we need the width of the view
mPointerView.setTranslationX(x - mExpandedViewPadding - (mPointerWidth / 2f)); post(() -> {
} float pointerY;
mCurrentPointer = isLandscape ? onLeft ? mLeftPointer : mRightPointer : mTopPointer; float pointerX;
updatePointerView(); if (showVertically) {
mPointerView.setVisibility(VISIBLE); 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);
});
} }
/** /**

View File

@@ -2683,7 +2683,7 @@ public class BubbleStackView extends FrameLayout
Log.d(TAG, "updateExpandedView: mIsExpanded=" + mIsExpanded); Log.d(TAG, "updateExpandedView: mIsExpanded=" + mIsExpanded);
} }
boolean isOverflowExpanded = mExpandedBubble != null boolean isOverflowExpanded = mExpandedBubble != null
&& mBubbleOverflow.KEY.equals(mExpandedBubble.getKey()); && BubbleOverflow.KEY.equals(mExpandedBubble.getKey());
int[] paddings = mPositioner.getExpandedViewPadding( int[] paddings = mPositioner.getExpandedViewPadding(
mStackAnimationController.isStackOnLeftSide(), isOverflowExpanded); mStackAnimationController.isStackOnLeftSide(), isOverflowExpanded);
mExpandedViewContainer.setPadding(paddings[0], 0, paddings[1], 0); mExpandedViewContainer.setPadding(paddings[0], 0, paddings[1], 0);
@@ -2695,6 +2695,7 @@ public class BubbleStackView extends FrameLayout
mExpandedViewContainer.setTranslationX(0f); mExpandedViewContainer.setTranslationX(0f);
mExpandedBubble.getExpandedView().updateView( mExpandedBubble.getExpandedView().updateView(
mExpandedViewContainer.getLocationOnScreen()); mExpandedViewContainer.getLocationOnScreen());
updatePointerPosition();
} }
mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide(); mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide();
@@ -2732,27 +2733,7 @@ public class BubbleStackView extends FrameLayout
return; return;
} }
float bubblePosition = mExpandedAnimationController.getBubbleXOrYForOrientation(index); float bubblePosition = mExpandedAnimationController.getBubbleXOrYForOrientation(index);
float expandedViewY = mPositioner.getExpandedViewY(); mExpandedBubble.getExpandedView().setPointerPosition(bubblePosition, mStackOnLeftOrWillBe);
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);
}
} }
/** /**