Merge "Adds shadows and a default background color to Bubbles."

This commit is contained in:
Josh Tsuji
2019-01-29 22:20:16 +00:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 0 deletions

View 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

View 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);
}
}