Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7409dbb authored by Selim Cinek's avatar Selim Cinek
Browse files

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
parent 1d6b50ec
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -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++) {