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

Commit 9951e920 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[Minimal HUN] Apply colon treatment to Messaging Title

This CL puts colon character before message content and apply developer settings to choose different conversation title
selection, which are conversation title with sender and sender only.

Bug: 336229954
Flag: ACONFIG android.app.Flags.compact_heads_up_notification DISABLED
Test: SystemUITest and manual

Change-Id: I6d3efee562885df358d4384b84d340a54cbb2321
parent 3cbc2ecb
Loading
Loading
Loading
Loading
+61 −5
Original line number Diff line number Diff line
@@ -8887,6 +8887,62 @@ public class Notification implements Parcelable
            }
        }
        private void fixTitleAndTextForCompactMessaging(StandardTemplateParams p) {
            Message m = findLatestIncomingMessage();
            final CharSequence text = (m == null) ? null : m.mText;
            CharSequence sender = m == null ? null
                    : m.mSender == null || TextUtils.isEmpty(m.mSender.getName())
                            ? mUser.getName() : m.mSender.getName();
            CharSequence conversationTitle = mIsGroupConversation ? mConversationTitle : null;
            // we want to have colon for possible title for conversation.
            final BidiFormatter bidi = BidiFormatter.getInstance();
            if (sender != null) {
                sender = mBuilder.mContext.getString(
                        com.android.internal.R.string.notification_messaging_title_template,
                        bidi.unicodeWrap(sender), "");
            } else if (conversationTitle != null) {
                conversationTitle = mBuilder.mContext.getString(
                        com.android.internal.R.string.notification_messaging_title_template,
                        bidi.unicodeWrap(conversationTitle), "");
            }
            if (Flags.cleanUpSpansAndNewLines()) {
                conversationTitle = stripStyling(conversationTitle);
                sender = stripStyling(sender);
            }
            final boolean showOnlySenderName = showOnlySenderName();
            final CharSequence title;
            boolean isConversationTitleAvailable = !showOnlySenderName && conversationTitle != null;
            if (isConversationTitleAvailable) {
                title = conversationTitle;
            } else {
                title = sender;
            }
            p.title(title);
            // when the conversation title is available, use headerTextSecondary for sender and
            // summaryText for text
            if (isConversationTitleAvailable) {
                p.headerTextSecondary(sender);
                p.summaryText(text);
            } else {
                // when it is not, use headerTextSecondary for text and don't use summaryText
                p.headerTextSecondary(text);
                p.summaryText(null);
            }
        }
        /** developer settings to always show sender name */
        private boolean showOnlySenderName() {
            return SystemProperties.getBoolean(
                    "persist.compact_heads_up_notification.show_only_sender_name",
                    false);
        }
        /**
         * @hide
         */
@@ -9206,19 +9262,19 @@ public class Notification implements Parcelable
                }
            }
            // This method fills title and text
            fixTitleAndTextExtras(mBuilder.mN.extras);
            final StandardTemplateParams p = mBuilder.mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_HEADS_UP)
                    .highlightExpander(isConversationLayout)
                    .fillTextsFrom(mBuilder)
                    .hideTime(true)
                    .summaryText("");
            p.headerTextSecondary(p.mText);
                    .hideTime(true);
            fixTitleAndTextForCompactMessaging(p);
            TemplateBindResult bindResult = new TemplateBindResult();
            RemoteViews contentView = mBuilder.applyStandardTemplate(
                    mBuilder.getMessagingCompactHeadsUpLayoutResource(), p, bindResult);
            contentView.setViewVisibility(R.id.header_text_secondary_divider, View.GONE);
            contentView.setViewVisibility(R.id.header_text_divider, View.GONE);
            if (conversationIcon != null) {
                contentView.setViewVisibility(R.id.icon, View.GONE);
                contentView.setViewVisibility(R.id.conversation_icon, View.VISIBLE);