Merge "Add the priority person highlight back to bubbles badge" into sc-dev
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.wm.shell.bubbles;
|
||||
|
||||
import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
||||
import static android.graphics.Paint.DITHER_FLAG;
|
||||
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
|
||||
|
||||
@@ -22,10 +23,10 @@ import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PaintFlagsDrawFilter;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.PathParser;
|
||||
import android.widget.ImageView;
|
||||
@@ -75,13 +76,13 @@ public class BadgedImageView extends ImageView {
|
||||
|
||||
private BubbleViewProvider mBubble;
|
||||
private BubblePositioner mPositioner;
|
||||
private boolean mOnLeft;
|
||||
|
||||
private DotRenderer mDotRenderer;
|
||||
private DotRenderer.DrawParams mDrawParams;
|
||||
private boolean mOnLeft;
|
||||
|
||||
private int mDotColor;
|
||||
|
||||
private Paint mPaint = new Paint(ANTI_ALIAS_FLAG);
|
||||
private Rect mTempBounds = new Rect();
|
||||
|
||||
public BadgedImageView(Context context) {
|
||||
@@ -305,7 +306,7 @@ public class BadgedImageView extends ImageView {
|
||||
}
|
||||
|
||||
void showBadge() {
|
||||
Drawable badge = mBubble.getAppBadge();
|
||||
Bitmap badge = mBubble.getAppBadge();
|
||||
if (badge == null) {
|
||||
setImageBitmap(mBubble.getBubbleIcon());
|
||||
return;
|
||||
@@ -318,13 +319,13 @@ public class BadgedImageView extends ImageView {
|
||||
bubbleCanvas.setBitmap(bubble);
|
||||
final int bubbleSize = bubble.getWidth();
|
||||
final int badgeSize = (int) (ICON_BADGE_SCALE * bubbleSize);
|
||||
Rect dest = new Rect();
|
||||
if (mOnLeft) {
|
||||
badge.setBounds(0, bubbleSize - badgeSize, badgeSize, bubbleSize);
|
||||
dest.set(0, bubbleSize - badgeSize, badgeSize, bubbleSize);
|
||||
} else {
|
||||
badge.setBounds(bubbleSize - badgeSize, bubbleSize - badgeSize,
|
||||
bubbleSize, bubbleSize);
|
||||
dest.set(bubbleSize - badgeSize, bubbleSize - badgeSize, bubbleSize, bubbleSize);
|
||||
}
|
||||
badge.draw(bubbleCanvas);
|
||||
bubbleCanvas.drawBitmap(badge, null /* src */, dest, mPaint);
|
||||
bubbleCanvas.setBitmap(null);
|
||||
setImageBitmap(bubble);
|
||||
}
|
||||
|
||||
@@ -104,9 +104,10 @@ public class Bubble implements BubbleViewProvider {
|
||||
}
|
||||
|
||||
private FlyoutMessage mFlyoutMessage;
|
||||
private Drawable mBadgeDrawable;
|
||||
// Bitmap with no badge, no dot
|
||||
// The developer provided image for the bubble
|
||||
private Bitmap mBubbleBitmap;
|
||||
// The app badge for the bubble
|
||||
private Bitmap mBadgeBitmap;
|
||||
private int mDotColor;
|
||||
private Path mDotPath;
|
||||
private int mFlags;
|
||||
@@ -242,8 +243,8 @@ public class Bubble implements BubbleViewProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getAppBadge() {
|
||||
return mBadgeDrawable;
|
||||
public Bitmap getAppBadge() {
|
||||
return mBadgeBitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -398,7 +399,7 @@ public class Bubble implements BubbleViewProvider {
|
||||
mAppName = info.appName;
|
||||
mFlyoutMessage = info.flyoutMessage;
|
||||
|
||||
mBadgeDrawable = info.badgeDrawable;
|
||||
mBadgeBitmap = info.badgeBitmap;
|
||||
mBubbleBitmap = info.bubbleBitmap;
|
||||
|
||||
mDotColor = info.dotColor;
|
||||
|
||||
@@ -101,6 +101,12 @@ public class BubbleIconFactory extends BaseIconFactory {
|
||||
userBadgedBitmap.getHeight(), userBadgedBitmap.getConfig());
|
||||
Canvas c = new Canvas(badgeAndRing);
|
||||
|
||||
Paint ringPaint = new Paint();
|
||||
ringPaint.setStyle(Paint.Style.FILL);
|
||||
ringPaint.setColor(importantConversationColor);
|
||||
ringPaint.setAntiAlias(true);
|
||||
c.drawCircle(c.getWidth() / 2, c.getHeight() / 2, c.getWidth() / 2, ringPaint);
|
||||
|
||||
final int bitmapTop = (int) ringStrokeWidth;
|
||||
final int bitmapLeft = (int) ringStrokeWidth;
|
||||
final int bitmapWidth = c.getWidth() - 2 * (int) ringStrokeWidth;
|
||||
@@ -110,14 +116,6 @@ public class BubbleIconFactory extends BaseIconFactory {
|
||||
bitmapHeight, /* filter */ true);
|
||||
c.drawBitmap(scaledBitmap, bitmapTop, bitmapLeft, /* paint */null);
|
||||
|
||||
Paint ringPaint = new Paint();
|
||||
ringPaint.setStyle(Paint.Style.STROKE);
|
||||
ringPaint.setColor(importantConversationColor);
|
||||
ringPaint.setAntiAlias(true);
|
||||
ringPaint.setStrokeWidth(ringStrokeWidth);
|
||||
c.drawCircle(c.getWidth() / 2, c.getHeight() / 2, c.getWidth() / 2 - ringStrokeWidth,
|
||||
ringPaint);
|
||||
|
||||
shadowGenerator.recreateIcon(Bitmap.createBitmap(badgeAndRing), c);
|
||||
return createIconBitmap(badgeAndRing);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.graphics.Matrix
|
||||
import android.graphics.Path
|
||||
import android.graphics.drawable.AdaptiveIconDrawable
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.InsetDrawable
|
||||
import android.util.PathParser
|
||||
import android.util.TypedValue
|
||||
@@ -151,7 +150,7 @@ class BubbleOverflow(
|
||||
return dotColor
|
||||
}
|
||||
|
||||
override fun getAppBadge(): Drawable? {
|
||||
override fun getAppBadge(): Bitmap? {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -2487,7 +2487,7 @@ public class BubbleStackView extends FrameLayout
|
||||
// name and icon.
|
||||
if (show && mBubbleData.hasBubbleInStackWithKey(mExpandedBubble.getKey())) {
|
||||
final Bubble bubble = mBubbleData.getBubbleInStackWithKey(mExpandedBubble.getKey());
|
||||
mManageSettingsIcon.setImageDrawable(bubble.getAppBadge());
|
||||
mManageSettingsIcon.setImageBitmap(bubble.getAppBadge());
|
||||
mManageSettingsText.setText(getResources().getString(
|
||||
R.string.bubbles_app_settings, bubble.getAppName()));
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
|
||||
ShortcutInfo shortcutInfo;
|
||||
String appName;
|
||||
Bitmap bubbleBitmap;
|
||||
Drawable badgeDrawable;
|
||||
Bitmap badgeBitmap;
|
||||
int dotColor;
|
||||
Path dotPath;
|
||||
Bubble.FlyoutMessage flyoutMessage;
|
||||
@@ -188,7 +188,7 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask
|
||||
|
||||
BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(badgedIcon,
|
||||
b.isImportantConversation());
|
||||
info.badgeDrawable = badgedIcon;
|
||||
info.badgeBitmap = badgeBitmapInfo.icon;
|
||||
info.bubbleBitmap = iconFactory.createBadgedIconBitmap(bubbleDrawable,
|
||||
null /* user */,
|
||||
true /* shrinkNonAdaptiveIcons */).icon;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.wm.shell.bubbles;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -48,7 +47,7 @@ public interface BubbleViewProvider {
|
||||
Bitmap getBubbleIcon();
|
||||
|
||||
/** App badge drawable to draw above bubble icon. */
|
||||
@Nullable Drawable getAppBadge();
|
||||
@Nullable Bitmap getAppBadge();
|
||||
|
||||
/** Path of normalized bubble icon to draw dot on. */
|
||||
Path getDotPath();
|
||||
|
||||
Reference in New Issue
Block a user