summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2017-05-16 23:34:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-05-16 23:34:52 +0000
commit02aced978285c8a78eb98ee22130cf43017a4fa6 (patch)
tree32ca13cb6dffbcf65a9ac17c5e6bb4b1655f32f2
parentd315d07aeef260ef72d57c3e04361c4106d817be (diff)
parente6a790e5ae98ecfd754638a9ff5e87ee45aad069 (diff)
downloadandroid_packages_apps_Trebuchet-02aced978285c8a78eb98ee22130cf43017a4fa6.tar.gz
android_packages_apps_Trebuchet-02aced978285c8a78eb98ee22130cf43017a4fa6.tar.bz2
android_packages_apps_Trebuchet-02aced978285c8a78eb98ee22130cf43017a4fa6.zip
Merge "Use a single color for all icon badges." into ub-launcher3-dorval
-rw-r--r--res/values/colors.xml2
-rw-r--r--src/com/android/launcher3/BubbleTextView.java2
-rw-r--r--src/com/android/launcher3/badge/BadgeRenderer.java14
-rw-r--r--src/com/android/launcher3/folder/FolderIcon.java3
-rw-r--r--src/com/android/launcher3/graphics/IconPalette.java6
5 files changed, 13 insertions, 14 deletions
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 58717c273..25893088d 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -41,6 +41,8 @@
<color name="notification_icon_default_color">#757575</color> <!-- Gray 600 -->
<color name="notification_color_beneath">#E0E0E0</color> <!-- Gray 300 -->
+ <color name="badge_color">#1DE9B6</color> <!-- Teal A400 -->
+
<!-- System shortcuts -->
<color name="system_shortcuts_icon_color">@android:color/tertiary_text_light</color>
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index cb40d3d5e..239bd2c30 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -453,7 +453,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {
final int scrollX = getScrollX();
final int scrollY = getScrollY();
canvas.translate(scrollX, scrollY);
- mBadgeRenderer.draw(canvas, mIconPalette, mBadgeInfo, mTempIconBounds, mBadgeScale,
+ mBadgeRenderer.draw(canvas, mBadgeInfo, mTempIconBounds, mBadgeScale,
mTempSpaceForBadgeOffset);
canvas.translate(-scrollX, -scrollY);
}
diff --git a/src/com/android/launcher3/badge/BadgeRenderer.java b/src/com/android/launcher3/badge/BadgeRenderer.java
index ba1977af4..adde4a2fc 100644
--- a/src/com/android/launcher3/badge/BadgeRenderer.java
+++ b/src/com/android/launcher3/badge/BadgeRenderer.java
@@ -63,6 +63,7 @@ public class BadgeRenderer {
private final Paint mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG
| Paint.FILTER_BITMAP_FLAG);
private final SparseArray<Bitmap> mBackgroundsWithShadow;
+ private final IconPalette mIconPalette;
public BadgeRenderer(Context context, int iconSizePx) {
mContext = context;
@@ -82,24 +83,25 @@ public class BadgeRenderer {
mTextHeight = tempTextHeight.height();
mBackgroundsWithShadow = new SparseArray<>(3);
+
+ mIconPalette = IconPalette.fromDominantColor(context.getColor(R.color.badge_color));
}
/**
* Draw a circle in the top right corner of the given bounds, and draw
* {@link BadgeInfo#getNotificationCount()} on top of the circle.
- * @param palette The colors (based on the icon) to use for the badge.
* @param badgeInfo Contains data to draw on the badge. Could be null if we are animating out.
* @param iconBounds The bounds of the icon being badged.
* @param badgeScale The progress of the animation, from 0 to 1.
* @param spaceForOffset How much space is available to offset the badge up and to the right.
*/
- public void draw(Canvas canvas, IconPalette palette, @Nullable BadgeInfo badgeInfo,
+ public void draw(Canvas canvas, @Nullable BadgeInfo badgeInfo,
Rect iconBounds, float badgeScale, Point spaceForOffset) {
- mTextPaint.setColor(palette.textColor);
+ mTextPaint.setColor(mIconPalette.textColor);
IconDrawer iconDrawer = badgeInfo != null && badgeInfo.isIconLarge()
? mLargeIconDrawer : mSmallIconDrawer;
Shader icon = badgeInfo == null ? null : badgeInfo.getNotificationIconForBadge(
- mContext, palette.backgroundColor, mSize, iconDrawer.mPadding);
+ mContext, mIconPalette.backgroundColor, mSize, iconDrawer.mPadding);
String notificationCount = badgeInfo == null ? "0"
: String.valueOf(badgeInfo.getNotificationCount());
int numChars = notificationCount.length();
@@ -125,7 +127,7 @@ public class BadgeRenderer {
canvas.translate(badgeCenterX + offsetX, badgeCenterY - offsetY);
canvas.scale(badgeScale, badgeScale);
// Prepare the background and shadow and possible stacking effect.
- mBackgroundPaint.setColorFilter(palette.backgroundColorMatrixFilter);
+ mBackgroundPaint.setColorFilter(mIconPalette.backgroundColorMatrixFilter);
int backgroundWithShadowSize = backgroundWithShadow.getHeight(); // Same as width.
boolean shouldStack = !isDot && badgeInfo != null
&& badgeInfo.getNotificationKeys().size() > 1;
@@ -147,7 +149,7 @@ public class BadgeRenderer {
-backgroundWithShadowSize / 2, mBackgroundPaint);
iconDrawer.drawIcon(icon, canvas);
} else if (isDot) {
- mBackgroundPaint.setColorFilter(palette.saturatedBackgroundColorMatrixFilter);
+ mBackgroundPaint.setColorFilter(mIconPalette.saturatedBackgroundColorMatrixFilter);
canvas.drawBitmap(backgroundWithShadow, -backgroundWithShadowSize / 2,
-backgroundWithShadowSize / 2, mBackgroundPaint);
}
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 25123fb1d..0b356b52c 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -75,7 +75,6 @@ import com.android.launcher3.badge.FolderBadgeInfo;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
-import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -886,7 +885,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
// If we are animating to the accepting state, animate the badge out.
float badgeScale = Math.max(0, mBadgeScale - mBackground.getScaleProgress());
mTempSpaceForBadgeOffset.set(getWidth() - mTempBounds.right, mTempBounds.top);
- mBadgeRenderer.draw(canvas, IconPalette.FOLDER_ICON_PALETTE, mBadgeInfo, mTempBounds,
+ mBadgeRenderer.draw(canvas, mBadgeInfo, mTempBounds,
badgeScale, mTempSpaceForBadgeOffset);
}
}
diff --git a/src/com/android/launcher3/graphics/IconPalette.java b/src/com/android/launcher3/graphics/IconPalette.java
index 0182e53b9..60ca7b236 100644
--- a/src/com/android/launcher3/graphics/IconPalette.java
+++ b/src/com/android/launcher3/graphics/IconPalette.java
@@ -49,7 +49,7 @@ public class IconPalette {
private IconPalette(int color) {
dominantColor = color;
- backgroundColor = getMutedColor(dominantColor);
+ backgroundColor = dominantColor;
ColorMatrix backgroundColorMatrix = new ColorMatrix();
Themes.setColorScaleOnMatrix(backgroundColor, backgroundColorMatrix);
backgroundColorMatrixFilter = new ColorMatrixColorFilter(backgroundColorMatrix);
@@ -176,10 +176,6 @@ public class IconPalette {
return ColorUtils.LABToColor(low, a, b);
}
- private static int getMutedColor(int color) {
- return getMutedColor(color, 0.87f);
- }
-
private static int getMutedColor(int color, float whiteScrimAlpha) {
int whiteScrim = ColorUtils.setAlphaComponent(Color.WHITE, (int) (255 * whiteScrimAlpha));
return ColorUtils.compositeColors(whiteScrim, color);