summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSelim Cinek <cinek@google.com>2017-10-24 16:17:14 -0700
committerSelim Cinek <cinek@google.com>2017-11-06 16:22:08 -0800
commitf7409dbbb24b454428887a28caaa33bd9867cebf (patch)
tree54c29a6e6185626e40ee59a97d4930a7768d77cb /core/java/android
parent1d6b50eccf3b608a34a2a92f46c7ee8b8641e0e4 (diff)
Fixed the handling of oneToOne conversations for certain apps
Certain apps were using specific white-spaces in order to get an effect they wanted on the old messaging style. We're now fixing that to ensure that the transition is smoothed Test: manual send messages using multiple apps Bug: 63708826 Change-Id: Ie8628c5b394b974f3dfcbbc6f26a7f50bc60a7b9
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Notification.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 7fb2c7d86a7f..d5d95fb85a6a 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -6129,6 +6129,8 @@ public class Notification implements Parcelable
// Let's add the conversationTitle in case we didn't have one before and all
// messages are from the same sender
conversationTitle = createConversationTitleFromMessages();
+ } else if (hasOnlyWhiteSpaceSenders()) {
+ isOneToOne = true;
}
boolean hasTitle = !TextUtils.isEmpty(conversationTitle);
RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
@@ -6147,6 +6149,35 @@ public class Notification implements Parcelable
return contentView;
}
+ private boolean hasOnlyWhiteSpaceSenders() {
+ for (int i = 0; i < mMessages.size(); i++) {
+ Message m = mMessages.get(i);
+ CharSequence sender = m.getSender();
+ if (!isWhiteSpace(sender)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isWhiteSpace(CharSequence sender) {
+ if (TextUtils.isEmpty(sender)) {
+ return true;
+ }
+ if (sender.toString().matches("^\\s*$")) {
+ return true;
+ }
+ // Let's check if we only have 0 whitespace chars. Some apps did this as a workaround
+ // For the presentation that we had.
+ for (int i = 0; i < sender.length(); i++) {
+ char c = sender.charAt(i);
+ if (c != '\u200B') {
+ return false;
+ }
+ }
+ return true;
+ }
+
private CharSequence createConversationTitleFromMessages() {
ArraySet<CharSequence> names = new ArraySet<>();
for (int i = 0; i < mMessages.size(); i++) {