From 580c0bf2ae7c3564f22d091e93289b8b3438983b Mon Sep 17 00:00:00 2001 From: Joshua Tsuji Date: Mon, 28 Jan 2019 13:28:21 -0500 Subject: [PATCH] Adds shadows and a default background color to Bubbles. This makes the aliasing issues with clip path more apparent, but not inherently worse. We'll fix those issues in a subsequent CL, I just want to add this change now because transparent bubbles with no shadows are complicating stack-position debugging! Test: manual Bug: 123521453 Change-Id: I06a925ba6db64e92640146b9642396303b098f99 --- .../android/systemui/bubbles/BadgedImageView.java | 9 +++++++++ .../android/systemui/bubbles/BubbleStackView.java | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java index 36a813b914d55..1154515b261c8 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java @@ -16,7 +16,9 @@ package com.android.systemui.bubbles; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Path; import android.graphics.Point; import android.graphics.Rect; @@ -38,6 +40,7 @@ public class BadgedImageView extends ImageView { private float mDotScale = 0f; private int mUpdateDotColor; + private int mBubbleDefaultBgColor; private boolean mShowUpdateDot; private boolean mOnLeft; @@ -59,6 +62,11 @@ public class BadgedImageView extends ImageView { setScaleType(ScaleType.CENTER_CROP); mIconSize = getResources().getDimensionPixelSize(R.dimen.individual_bubble_size); mDotRenderer = new BadgeRenderer(mIconSize); + + TypedArray ta = context.obtainStyledAttributes( + new int[] {android.R.attr.colorBackgroundFloating}); + mBubbleDefaultBgColor = ta.getColor(0, Color.WHITE); + ta.recycle(); } // TODO: Clipping oval path isn't great: rerender image into a separate, rounded bitmap and @@ -70,6 +78,7 @@ public class BadgedImageView extends ImageView { mClipPath.addOval(getPaddingStart(), getPaddingTop(), getWidth() - getPaddingEnd(), getHeight() - getPaddingBottom(), Path.Direction.CW); canvas.clipPath(mClipPath); + canvas.drawColor(mBubbleDefaultBgColor); super.onDraw(canvas); // After we've circle cropped what we're showing, restore so we don't clip the badge diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index b584f6781796e..83fd9708e26af 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -23,6 +23,7 @@ import android.app.ActivityView; import android.app.PendingIntent; import android.content.Context; import android.content.res.Resources; +import android.graphics.Outline; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; @@ -32,6 +33,7 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewOutlineProvider; import android.view.ViewTreeObserver; import android.view.WindowInsets; import android.view.WindowManager; @@ -674,6 +676,17 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i); bv.updateDotVisibility(); bv.setZ(bubbsCount - i); + + // Draw the shadow around the circle inscribed within the bubble's bounds. This + // (intentionally) does not draw a shadow behind the update dot, which should be drawing + // its own shadow since it's on a different (higher) plane. + bv.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setOval(0, 0, mBubbleSize, mBubbleSize); + } + }); + bv.setClipToOutline(false); } }