Merge "Bubbles: fix some issues with the pointer" into sc-dev am: 16529a2613
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14359193 Change-Id: I4642b108f2b99d6d6a0c84b3170d7f4a2e0f46db
This commit is contained in:
@@ -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
|
||||||
|
: 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 {
|
} else {
|
||||||
mPointerView.setTranslationY(0f);
|
pointerY = 0;
|
||||||
mPointerView.setTranslationX(x - mExpandedViewPadding - (mPointerWidth / 2f));
|
pointerX = bubbleCenter - mPaddingLeft - (mPointerWidth / 2f);
|
||||||
}
|
}
|
||||||
mCurrentPointer = isLandscape ? onLeft ? mLeftPointer : mRightPointer : mTopPointer;
|
mPointerView.setTranslationY(pointerY);
|
||||||
|
mPointerView.setTranslationX(pointerX);
|
||||||
|
mCurrentPointer = showVertically ? onLeft ? mLeftPointer : mRightPointer : mTopPointer;
|
||||||
updatePointerView();
|
updatePointerView();
|
||||||
mPointerView.setVisibility(VISIBLE);
|
mPointerView.setVisibility(VISIBLE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user