diff options
Diffstat (limited to 'core/java')
| -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; } |
