Handle the event of first bubble added.
When the first bubble is added we set the visibility of the bubble bar
to VISIBLE if the stash controller is unstashed. The issue is that once
bubbles are gone we no longer update the stash state in the controller,
so it becomes stale and can't be used when the first bubble is added.
This change introduces a new method for handling the transition from
the state where both bar and handle are invisible into the state where
one of them becomes visible. We can't use the existing stashBubbleBar
and showBubbleBar methods because those transition from one to the other.
Using them when both are invisible results in one of them becoming visible
and then invisible again.
Fixes: 290992144
Fixes: 291074646
Test: Manual:
- Add bubble in the test app by double-tapping on a chat (non expanding notification)
- Observe that the handle becomes visible and the bar is invisible
- Dismiss bubble
- Add bubble in the test app by tapping on the button on the right (auto expanding)
- Observe that the bar becomes visible and expanded
Change-Id: I61334c67c255a6ed074fa8c834f4a5a1547539bf
This commit is contained in:
+23
-15
@@ -52,6 +52,7 @@ public class BubbleStashedHandleViewController {
|
||||
private BubbleStashController mBubbleStashController;
|
||||
private RegionSamplingHelper mRegionSamplingHelper;
|
||||
private int mBarSize;
|
||||
private int mStashedTaskbarHeight;
|
||||
private int mStashedHandleWidth;
|
||||
private int mStashedHandleHeight;
|
||||
|
||||
@@ -92,7 +93,7 @@ public class BubbleStashedHandleViewController {
|
||||
|
||||
mTaskbarStashedHandleAlpha.get(0).setValue(0);
|
||||
|
||||
final int stashedTaskbarHeight = resources.getDimensionPixelSize(
|
||||
mStashedTaskbarHeight = resources.getDimensionPixelSize(
|
||||
R.dimen.bubblebar_stashed_size);
|
||||
mStashedHandleView.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
@@ -115,22 +116,25 @@ public class BubbleStashedHandleViewController {
|
||||
}
|
||||
}, Executors.UI_HELPER_EXECUTOR);
|
||||
|
||||
mStashedHandleView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) -> {
|
||||
// As more bubbles get added, the icon bounds become larger. To ensure a consistent
|
||||
// handle bar position, we pin it to the edge of the screen.
|
||||
Rect bubblebarRect = mBarViewController.getBubbleBarBounds();
|
||||
final int stashedCenterY = view.getHeight() - stashedTaskbarHeight / 2;
|
||||
mStashedHandleView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) ->
|
||||
updateBounds());
|
||||
}
|
||||
|
||||
mStashedHandleBounds.set(
|
||||
bubblebarRect.right - mStashedHandleWidth,
|
||||
stashedCenterY - mStashedHandleHeight / 2,
|
||||
bubblebarRect.right,
|
||||
stashedCenterY + mStashedHandleHeight / 2);
|
||||
mStashedHandleView.updateSampledRegion(mStashedHandleBounds);
|
||||
private void updateBounds() {
|
||||
// As more bubbles get added, the icon bounds become larger. To ensure a consistent
|
||||
// handle bar position, we pin it to the edge of the screen.
|
||||
Rect bubblebarRect = mBarViewController.getBubbleBarBounds();
|
||||
final int stashedCenterY = mStashedHandleView.getHeight() - mStashedTaskbarHeight / 2;
|
||||
|
||||
view.setPivotX(view.getWidth());
|
||||
view.setPivotY(view.getHeight() - stashedTaskbarHeight / 2f);
|
||||
});
|
||||
mStashedHandleBounds.set(
|
||||
bubblebarRect.right - mStashedHandleWidth,
|
||||
stashedCenterY - mStashedHandleHeight / 2,
|
||||
bubblebarRect.right,
|
||||
stashedCenterY + mStashedHandleHeight / 2);
|
||||
mStashedHandleView.updateSampledRegion(mStashedHandleBounds);
|
||||
|
||||
mStashedHandleView.setPivotX(mStashedHandleView.getWidth());
|
||||
mStashedHandleView.setPivotY(mStashedHandleView.getHeight() - mStashedTaskbarHeight / 2f);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
@@ -188,6 +192,7 @@ public class BubbleStashedHandleViewController {
|
||||
mStashedHandleView.setVisibility(VISIBLE);
|
||||
} else {
|
||||
mStashedHandleView.setVisibility(INVISIBLE);
|
||||
mStashedHandleView.setAlpha(0);
|
||||
}
|
||||
updateRegionSampling();
|
||||
}
|
||||
@@ -235,6 +240,9 @@ public class BubbleStashedHandleViewController {
|
||||
*/
|
||||
public Animator createRevealAnimToIsStashed(boolean isStashed) {
|
||||
Rect bubbleBarBounds = new Rect(mBarViewController.getBubbleBarBounds());
|
||||
// the bubble bar may have been invisible when the bounds were previously calculated,
|
||||
// update them again to ensure they're correct.
|
||||
updateBounds();
|
||||
|
||||
// Account for the full visual height of the bubble bar
|
||||
int heightDiff = (mBarSize - bubbleBarBounds.height()) / 2;
|
||||
|
||||
Reference in New Issue
Block a user