Merge "MessagingStyle: Generate EXTRA_TITLE and EXTRA_TEXT" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-06-01 17:01:58 +00:00
committed by Android (Google) Code Review
3 changed files with 38 additions and 0 deletions

View File

@@ -4479,6 +4479,35 @@ public class Notification implements Parcelable
if (!mMessages.isEmpty()) { extras.putParcelableArray(EXTRA_MESSAGES,
Message.getBundleArrayForMessages(mMessages));
}
fixTitleAndTextExtras(extras);
}
private void fixTitleAndTextExtras(Bundle extras) {
Message m = findLatestIncomingMessage();
CharSequence text = (m == null) ? null : m.mText;
CharSequence sender = m == null ? null
: TextUtils.isEmpty(m.mSender) ? mUserDisplayName : m.mSender;
CharSequence title;
if (!TextUtils.isEmpty(mConversationTitle)) {
if (!TextUtils.isEmpty(sender)) {
BidiFormatter bidi = BidiFormatter.getInstance();
title = mBuilder.mContext.getString(
com.android.internal.R.string.notification_messaging_title_template,
bidi.unicodeWrap(mConversationTitle), bidi.unicodeWrap(m.mSender));
} else {
title = mConversationTitle;
}
} else {
title = sender;
}
if (title != null) {
extras.putCharSequence(EXTRA_TITLE, title);
}
if (text != null) {
extras.putCharSequence(EXTRA_TEXT, text);
}
}
/**
@@ -4524,6 +4553,10 @@ public class Notification implements Parcelable
return m;
}
}
if (!mMessages.isEmpty()) {
// No incoming messages, fall back to outgoing message
return mMessages.get(mMessages.size() - 1);
}
return null;
}

View File

@@ -4289,6 +4289,10 @@
DO NOT TRANSLATE -->
<string name="notification_inbox_ellipsis">\u2026</string>
<!-- Tempalate for Notification.MessagingStyle to join a conversation name with the name of the sender of a message, to make a notification title [CHAR LIMIT=NONE] -->
<string name="notification_messaging_title_template"><xliff:g id="conversation_title" example="Tasty Treat Team">%1$s</xliff:g>: <xliff:g id="sender_name" example="Adrian Baker">%2$s</xliff:g></string>
<!-- Label describing the number of selected items [CHAR LIMIT=48] -->
<plurals name="selected_count">
<item quantity="one"><xliff:g id="count" example="1">%1$d</xliff:g> selected</item>

View File

@@ -2598,6 +2598,7 @@
<!-- TV Remote Service package -->
<java-symbol type="string" name="config_tvRemoteServicePackage" />
<java-symbol type="string" name="notification_messaging_title_template" />
<java-symbol type="bool" name="config_supportPreRebootSecurityLogs" />