Merge "MessagingStyle: Generate EXTRA_TITLE and EXTRA_TEXT" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ff39d3ec2f
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user