Bubbles: fix some issues with the pointer
* Pointer was missing if showing vertically on the right
side, this is fixed & tried to make the code a lil more
clear
* Pointer was missing for the bubble overflow, this is
also fixed
Bug: 181888630
Test: manual - make sure the pointer is visible when the
stack is expanded, check landscape left &
right on small & large screen and check
portrait on phone.
Change-Id: Id7dc6ae9a1f3e798940342b780940fb77ceaed3a
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user