Add support for color extracted notification dots
Changing the badge_color in colors.xml to transparent
will cause them to be color extracted.
When an extracted color is used in the IconPalette, we
desaturate the background. Otherwise we respect the
exact color specified in colors.xml.
Change-Id: Ie82d0c5335fa5f24d4cc47766e4c1719c4916f8b
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 94c7e07..3c3e224 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -96,7 +96,7 @@
private BadgeInfo mBadgeInfo;
private BadgeRenderer mBadgeRenderer;
- private IconPalette mIconPalette;
+ private IconPalette mBadgePalette;
private float mBadgeScale;
private boolean mForceHideBadge;
private Point mTempSpaceForBadgeOffset = new Point();
@@ -453,7 +453,7 @@
final int scrollX = getScrollX();
final int scrollY = getScrollY();
canvas.translate(scrollX, scrollY);
- mBadgeRenderer.draw(canvas, mBadgeInfo, mTempIconBounds, mBadgeScale,
+ mBadgeRenderer.draw(canvas, mBadgePalette, mBadgeInfo, mTempIconBounds, mBadgeScale,
mTempSpaceForBadgeOffset);
canvas.translate(-scrollX, -scrollY);
}
@@ -578,7 +578,10 @@
float newBadgeScale = isBadged ? 1f : 0;
mBadgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer;
if (wasBadged || isBadged) {
- mIconPalette = ((FastBitmapDrawable) mIcon).getIconPalette();
+ mBadgePalette = IconPalette.getBadgePalette(getResources());
+ if (mBadgePalette == null) {
+ mBadgePalette = ((FastBitmapDrawable) mIcon).getIconPalette();
+ }
// Animate when a badge is first added or when it is removed.
if (animate && (wasBadged ^ isBadged) && isShown()) {
ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, newBadgeScale).start();
@@ -590,6 +593,10 @@
}
}
+ public IconPalette getBadgePalette() {
+ return mBadgePalette;
+ }
+
/**
* Sets the icon for this view based on the layout direction.
*/