diff options
| author | Kodlee Yin <kodlee@google.com> | 2018-01-09 18:22:07 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-01-09 18:22:07 +0000 |
| commit | 245a749dd62e620f4413abe03bdfb75fa3560ea4 (patch) | |
| tree | 3482dd6d28790e739f70e24cb5564b576d3b9175 /core/java/android | |
| parent | 26d5b41fdbb5fe9f42dd33d78ccafd2ea8e38aff (diff) | |
| parent | 14656423a630679dd7cf7334e50d0f52035d9faf (diff) | |
Merge "Fix compatibility in MessagingStyle."
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/Notification.java | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 85c3be826c0d..046a128cc81e 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5994,8 +5994,15 @@ public class Notification implements Parcelable /** * Sets the title to be displayed on this conversation. May be set to {@code null}. * - * @param conversationTitle A name for the conversation, or {@code null} - * @return this object for method chaining. + * <p>This API's behavior was changed in SDK version {@link Build.VERSION_CODES#P}. If your + * application's target version is less than {@link Build.VERSION_CODES#P}, setting a + * conversation title to a non-null value will make {@link #isGroupConversation()} return + * {@code true} and passing {@code null} will make it return {@code false}. In + * {@link Build.VERSION_CODES#P} and beyond, use {@link #setGroupConversation(boolean)} + * to set group conversation status. + * + * @param conversationTitle Title displayed for this conversation + * @return this object for method chaining */ public MessagingStyle setConversationTitle(@Nullable CharSequence conversationTitle) { mConversationTitle = conversationTitle; @@ -6083,6 +6090,7 @@ public class Notification implements Parcelable /** * Sets whether this conversation notification represents a group. + * * @param isGroupConversation {@code true} if the conversation represents a group, * {@code false} otherwise. * @return this object for method chaining @@ -6093,9 +6101,27 @@ public class Notification implements Parcelable } /** - * Returns {@code true} if this notification represents a group conversation. + * Returns {@code true} if this notification represents a group conversation, otherwise + * {@code false}. + * + * <p> If the application that generated this {@link MessagingStyle} targets an SDK version + * less than {@link Build.VERSION_CODES#P}, this method becomes dependent on whether or + * not the conversation title is set; returning {@code true} if the conversation title is + * a non-null value, or {@code false} otherwise. From {@link Build.VERSION_CODES#P} forward, + * this method returns what's set by {@link #setGroupConversation(boolean)} allowing for + * named, non-group conversations. + * + * @see #setConversationTitle(CharSequence) */ public boolean isGroupConversation() { + // When target SDK version is < P, a non-null conversation title dictates if this is + // as group conversation. + if (mBuilder != null + && mBuilder.mContext.getApplicationInfo().targetSdkVersion + < Build.VERSION_CODES.P) { + return mConversationTitle != null; + } + return mIsGroupConversation; } |
