From 25fdf10ad1255d4aaeaadb50957d0eaedff2ab8f Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 2 Jun 2022 11:24:17 -0700 Subject: [PATCH] Fix an issue where the pointer could be invisible Add setBackgroundAlpha and use that to change the alpha of the expanded view background and pointer. Test: manual - have a bunch of bubbles, expand them, dismiss the selected one => verify that the arrow is visible for the next bubble - turn on home animation, swipe up to collapse a bubble => verify pointer looks fine Bug: 234739591 Change-Id: If5823840d148e2031312c54eba9c0132b8aa3a4c --- .../wm/shell/bubbles/BubbleExpandedView.java | 22 +++++++++++++++++++ .../wm/shell/bubbles/BubbleStackView.java | 4 ++-- .../ExpandedViewAnimationControllerImpl.java | 7 +++--- .../ExpandedViewAnimationControllerTest.java | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index bf8406c68a894..1f6978cb74d3a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -106,6 +106,20 @@ public class BubbleExpandedView extends LinearLayout { } }; + /** {@link FloatProperty} for updating background and pointer alpha */ + public static final FloatProperty BACKGROUND_ALPHA = + new FloatProperty("backgroundAlpha") { + @Override + public void setValue(BubbleExpandedView expandedView, float value) { + expandedView.setBackgroundAlpha(value); + } + + @Override + public Float get(BubbleExpandedView expandedView) { + return expandedView.getAlpha(); + } + }; + /** {@link FloatProperty} for updating manage button alpha */ public static final FloatProperty MANAGE_BUTTON_ALPHA = new FloatProperty("manageButtonAlpha") { @@ -602,6 +616,14 @@ public class BubbleExpandedView extends LinearLayout { } } + /** + * Sets the alpha of the background and the pointer view. + */ + public void setBackgroundAlpha(float alpha) { + mPointerView.setAlpha(alpha); + setAlpha(alpha); + } + /** * Set translation Y for the expanded view content. * Excludes manage button and pointer. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 33a5fa12a4a16..5aae14bc31529 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -1079,7 +1079,7 @@ public class BubbleStackView extends FrameLayout if (mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) { float alpha = (float) valueAnimator.getAnimatedValue(); mExpandedBubble.getExpandedView().setContentAlpha(alpha); - mExpandedBubble.getExpandedView().setAlpha(alpha); + mExpandedBubble.getExpandedView().setBackgroundAlpha(alpha); } }); @@ -2215,7 +2215,7 @@ public class BubbleStackView extends FrameLayout if (mExpandedBubble.getExpandedView() != null) { mExpandedBubble.getExpandedView().setContentAlpha(0f); - mExpandedBubble.getExpandedView().setAlpha(0f); + mExpandedBubble.getExpandedView().setBackgroundAlpha(0f); // We'll be starting the alpha animation after a slight delay, so set this flag early // here. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerImpl.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerImpl.java index ca54232c95b56..845dca34b41f6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerImpl.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerImpl.java @@ -15,12 +15,11 @@ */ package com.android.wm.shell.bubbles.animation; -import static android.view.View.ALPHA; - import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_COLLAPSE_ANIMATOR; import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_EXPANDED_VIEW_DRAGGING; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME; +import static com.android.wm.shell.bubbles.BubbleExpandedView.BACKGROUND_ALPHA; import static com.android.wm.shell.bubbles.BubbleExpandedView.BOTTOM_CLIP_PROPERTY; import static com.android.wm.shell.bubbles.BubbleExpandedView.CONTENT_ALPHA; import static com.android.wm.shell.bubbles.BubbleExpandedView.MANAGE_BUTTON_ALPHA; @@ -314,7 +313,7 @@ public class ExpandedViewAnimationControllerImpl implements ExpandedViewAnimatio mBackToExpandedAnimation.cancel(); } mExpandedView.setContentAlpha(1); - mExpandedView.setAlpha(1); + mExpandedView.setBackgroundAlpha(1); mExpandedView.setManageButtonAlpha(1); setCollapsedAmount(0); mExpandedView.setBottomClip(0); @@ -416,7 +415,7 @@ public class ExpandedViewAnimationControllerImpl implements ExpandedViewAnimatio } private ObjectAnimator createBackgroundAlphaAnimation() { - ObjectAnimator animator = ObjectAnimator.ofFloat(mExpandedView, ALPHA, 0f); + ObjectAnimator animator = ObjectAnimator.ofFloat(mExpandedView, BACKGROUND_ALPHA, 0f); animator.setDuration(BACKGROUND_OPACITY_ANIM_DURATION_MS); animator.setInterpolator(Interpolators.LINEAR); animator.setStartDelay(BACKGROUND_OPACITY_ANIM_DELAY_MS); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerTest.java index 21887c03833a1..991913afbb90a 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/ExpandedViewAnimationControllerTest.java @@ -156,7 +156,7 @@ public class ExpandedViewAnimationControllerTest extends ShellTestCase { mController.reset(); verify(mMockExpandedView, atLeastOnce()).setAnimating(false); verify(mMockExpandedView).setContentAlpha(1); - verify(mMockExpandedView).setAlpha(1); + verify(mMockExpandedView).setBackgroundAlpha(1); verify(mMockExpandedView).setManageButtonAlpha(1); verify(mMockExpandedView).setManageButtonAlpha(1); verify(mMockExpandedView).setTopClip(0);