From 190d58d621a6d520db5fce840b07d26e4984e1f5 Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Thu, 15 May 2014 09:33:39 -0400 Subject: [PATCH] Badge largeIcons with the notification icon. The old right-hand small icon is no more; instead the notification's small icon is overlaid atop the largeIcon bitmap. If the small icon would have had a colored circle background applied to it in the large left-hand slot, it gets a similar treatment when used as a badge. Change-Id: I8b262afbdd4faab2beffd294d662f4759f35f3b3 --- core/java/android/app/Notification.java | 49 +++++++++++++--------- .../layout/notification_template_icon_group.xml | 42 +++++++++++++++++++ .../layout/notification_template_quantum_base.xml | 13 +----- .../notification_template_quantum_big_base.xml | 13 +----- .../notification_template_quantum_big_text.xml | 13 +----- .../layout/notification_template_quantum_inbox.xml | 13 +----- core/res/res/values/symbols.xml | 2 + 7 files changed, 78 insertions(+), 67 deletions(-) create mode 100644 core/res/res/layout/notification_template_icon_group.xml diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 76a6a8e71fd7..3b234bebff8f 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1889,26 +1889,20 @@ public class Notification implements Parcelable RemoteViews contentView = new RemoteViews(mContext.getPackageName(), resId); boolean showLine3 = false; boolean showLine2 = false; - int smallIconImageViewId = R.id.icon; + if (mPriority < PRIORITY_LOW) { // TODO: Low priority presentation } if (mLargeIcon != null) { contentView.setImageViewBitmap(R.id.icon, mLargeIcon); processLargeIcon(mLargeIcon, contentView); - smallIconImageViewId = R.id.right_icon; - } - if (mSmallIcon != 0) { - contentView.setImageViewResource(smallIconImageViewId, mSmallIcon); - contentView.setViewVisibility(smallIconImageViewId, View.VISIBLE); - if (mLargeIcon != null) { - processSmallRightIcon(mSmallIcon, smallIconImageViewId, contentView); - } else { - processSmallIconAsLarge(mSmallIcon, contentView); - } - - } else { - contentView.setViewVisibility(smallIconImageViewId, View.GONE); + contentView.setImageViewResource(R.id.right_icon, mSmallIcon); + contentView.setViewVisibility(R.id.right_icon, View.VISIBLE); + processSmallRightIcon(mSmallIcon, contentView); + } else { // small icon at left + contentView.setImageViewResource(R.id.icon, mSmallIcon); + contentView.setViewVisibility(R.id.icon, View.VISIBLE); + processSmallIconAsLarge(mSmallIcon, contentView); } if (mContentTitle != null) { contentView.setTextViewText(R.id.title, processLegacyText(mContentTitle)); @@ -2103,6 +2097,8 @@ public class Notification implements Parcelable private void processLargeIcon(Bitmap largeIcon, RemoteViews contentView) { if (!isLegacy() || mColorUtil.isGrayscale(largeIcon)) { applyLargeIconBackground(contentView); + } else { + removeLargeIconBackground(contentView); } } @@ -2122,16 +2118,31 @@ public class Notification implements Parcelable -1); } + private void removeLargeIconBackground(RemoteViews contentView) { + contentView.setInt(R.id.icon, "setBackgroundResource", 0); + } + /** * Recolor small icons when used in the R.id.right_icon slot. */ - private void processSmallRightIcon(int smallIconDrawableId, int smallIconImageViewId, + private void processSmallRightIcon(int smallIconDrawableId, RemoteViews contentView) { if (!isLegacy() || mColorUtil.isGrayscale(mContext, smallIconDrawableId)) { - contentView.setDrawableParameters(smallIconImageViewId, false, -1, - mContext.getResources().getColor( - R.color.notification_action_legacy_color_filter), - PorterDuff.Mode.MULTIPLY, -1); + contentView.setDrawableParameters(R.id.right_icon, false, -1, + 0xFFFFFFFF, + PorterDuff.Mode.SRC_ATOP, -1); + + contentView.setInt(R.id.right_icon, + "setBackgroundResource", + R.drawable.notification_icon_legacy_bg); + + contentView.setDrawableParameters( + R.id.right_icon, + true, + -1, + mColor, + PorterDuff.Mode.SRC_ATOP, + -1); } } diff --git a/core/res/res/layout/notification_template_icon_group.xml b/core/res/res/layout/notification_template_icon_group.xml new file mode 100644 index 000000000000..2ad6f9ef82fa --- /dev/null +++ b/core/res/res/layout/notification_template_icon_group.xml @@ -0,0 +1,42 @@ + + + + + + + + diff --git a/core/res/res/layout/notification_template_quantum_base.xml b/core/res/res/layout/notification_template_quantum_base.xml index 8f3019d829f0..07fe0beba160 100644 --- a/core/res/res/layout/notification_template_quantum_base.xml +++ b/core/res/res/layout/notification_template_quantum_base.xml @@ -23,10 +23,9 @@ internal:layout_minHeight="64dp" internal:layout_maxHeight="64dp" > - - diff --git a/core/res/res/layout/notification_template_quantum_big_base.xml b/core/res/res/layout/notification_template_quantum_big_base.xml index 45e69b12fd7b..8cb55494d48c 100644 --- a/core/res/res/layout/notification_template_quantum_big_base.xml +++ b/core/res/res/layout/notification_template_quantum_big_base.xml @@ -23,10 +23,9 @@ internal:layout_minHeight="65dp" internal:layout_maxHeight="unbounded" > - - - - diff --git a/core/res/res/layout/notification_template_quantum_inbox.xml b/core/res/res/layout/notification_template_quantum_inbox.xml index 04974c49dc54..a071d59fa596 100644 --- a/core/res/res/layout/notification_template_quantum_inbox.xml +++ b/core/res/res/layout/notification_template_quantum_inbox.xml @@ -23,10 +23,9 @@ internal:layout_minHeight="65dp" internal:layout_maxHeight="unbounded" > - - diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index c5013b33a9fb..2f0ac49913b7 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1658,8 +1658,10 @@ + + -- 2.11.0