Do not animate bubble bar for initial state [2/N]
Initial state for bubble bar does not need to be animated. Especially if it is sent after rotation. In that case we do not want it to animate. When launcher is rotated, taskbar is recreated. After getting recreated, we receive the initial state from WMShell for the bubbles again. Part of the initial state is whether bubble bar is expanded or not. Bug: 357115534 Flag: com.android.wm.shell.enable_bubble_bar Test: rotate device Change-Id: I859b73597c8f286069f384dcdea0e3a5296e0073
This commit is contained in:
1 parent
416f80dc82
commit
f1f507e8c3
3 files changed
+73
-36
No files matched your search
@@ -145,7 +145,8 @@ public class BubbleBarView extends FrameLayout {
|
||||
|
||||
// An animator that represents the expansion state of the bubble bar, where 0 corresponds to the
|
||||
// collapsed state and 1 to the fully expanded state.
|
||||
private ValueAnimator mWidthAnimator = createExpansionAnimator(/* expanding = */ false);
|
||||
@Nullable
|
||||
private ValueAnimator mWidthAnimator;
|
||||
|
||||
@Nullable
|
||||
private ValueAnimator mDismissAnimator = null;
|
||||
@@ -1007,7 +1008,12 @@ public class BubbleBarView extends FrameLayout {
|
||||
* on the expanded state.
|
||||
*/
|
||||
private void updateBubblesLayoutProperties(BubbleBarLocation bubbleBarLocation) {
|
||||
final float widthState = (float) mWidthAnimator.getAnimatedValue();
|
||||
final float widthState;
|
||||
if (mWidthAnimator == null) {
|
||||
widthState = mIsBarExpanded ? 1f : 0f;
|
||||
} else {
|
||||
widthState = (float) mWidthAnimator.getAnimatedValue();
|
||||
}
|
||||
final float currentWidth = getWidth();
|
||||
final float expandedWidth = expandedWidth();
|
||||
final float collapsedWidth = collapsedWidth();
|
||||
@@ -1044,7 +1050,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
bv.setZ(fullElevationForChild * elevationState);
|
||||
|
||||
// only update the dot and badge scale if we're expanding or collapsing
|
||||
if (mWidthAnimator.isRunning()) {
|
||||
if (mWidthAnimator != null && mWidthAnimator.isRunning()) {
|
||||
// The dot for the selected bubble scales in the opposite direction of the expansion
|
||||
// animation.
|
||||
bv.showDotIfNeeded(bv == mSelectedBubbleView ? 1 - widthState : widthState);
|
||||
@@ -1160,7 +1166,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
* Reorders the views to match the provided list.
|
||||
*/
|
||||
public void reorder(List<BubbleView> viewOrder) {
|
||||
if (isExpanded() || mWidthAnimator.isRunning()) {
|
||||
if (isExpanded() || (mWidthAnimator != null && mWidthAnimator.isRunning())) {
|
||||
mReorderRunnable = () -> doReorder(viewOrder);
|
||||
} else {
|
||||
doReorder(viewOrder);
|
||||
@@ -1308,22 +1314,39 @@ public class BubbleBarView extends FrameLayout {
|
||||
super.setOnClickListener(mIsBarExpanded ? null : mOnClickListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update bubble bar expanded state.
|
||||
*/
|
||||
public void setExpanded(boolean isBarExpanded) {
|
||||
setExpandedInternal(isBarExpanded, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update bubble bar expanded state with animation.
|
||||
* <p>
|
||||
* Also triggers a talkback announcement for accessibility.
|
||||
*/
|
||||
public void animateExpanded(boolean isBarExpanded) {
|
||||
if (mIsBarExpanded != isBarExpanded) {
|
||||
mIsBarExpanded = isBarExpanded;
|
||||
updateArrowForSelected(/* shouldAnimate= */ false);
|
||||
setOrUnsetClickListener();
|
||||
setExpandedInternal(isBarExpanded, true);
|
||||
}
|
||||
|
||||
private void setExpandedInternal(boolean isBarExpanded, boolean animate) {
|
||||
if (mIsBarExpanded == isBarExpanded) return;
|
||||
mIsBarExpanded = isBarExpanded;
|
||||
updateArrowForSelected(/* shouldAnimate= */ false);
|
||||
setOrUnsetClickListener();
|
||||
if (animate) {
|
||||
mWidthAnimator = createExpansionAnimator(isBarExpanded);
|
||||
mWidthAnimator.start();
|
||||
updateBubbleAccessibilityStates();
|
||||
announceExpandedStateChange();
|
||||
mController.onBubbleBarExpandedStateChanged(mIsBarExpanded);
|
||||
} else {
|
||||
onExpandedChanged();
|
||||
}
|
||||
updateBubbleAccessibilityStates();
|
||||
mController.onBubbleBarExpandedStateChanged(mIsBarExpanded);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the bubble bar is expanded.
|
||||
*/
|
||||
@@ -1335,7 +1358,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
* Returns whether the bubble bar is expanding.
|
||||
*/
|
||||
public boolean isExpanding() {
|
||||
return mWidthAnimator.isRunning() && mIsBarExpanded;
|
||||
return mWidthAnimator != null && mWidthAnimator.isRunning() && mIsBarExpanded;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1584,26 +1607,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
animator.setInterpolator(Interpolators.EMPHASIZED);
|
||||
addAnimationCallBacks(animator,
|
||||
/* onStart= */ () -> mBubbleBarBackground.showArrow(true),
|
||||
/* onEnd= */ () -> {
|
||||
mBubbleBarBackground.showArrow(mIsBarExpanded);
|
||||
if (!mIsBarExpanded && mReorderRunnable != null) {
|
||||
mReorderRunnable.run();
|
||||
mReorderRunnable = null;
|
||||
}
|
||||
// If the bar was just collapsed and the overflow was the last bubble that was
|
||||
// selected, set the first bubble as selected.
|
||||
if (!mIsBarExpanded && mUpdateSelectedBubbleAfterCollapse != null
|
||||
&& mSelectedBubbleView != null
|
||||
&& mSelectedBubbleView.getBubble() instanceof BubbleBarOverflow) {
|
||||
BubbleView firstBubble = (BubbleView) getChildAt(0);
|
||||
mUpdateSelectedBubbleAfterCollapse.accept(firstBubble.getBubble().getKey());
|
||||
}
|
||||
// If the bar was just expanded, remove the dot from the selected bubble.
|
||||
if (mIsBarExpanded && mSelectedBubbleView != null) {
|
||||
mSelectedBubbleView.markSeen();
|
||||
}
|
||||
updateLayoutParams();
|
||||
},
|
||||
/* onEnd= */ this::onExpandedChanged,
|
||||
/* onUpdate= */ anim -> {
|
||||
updateBubblesLayoutProperties(mBubbleBarLocation);
|
||||
invalidate();
|
||||
@@ -1611,6 +1615,27 @@ public class BubbleBarView extends FrameLayout {
|
||||
return animator;
|
||||
}
|
||||
|
||||
private void onExpandedChanged() {
|
||||
mBubbleBarBackground.showArrow(mIsBarExpanded);
|
||||
if (!mIsBarExpanded && mReorderRunnable != null) {
|
||||
mReorderRunnable.run();
|
||||
mReorderRunnable = null;
|
||||
}
|
||||
// If the bar was just collapsed and the overflow was the last bubble that was
|
||||
// selected, set the first bubble as selected.
|
||||
if (!mIsBarExpanded && mUpdateSelectedBubbleAfterCollapse != null
|
||||
&& mSelectedBubbleView != null
|
||||
&& mSelectedBubbleView.getBubble() instanceof BubbleBarOverflow) {
|
||||
BubbleView firstBubble = (BubbleView) getChildAt(0);
|
||||
mUpdateSelectedBubbleAfterCollapse.accept(firstBubble.getBubble().getKey());
|
||||
}
|
||||
// If the bar was just expanded, remove the dot from the selected bubble.
|
||||
if (mIsBarExpanded && mSelectedBubbleView != null) {
|
||||
mSelectedBubbleView.markSeen();
|
||||
}
|
||||
updateLayoutParams();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance between the top left corner of the bubble bar to the center of the dot
|
||||
* of the selected bubble.
|
||||
|
||||
Reference in new issue
Block a user