OSDN Git Service

Adds shadows and a default background color to Bubbles.
authorJoshua Tsuji <tsuji@google.com>
Mon, 28 Jan 2019 18:28:21 +0000 (13:28 -0500)
committerJoshua Tsuji <tsuji@google.com>
Tue, 29 Jan 2019 18:14:53 +0000 (13:14 -0500)
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

packages/SystemUI/src/com/android/systemui/bubbles/BadgedImageView.java
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java

index 36a813b..1154515 100644 (file)
@@ -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
index b584f67..83fd970 100644 (file)
@@ -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);
         }
     }