From 9254393aa55cb5e7c9d356be58bfa700b35fe192 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 13 May 2021 01:22:13 -0700 Subject: Bubble dismiss updates - large colored circle, uses same accent color that launcher has for remove / uninstall - added a shrink animation for the target when the bubble is stuck via the magnet - no longer desaturate the bubble being dismissed but rather add a bit of an alpha Bug: 183657564 Test: manual - get a bubble, drag it around & dismiss it, notice the animation Change-Id: If0d0d86b7389f0fa3314598266cd83ecabdc6a9b --- .../Shell/res/drawable/bubble_dismiss_circle.xml | 28 ---- .../Shell/res/drawable/bubble_dismiss_icon.xml | 26 ---- .../res/drawable/dismiss_circle_background.xml | 7 +- .../Shell/res/drawable/pip_ic_close_white.xml | 2 +- .../Shell/res/layout/bubble_dismiss_target.xml | 49 ------- libs/WindowManager/Shell/res/values/dimen.xml | 3 +- .../android/wm/shell/bubbles/BubbleStackView.java | 145 ++++++++++----------- .../com/android/wm/shell/bubbles/DismissView.kt | 2 - 8 files changed, 78 insertions(+), 184 deletions(-) delete mode 100644 libs/WindowManager/Shell/res/drawable/bubble_dismiss_circle.xml delete mode 100644 libs/WindowManager/Shell/res/drawable/bubble_dismiss_icon.xml delete mode 100644 libs/WindowManager/Shell/res/layout/bubble_dismiss_target.xml diff --git a/libs/WindowManager/Shell/res/drawable/bubble_dismiss_circle.xml b/libs/WindowManager/Shell/res/drawable/bubble_dismiss_circle.xml deleted file mode 100644 index 2104be48d1d9..000000000000 --- a/libs/WindowManager/Shell/res/drawable/bubble_dismiss_circle.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/drawable/bubble_dismiss_icon.xml b/libs/WindowManager/Shell/res/drawable/bubble_dismiss_icon.xml deleted file mode 100644 index ff8feded11ab..000000000000 --- a/libs/WindowManager/Shell/res/drawable/bubble_dismiss_icon.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/libs/WindowManager/Shell/res/drawable/dismiss_circle_background.xml b/libs/WindowManager/Shell/res/drawable/dismiss_circle_background.xml index 7809c8398c2d..f7fda362d76c 100644 --- a/libs/WindowManager/Shell/res/drawable/dismiss_circle_background.xml +++ b/libs/WindowManager/Shell/res/drawable/dismiss_circle_background.xml @@ -20,9 +20,8 @@ android:shape="oval"> - - + android:width="2dp" + android:color="@android:color/system_accent1_600" /> + \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml index 60456267afef..62285e62fbf5 100644 --- a/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml +++ b/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml @@ -21,5 +21,5 @@ android:viewportHeight="24.0"> + android:fillColor="@android:color/system_neutral1_50"/> diff --git a/libs/WindowManager/Shell/res/layout/bubble_dismiss_target.xml b/libs/WindowManager/Shell/res/layout/bubble_dismiss_target.xml deleted file mode 100644 index f5cd727a6d03..000000000000 --- a/libs/WindowManager/Shell/res/layout/bubble_dismiss_target.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 3caff35c8a9d..dddf2c12ea2d 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -15,7 +15,8 @@ limitations under the License. --> - 52dp + 96dp + 60dp 250dp 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 7e48a7e13920..d821c6ff7cd1 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 @@ -34,10 +34,7 @@ import android.content.Intent; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; -import android.graphics.ColorMatrix; -import android.graphics.ColorMatrixColorFilter; import android.graphics.Outline; -import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; @@ -192,8 +189,7 @@ public class BubbleStackView extends FrameLayout private final BubbleController mBubbleController; private final BubbleData mBubbleData; - private final ValueAnimator mDesaturateAndDarkenAnimator; - private final Paint mDesaturateAndDarkenPaint = new Paint(); + private final ValueAnimator mDismissBubbleAnimator; private PhysicsAnimationLayout mBubbleContainer; private StackAnimationController mStackAnimationController; @@ -330,8 +326,8 @@ public class BubbleStackView extends FrameLayout private boolean mIsExpansionAnimating = false; private boolean mIsBubbleSwitchAnimating = false; - /** The view to desaturate/darken when magneted to the dismiss target. */ - @Nullable private View mDesaturateAndDarkenTargetView; + /** The view to shrink and apply alpha to when magneted to the dismiss target. */ + @Nullable private View mViewBeingDismissed; private Rect mTempRect = new Rect(); @@ -415,8 +411,7 @@ public class BubbleStackView extends FrameLayout if (mExpandedAnimationController.getDraggedOutBubble() == null) { return; } - - animateDesaturateAndDarken( + animateDismissBubble( mExpandedAnimationController.getDraggedOutBubble(), true); } @@ -426,8 +421,7 @@ public class BubbleStackView extends FrameLayout if (mExpandedAnimationController.getDraggedOutBubble() == null) { return; } - - animateDesaturateAndDarken( + animateDismissBubble( mExpandedAnimationController.getDraggedOutBubble(), false); if (wasFlungOut) { @@ -459,14 +453,13 @@ public class BubbleStackView extends FrameLayout @Override public void onStuckToTarget( @NonNull MagnetizedObject.MagneticTarget target) { - animateDesaturateAndDarken(mBubbleContainer, true); + animateDismissBubble(mBubbleContainer, true); } @Override public void onUnstuckFromTarget(@NonNull MagnetizedObject.MagneticTarget target, float velX, float velY, boolean wasFlungOut) { - animateDesaturateAndDarken(mBubbleContainer, false); - + animateDismissBubble(mBubbleContainer, false); if (wasFlungOut) { mStackAnimationController.flingStackThenSpringToEdge( mStackAnimationController.getStackPosition().x, velX, velY); @@ -481,11 +474,10 @@ public class BubbleStackView extends FrameLayout mStackAnimationController.animateStackDismissal( mDismissView.getHeight() /* translationYBy */, () -> { - resetDesaturationAndDarken(); + resetDismissAnimator(); dismissMagnetizedObject(); } ); - mDismissView.hide(); } }; @@ -836,17 +828,7 @@ public class BubbleStackView extends FrameLayout .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)); mFlyoutTransitionSpring.addEndListener(mAfterFlyoutTransitionSpring); - mDismissView = new DismissView(context); - addView(mDismissView); - - final ContentResolver contentResolver = getContext().getContentResolver(); - final int dismissRadius = Settings.Secure.getInt( - contentResolver, "bubble_dismiss_radius", mBubbleSize * 2 /* default */); - - // Save the MagneticTarget instance for the newly set up view - we'll add this to the - // MagnetizedObjects. - mMagneticTarget = new MagnetizedObject.MagneticTarget( - mDismissView.getCircle(), dismissRadius); + setUpDismissView(); setClipChildren(false); setFocusable(true); @@ -891,6 +873,7 @@ public class BubbleStackView extends FrameLayout mRelativeStackPositionBeforeRotation = null; } + setUpDismissView(); if (mIsExpanded) { // Re-draw bubble row and pointer for new orientation. beforeExpandedViewAnimation(); @@ -905,30 +888,23 @@ public class BubbleStackView extends FrameLayout } removeOnLayoutChangeListener(mOrientationChangedListener); }; - - final ColorMatrix animatedMatrix = new ColorMatrix(); - final ColorMatrix darkenMatrix = new ColorMatrix(); - - mDesaturateAndDarkenAnimator = ValueAnimator.ofFloat(1f, 0f); - mDesaturateAndDarkenAnimator.addUpdateListener(animation -> { + final float maxDismissSize = getResources().getDimensionPixelSize( + R.dimen.dismiss_circle_size); + final float minDismissSize = getResources().getDimensionPixelSize( + R.dimen.dismiss_circle_small); + final float sizePercent = minDismissSize / maxDismissSize; + mDismissBubbleAnimator = ValueAnimator.ofFloat(1f, 0f); + mDismissBubbleAnimator.addUpdateListener(animation -> { final float animatedValue = (float) animation.getAnimatedValue(); - animatedMatrix.setSaturation(animatedValue); - - final float animatedDarkenValue = (1f - animatedValue) * DARKEN_PERCENT; - darkenMatrix.setScale( - 1f - animatedDarkenValue /* red */, - 1f - animatedDarkenValue /* green */, - 1f - animatedDarkenValue /* blue */, - 1f /* alpha */); - - // Concat the matrices so that the animatedMatrix both desaturates and darkens. - animatedMatrix.postConcat(darkenMatrix); - - // Update the paint and apply it to the bubble container. - mDesaturateAndDarkenPaint.setColorFilter(new ColorMatrixColorFilter(animatedMatrix)); - - if (mDesaturateAndDarkenTargetView != null) { - mDesaturateAndDarkenTargetView.setLayerPaint(mDesaturateAndDarkenPaint); + if (mDismissView != null) { + mDismissView.setPivotX((mDismissView.getRight() - mDismissView.getLeft()) / 2f); + mDismissView.setPivotY((mDismissView.getBottom() - mDismissView.getTop()) / 2f); + final float scaleValue = Math.max(animatedValue, sizePercent); + mDismissView.getCircle().setScaleX(scaleValue); + mDismissView.getCircle().setScaleY(scaleValue); + } + if (mViewBeingDismissed != null) { + mViewBeingDismissed.setAlpha(Math.max(animatedValue, 0.7f)); } }); @@ -1048,6 +1024,23 @@ public class BubbleStackView extends FrameLayout } }; + private void setUpDismissView() { + if (mDismissView != null) { + removeView(mDismissView); + } + mDismissView = new DismissView(getContext()); + addView(mDismissView); + + final ContentResolver contentResolver = getContext().getContentResolver(); + final int dismissRadius = Settings.Secure.getInt( + contentResolver, "bubble_dismiss_radius", mBubbleSize * 2 /* default */); + + // Save the MagneticTarget instance for the newly set up view - we'll add this to the + // MagnetizedObjects. + mMagneticTarget = new MagnetizedObject.MagneticTarget( + mDismissView.getCircle(), dismissRadius); + } + // TODO: Create ManageMenuView and move setup / animations there private void setUpManageMenu() { if (mManageMenu != null) { @@ -1217,6 +1210,7 @@ public class BubbleStackView extends FrameLayout public void onThemeChanged() { setUpFlyout(); setUpManageMenu(); + setUpDismissView(); updateOverflow(); updateUserEdu(); updateExpandedViewTheme(); @@ -1256,6 +1250,7 @@ public class BubbleStackView extends FrameLayout updateOverflow(); setUpManageMenu(); setUpFlyout(); + setUpDismissView(); mBubbleSize = mPositioner.getBubbleSize(); for (Bubble b : mBubbleData.getBubbles()) { if (b.getIconView() == null) { @@ -2264,42 +2259,46 @@ public class BubbleStackView extends FrameLayout } } - /** Prepares and starts the desaturate/darken animation on the bubble stack. */ - private void animateDesaturateAndDarken(View targetView, boolean desaturateAndDarken) { - mDesaturateAndDarkenTargetView = targetView; + /** Prepares and starts the dismiss animation on the bubble stack. */ + private void animateDismissBubble(View targetView, boolean applyAlpha) { + mViewBeingDismissed = targetView; - if (mDesaturateAndDarkenTargetView == null) { + if (mViewBeingDismissed == null) { return; } - - if (desaturateAndDarken) { - // Use the animated paint for the bubbles. - mDesaturateAndDarkenTargetView.setLayerType( - View.LAYER_TYPE_HARDWARE, mDesaturateAndDarkenPaint); - mDesaturateAndDarkenAnimator.removeAllListeners(); - mDesaturateAndDarkenAnimator.start(); + if (applyAlpha) { + mDismissBubbleAnimator.removeAllListeners(); + mDismissBubbleAnimator.start(); } else { - mDesaturateAndDarkenAnimator.removeAllListeners(); - mDesaturateAndDarkenAnimator.addListener(new AnimatorListenerAdapter() { + mDismissBubbleAnimator.removeAllListeners(); + mDismissBubbleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - // Stop using the animated paint. - resetDesaturationAndDarken(); + resetDismissAnimator(); + } + + @Override + public void onAnimationCancel(Animator animation) { + super.onAnimationCancel(animation); + resetDismissAnimator(); } }); - mDesaturateAndDarkenAnimator.reverse(); + mDismissBubbleAnimator.reverse(); } } - private void resetDesaturationAndDarken() { + private void resetDismissAnimator() { + mDismissBubbleAnimator.removeAllListeners(); + mDismissBubbleAnimator.cancel(); - mDesaturateAndDarkenAnimator.removeAllListeners(); - mDesaturateAndDarkenAnimator.cancel(); - - if (mDesaturateAndDarkenTargetView != null) { - mDesaturateAndDarkenTargetView.setLayerType(View.LAYER_TYPE_NONE, null); - mDesaturateAndDarkenTargetView = null; + if (mViewBeingDismissed != null) { + mViewBeingDismissed.setAlpha(1f); + mViewBeingDismissed = null; + } + if (mDismissView != null) { + mDismissView.getCircle().setScaleX(1f); + mDismissView.getCircle().setScaleY(1f); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/DismissView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/DismissView.kt index 04b5ad6dddf9..0a1cd2246339 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/DismissView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/DismissView.kt @@ -67,8 +67,6 @@ class DismissView(context: Context) : FrameLayout(context) { fun show() { if (isShowing) return isShowing = true - bringToFront() - setZ(Short.MAX_VALUE - 1f) setVisibility(View.VISIBLE) (getBackground() as TransitionDrawable).startTransition(DISMISS_SCRIM_FADE_MS) animator.cancel() -- cgit v1.2.3-59-g8ed1b