From 054c5dcf4a2b45d3e1e8a32ceb2014d50f8790ab Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 17 Nov 2015 15:36:30 -0500 Subject: [PATCH] Notifications can only have 1 topic. Change-Id: Id0ab6bca352b969431d4ba68167074e514a98980 --- api/current.txt | 4 +-- api/system-current.txt | 4 +-- core/java/android/app/Notification.java | 53 +++++++++++++-------------------- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/api/current.txt b/api/current.txt index e7627f7a4c4a..620864060898 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4795,7 +4795,7 @@ package android.app { method public android.graphics.drawable.Icon getLargeIcon(); method public android.graphics.drawable.Icon getSmallIcon(); method public java.lang.String getSortKey(); - method public android.app.Notification.Topic[] getTopics(); + method public android.app.Notification.Topic getTopic(); method public void writeToParcel(android.os.Parcel, int); field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT; field public static final java.lang.String CATEGORY_ALARM = "alarm"; @@ -4960,7 +4960,6 @@ package android.app { method public android.app.Notification.Builder addAction(android.app.Notification.Action); method public android.app.Notification.Builder addExtras(android.os.Bundle); method public android.app.Notification.Builder addPerson(java.lang.String); - method public android.app.Notification.Builder addTopic(android.app.Notification.Topic); method public android.app.Notification build(); method public android.app.Notification.Builder extend(android.app.Notification.Extender); method public android.os.Bundle getExtras(); @@ -5009,6 +5008,7 @@ package android.app { method public android.app.Notification.Builder setSubText(java.lang.CharSequence); method public android.app.Notification.Builder setTicker(java.lang.CharSequence); method public deprecated android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews); + method public android.app.Notification.Builder setTopic(android.app.Notification.Topic); method public android.app.Notification.Builder setUsesChronometer(boolean); method public android.app.Notification.Builder setVibrate(long[]); method public android.app.Notification.Builder setVisibility(int); diff --git a/api/system-current.txt b/api/system-current.txt index 203df9073e8b..fc11f34314b5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4913,7 +4913,7 @@ package android.app { method public android.graphics.drawable.Icon getLargeIcon(); method public android.graphics.drawable.Icon getSmallIcon(); method public java.lang.String getSortKey(); - method public android.app.Notification.Topic[] getTopics(); + method public android.app.Notification.Topic getTopic(); method public void writeToParcel(android.os.Parcel, int); field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT; field public static final java.lang.String CATEGORY_ALARM = "alarm"; @@ -5078,7 +5078,6 @@ package android.app { method public android.app.Notification.Builder addAction(android.app.Notification.Action); method public android.app.Notification.Builder addExtras(android.os.Bundle); method public android.app.Notification.Builder addPerson(java.lang.String); - method public android.app.Notification.Builder addTopic(android.app.Notification.Topic); method public android.app.Notification build(); method public android.app.Notification.Builder extend(android.app.Notification.Extender); method public android.os.Bundle getExtras(); @@ -5127,6 +5126,7 @@ package android.app { method public android.app.Notification.Builder setSubText(java.lang.CharSequence); method public android.app.Notification.Builder setTicker(java.lang.CharSequence); method public deprecated android.app.Notification.Builder setTicker(java.lang.CharSequence, android.widget.RemoteViews); + method public android.app.Notification.Builder setTopic(android.app.Notification.Topic); method public android.app.Notification.Builder setUsesChronometer(boolean); method public android.app.Notification.Builder setVibrate(long[]); method public android.app.Notification.Builder setVisibility(int); diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 0b77be3eda20..b5b77e65f442 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1466,10 +1466,10 @@ public class Notification implements Parcelable }; } - private Topic[] topics; + private Topic topic; - public Topic[] getTopics() { - return topics; + public Topic getTopic() { + return topic; } /** @@ -1599,7 +1599,9 @@ public class Notification implements Parcelable color = parcel.readInt(); - topics = parcel.createTypedArray(Topic.CREATOR); // may be null + if (parcel.readInt() != 0) { + topic = Topic.CREATOR.createFromParcel(parcel); + } } @Override @@ -1700,11 +1702,8 @@ public class Notification implements Parcelable that.color = this.color; - if (this.topics != null) { - that.topics = new Topic[this.topics.length]; - for(int i=0; i 0) { - for (int i = 0; i < N-1; i++) { - sb.append(topics[i]); - sb.append(','); - } - sb.append(topics[N-1]); - } - sb.append("]"); + if (topic != null) { + sb.append("topic="); + sb.append(topic.toString()); } sb.append(")"); return sb.toString(); @@ -2136,7 +2132,6 @@ public class Notification implements Parcelable private ArrayList mPersonList = new ArrayList(); private NotificationColorUtil mColorUtil; private boolean mColorUtilInited = false; - private List mTopics = new ArrayList<>(); /** * The user that built the notification originally. @@ -2187,10 +2182,6 @@ public class Notification implements Parcelable Collections.addAll(mPersonList, mN.extras.getStringArray(EXTRA_PEOPLE)); } - if (mN.getTopics() != null) { - Collections.addAll(mTopics, mN.getTopics()); - } - String templateClass = mN.extras.getString(EXTRA_TEMPLATE); if (!TextUtils.isEmpty(templateClass)) { final Class styleClass @@ -2962,15 +2953,15 @@ public class Notification implements Parcelable } /** - * Add a topic to this notification. Topics are typically displayed in Notification + * Sets the topic of this notification. Topics are typically displayed in Notification * settings. *

* Every topic must have an id and a textual label. * * @param topic The topic to add. */ - public Builder addTopic(Topic topic) { - mTopics.add(topic); + public Builder setTopic(Topic topic) { + mN.topic = topic; return this; } @@ -3452,10 +3443,6 @@ public class Notification implements Parcelable mN.extras.putStringArray(EXTRA_PEOPLE, mPersonList.toArray(new String[mPersonList.size()])); } - if (mTopics.size() > 0) { - mN.topics = new Topic[mTopics.size()]; - mTopics.toArray(mN.topics); - } return mN; } -- 2.11.0