diff options
author | Dan Sandler <dsandler@android.com> | 2014-05-16 15:18:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-16 15:18:40 +0000 |
commit | 4ec3b0f9ab957960a8ce88a4fc41aa66817fd749 (patch) | |
tree | cd1312573a1750856c65ea6cfedf12b7591523c5 /core | |
parent | 3242f51c936d804c5308971a8cc10a251f9690fe (diff) | |
parent | 190d58d621a6d520db5fce840b07d26e4984e1f5 (diff) | |
download | frameworks_base-4ec3b0f9ab957960a8ce88a4fc41aa66817fd749.zip frameworks_base-4ec3b0f9ab957960a8ce88a4fc41aa66817fd749.tar.gz frameworks_base-4ec3b0f9ab957960a8ce88a4fc41aa66817fd749.tar.bz2 |
Merge "Badge largeIcons with the notification icon."
Diffstat (limited to 'core')
7 files changed, 78 insertions, 67 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 76a6a8e..3b234be 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 0000000..2ad6f9e --- /dev/null +++ b/core/res/res/layout/notification_template_icon_group.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2014 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> + +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:internal="http://schemas.android.com/apk/prv/res/android" + android:layout_width="@dimen/notification_large_icon_width" + android:layout_height="@dimen/notification_large_icon_height" + android:id="@+id/icon_group" + > + <ImageView android:id="@+id/icon" + android:layout_width="@dimen/notification_large_icon_width" + android:layout_height="@dimen/notification_large_icon_height" + android:padding="8dp" + android:scaleType="centerInside" + /> + <ImageView android:id="@+id/right_icon" + android:layout_width="24dp" + android:layout_height="24dp" + android:padding="4dp" + android:layout_gravity="end|bottom" + android:scaleType="centerInside" + android:visibility="gone" + android:layout_marginEnd="3dp" + android:layout_marginBottom="3dp" + /> +</FrameLayout> + diff --git a/core/res/res/layout/notification_template_quantum_base.xml b/core/res/res/layout/notification_template_quantum_base.xml index 8f3019d..07fe0be 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" > - <ImageView android:id="@+id/icon" + <include layout="@layout/notification_template_icon_group" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" - android:scaleType="center" /> <LinearLayout android:layout_width="match_parent" @@ -121,16 +120,6 @@ android:gravity="center" android:paddingStart="8dp" /> - <ImageView android:id="@+id/right_icon" - android:layout_width="16dp" - android:layout_height="16dp" - android:layout_gravity="center" - android:layout_weight="0" - android:layout_marginStart="8dp" - android:scaleType="centerInside" - android:visibility="gone" - android:drawableAlpha="153" - /> </LinearLayout> </LinearLayout> </FrameLayout> 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 45e69b1..8cb5549 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" > - <ImageView android:id="@+id/icon" + <include layout="@layout/notification_template_icon_group" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" - android:scaleType="center" /> <LinearLayout android:layout_width="match_parent" @@ -128,16 +127,6 @@ android:gravity="center" android:paddingStart="8dp" /> - <ImageView android:id="@+id/right_icon" - android:layout_width="16dp" - android:layout_height="16dp" - android:layout_gravity="center" - android:layout_weight="0" - android:layout_marginStart="8dp" - android:scaleType="centerInside" - android:visibility="gone" - android:drawableAlpha="153" - /> </LinearLayout> <ProgressBar android:id="@android:id/progress" diff --git a/core/res/res/layout/notification_template_quantum_big_text.xml b/core/res/res/layout/notification_template_quantum_big_text.xml index f7769d7..bbd1071 100644 --- a/core/res/res/layout/notification_template_quantum_big_text.xml +++ b/core/res/res/layout/notification_template_quantum_big_text.xml @@ -22,10 +22,9 @@ internal:layout_minHeight="65dp" internal:layout_maxHeight="unbounded" > - <ImageView android:id="@+id/icon" + <include layout="@layout/notification_template_icon_group" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" - android:scaleType="center" /> <LinearLayout android:layout_width="match_parent" @@ -166,16 +165,6 @@ android:gravity="center" android:paddingStart="8dp" /> - <ImageView android:id="@+id/right_icon" - android:layout_width="16dp" - android:layout_height="16dp" - android:layout_gravity="center" - android:layout_weight="0" - android:layout_marginStart="8dp" - android:scaleType="centerInside" - android:visibility="gone" - android:drawableAlpha="153" - /> </LinearLayout> </LinearLayout> </FrameLayout> diff --git a/core/res/res/layout/notification_template_quantum_inbox.xml b/core/res/res/layout/notification_template_quantum_inbox.xml index 04974c4..a071d59 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" > - <ImageView android:id="@+id/icon" + <include layout="@layout/notification_template_icon_group" android:layout_width="@dimen/notification_large_icon_width" android:layout_height="@dimen/notification_large_icon_height" - android:scaleType="center" /> <LinearLayout android:layout_width="match_parent" @@ -250,16 +249,6 @@ android:gravity="center" android:paddingStart="8dp" /> - <ImageView android:id="@+id/right_icon" - android:layout_width="16dp" - android:layout_height="16dp" - android:layout_gravity="center" - android:layout_weight="0" - android:layout_marginStart="8dp" - android:scaleType="centerInside" - android:visibility="gone" - android:drawableAlpha="153" - /> </LinearLayout> </LinearLayout> </FrameLayout> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index c5013b3..2f0ac49 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1658,8 +1658,10 @@ <java-symbol type="layout" name="notification_template_quantum_big_picture" /> <java-symbol type="layout" name="notification_template_quantum_big_text" /> <java-symbol type="layout" name="notification_template_quantum_inbox" /> + <java-symbol type="layout" name="notification_template_icon_group" /> <java-symbol type="color" name="notification_action_legacy_color_filter" /> <java-symbol type="color" name="notification_icon_bg_color" /> + <java-symbol type="drawable" name="notification_icon_legacy_bg" /> <java-symbol type="drawable" name="notification_icon_legacy_bg_inset" /> <java-symbol type="drawable" name="notification_quantum_bg_dim" /> <java-symbol type="drawable" name="notification_quantum_bg" /> |