List of usage examples for android.text SpannableStringBuilder toString
@Override
public String toString()
From source file:Main.java
public static CharSequence htmlfrom(CharSequence text) { Pattern htmlflag1 = Pattern.compile("<(.*?)>"); SpannableStringBuilder builder = new SpannableStringBuilder(text); Matcher matcher = htmlflag1.matcher(text); while (matcher.find()) { builder.delete(matcher.start(), matcher.end()); text = builder;//w ww. j av a 2 s . c o m matcher = htmlflag1.matcher(text); } Pattern htmlflag2 = Pattern.compile("&(.*?);"); matcher = htmlflag2.matcher(text); while (matcher.find()) { builder.delete(matcher.start(), matcher.end()); text = builder; matcher = htmlflag2.matcher(text); } return builder.toString(); }
From source file:org.kontalk.ui.view.TextContentView.java
private SpannableStringBuilder formatMessage(final Pattern highlight) { SpannableStringBuilder buf; String textContent = mComponent.getContent(); buf = new SpannableStringBuilder(textContent); if (highlight != null) { Matcher m = highlight.matcher(buf.toString()); while (m.find()) buf.setSpan(mHighlightColorSpan, m.start(), m.end(), 0); }/* w w w. j a v a2 s. c o m*/ return buf; }
From source file:com.android.screenspeak.formatter.EventSpeechRule.java
/** * Returns the text content of a given <code>node</code> by performing a * preorder traversal of the tree rooted at that node. </p> Note: Android * Java implementation is not compatible with Java 5.0 which provides such a * method./*from w w w . j a v a 2 s.c om*/ * * @param node The node. * @return The text content. */ private static String getTextContent(Node node) { SpannableStringBuilder builder = sTempBuilder; getTextContentRecursive(node, builder); String text = builder.toString(); builder.delete(0, builder.length()); return text; }
From source file:ru.valle.btc.MainActivity.java
private static void setUrlSpanForAddress(String domain, String address, SpannableStringBuilder builder) { int spanBegin = builder.toString().indexOf(domain); if (spanBegin >= 0) { URLSpan urlSpan = new URLSpan("http://" + domain + "/address/" + address); builder.setSpan(urlSpan, spanBegin, spanBegin + domain.length(), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE); }/*w w w .ja v a 2 s. com*/ }
From source file:net.kourlas.voipms_sms.adapters.ConversationsRecyclerViewAdapter.java
@Override public void onBindViewHolder(ConversationViewHolder conversationViewHolder, int position) { Message message = messages.get(position); ViewSwitcher viewSwitcher = conversationViewHolder.getViewSwitcher(); viewSwitcher.setDisplayedChild(isItemChecked(position) ? 1 : 0); QuickContactBadge contactBadge = conversationViewHolder.getContactBadge(); contactBadge.assignContactFromPhone(message.getContact(), true); String photoUri = Utils.getContactPhotoUri(applicationContext, message.getContact()); if (photoUri != null) { contactBadge.setImageURI(Uri.parse(photoUri)); } else {//from ww w . j a v a 2s .c o m contactBadge.setImageToDefault(); } TextView contactTextView = conversationViewHolder.getContactTextView(); String contactName = Utils.getContactName(applicationContext, message.getContact()); SpannableStringBuilder contactTextBuilder = new SpannableStringBuilder(); if (contactName != null) { contactTextBuilder.append(contactName); } else { contactTextBuilder.append(Utils.getFormattedPhoneNumber(message.getContact())); } if (!filterConstraint.equals("")) { int index = contactTextBuilder.toString().toLowerCase().indexOf(filterConstraint.toLowerCase()); if (index != -1) { contactTextBuilder.setSpan( new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)), index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE); } } contactTextView.setText(contactTextBuilder); final TextView messageTextView = conversationViewHolder.getMessageTextView(); SpannableStringBuilder messageTextBuilder = new SpannableStringBuilder(); int index = message.getText().toLowerCase().indexOf(filterConstraint.toLowerCase()); if (!filterConstraint.equals("") && index != -1) { int nonMessageOffset = index; if (message.getType() == Message.Type.OUTGOING) { messageTextBuilder.insert(0, applicationContext.getString(R.string.conversations_message_you) + " "); nonMessageOffset += 5; } int substringOffset = index - 20; if (substringOffset > 0) { messageTextBuilder.append("..."); nonMessageOffset += 3; while (message.getText().charAt(substringOffset) != ' ' && substringOffset < index - 1) { substringOffset += 1; } substringOffset += 1; } else { substringOffset = 0; } messageTextBuilder.append(message.getText().substring(substringOffset)); messageTextBuilder.setSpan( new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)), nonMessageOffset - substringOffset, nonMessageOffset - substringOffset + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE); } else { if (message.getType() == Message.Type.OUTGOING) { messageTextBuilder.append(applicationContext.getString(R.string.conversations_message_you)); messageTextBuilder.append(" "); } messageTextBuilder.append(message.getText()); } messageTextView.setText(messageTextBuilder); if (message.isUnread()) { contactTextView.setTypeface(null, Typeface.BOLD); messageTextView.setTypeface(null, Typeface.BOLD); } else { contactTextView.setTypeface(null, Typeface.NORMAL); messageTextView.setTypeface(null, Typeface.NORMAL); } // Set date line TextView dateTextView = conversationViewHolder.getDateTextView(); if (message.isDraft()) { SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder(); dateTextBuilder.append(applicationContext.getString(R.string.conversations_message_draft)); dateTextBuilder.setSpan(new StyleSpan(Typeface.ITALIC), 0, dateTextBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); dateTextView.setText(dateTextBuilder); } else if (!message.isDelivered()) { if (!message.isDeliveryInProgress()) { SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder(); dateTextBuilder.append(applicationContext.getString(R.string.conversations_message_not_sent)); dateTextBuilder.setSpan( new ForegroundColorSpan( ContextCompat.getColor(applicationContext, android.R.color.holo_red_dark)), 0, dateTextBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); dateTextView.setText(dateTextBuilder); } else { dateTextView.setText(applicationContext.getString(R.string.conversations_message_sending)); } } else { dateTextView.setText(Utils.getFormattedDate(applicationContext, message.getDate(), true)); } }
From source file:com.owncloud.android.ui.adapter.NotificationListAdapter.java
private SpannableStringBuilder makeSpecialPartsBold(Notification notification) { String text = notification.getSubjectRich(); SpannableStringBuilder ssb = new SpannableStringBuilder(text); int openingBrace = text.indexOf('{'); int closingBrace; String replaceablePart;//from w w w .jav a 2 s . c o m while (openingBrace != -1) { closingBrace = text.indexOf('}', openingBrace) + 1; replaceablePart = text.substring(openingBrace + 1, closingBrace - 1); RichObject richObject = notification.subjectRichParameters.get(replaceablePart); if (richObject != null) { String name = richObject.getName(); ssb.replace(openingBrace, closingBrace, name); text = ssb.toString(); closingBrace = openingBrace + name.length(); ssb.setSpan(styleSpanBold, openingBrace, closingBrace, 0); ssb.setSpan(foregroundColorSpanBlack, openingBrace, closingBrace, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } openingBrace = text.indexOf('{', closingBrace); } return ssb; }
From source file:pct.droid.fragments.VideoPlayerFragment.java
@Override protected void showTimedCaptionText(final Caption text) { mDisplayHandler.post(new Runnable() { @Override/* www .j a v a 2 s . c o m*/ public void run() { if (text == null) { if (mSubtitleText.getText().length() > 0) { mSubtitleText.setText(""); } return; } SpannableStringBuilder styledString = (SpannableStringBuilder) Html.fromHtml(text.content); ForegroundColorSpan[] toRemoveSpans = styledString.getSpans(0, styledString.length(), ForegroundColorSpan.class); for (ForegroundColorSpan remove : toRemoveSpans) { styledString.removeSpan(remove); } if (!mSubtitleText.getText().toString().equals(styledString.toString())) { mSubtitleText.setText(styledString); } } }); }
From source file:org.telegram.ui.IdenticonActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*from w w w.j a v a2 s .com*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new LinearLayout(context); LinearLayout linearLayout = (LinearLayout) fragmentView; linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setWeightSum(100); linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); ImageView identiconView = new ImageView(context); identiconView.setScaleType(ImageView.ScaleType.FIT_XY); frameLayout.addView(identiconView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLinksClickable(true); textView.setClickable(true); textView.setMovementMethod(new LinkMovementMethodMy()); //textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setGravity(Gravity.CENTER); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id); if (encryptedChat != null) { IdenticonDrawable drawable = new IdenticonDrawable(); identiconView.setImageDrawable(drawable); drawable.setEncryptedChat(encryptedChat); TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id); SpannableStringBuilder hash = new SpannableStringBuilder(); if (encryptedChat.key_hash.length > 16) { String hex = Utilities.bytesToHex(encryptedChat.key_hash); for (int a = 0; a < 32; a++) { if (a != 0) { if (a % 8 == 0) { hash.append('\n'); } else if (a % 4 == 0) { hash.append(' '); } } hash.append(hex.substring(a * 2, a * 2 + 2)); hash.append(' '); } hash.append("\n\n"); } hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name))); final String url = "telegram.org"; int index = hash.toString().indexOf(url); if (index != -1) { hash.setSpan( new URLSpanReplacement( LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(hash); } return fragmentView; }
From source file:com.chen.mail.utils.NotificationUtils.java
private static void configureLatestEventInfoFromConversation(final Context context, final Account account, final FolderPreferences folderPreferences, final NotificationCompat.Builder notification, final Cursor conversationCursor, final PendingIntent clickIntent, final Intent notificationIntent, final int unreadCount, final int unseenCount, final Folder folder, final long when) { final Resources res = context.getResources(); final String notificationAccount = account.name; LogUtils.i(LOG_TAG, "Showing notification with unreadCount of %d and unseenCount of %d", unreadCount, unseenCount);/*from w ww. java2 s . com*/ String notificationTicker = null; // Boolean indicating that this notification is for a non-inbox label. final boolean isInbox = folder.folderUri.fullUri.equals(account.settings.defaultInbox); // Notification label name for user label notifications. final String notificationLabelName = isInbox ? null : folder.name; if (unseenCount > 1) { // Build the string that describes the number of new messages final String newMessagesString = res.getString(R.string.new_messages, unseenCount); // Use the default notification icon notification .setLargeIcon(getDefaultNotificationIcon(context, folder, true /* multiple new messages */)); // The ticker initially start as the new messages string. notificationTicker = newMessagesString; // The title of the notification is the new messages string notification.setContentTitle(newMessagesString); // TODO(skennedy) Can we remove this check? if (Utils.isRunningJellybeanOrLater()) { // For a new-style notification final int maxNumDigestItems = context.getResources() .getInteger(R.integer.max_num_notification_digest_items); // The body of the notification is the account name, or the label name. notification.setSubText(isInbox ? notificationAccount : notificationLabelName); final NotificationCompat.InboxStyle digest = new NotificationCompat.InboxStyle(notification); int numDigestItems = 0; do { final Conversation conversation = new Conversation(conversationCursor); if (!conversation.read) { boolean multipleUnreadThread = false; // TODO(cwren) extract this pattern into a helper Cursor cursor = null; MessageCursor messageCursor = null; try { final Uri.Builder uriBuilder = conversation.messageListUri.buildUpon(); uriBuilder.appendQueryParameter(UIProvider.LABEL_QUERY_PARAMETER, notificationLabelName); cursor = context.getContentResolver().query(uriBuilder.build(), UIProvider.MESSAGE_PROJECTION, null, null, null); messageCursor = new MessageCursor(cursor); String from = ""; String fromAddress = ""; if (messageCursor.moveToPosition(messageCursor.getCount() - 1)) { final Message message = messageCursor.getMessage(); fromAddress = message.getFrom(); if (fromAddress == null) { fromAddress = ""; } from = getDisplayableSender(fromAddress); } while (messageCursor.moveToPosition(messageCursor.getPosition() - 1)) { final Message message = messageCursor.getMessage(); if (!message.read && !fromAddress.contentEquals(message.getFrom())) { multipleUnreadThread = true; break; } } final SpannableStringBuilder sendersBuilder; if (multipleUnreadThread) { final int sendersLength = res.getInteger(R.integer.swipe_senders_length); sendersBuilder = getStyledSenders(context, conversationCursor, sendersLength, notificationAccount); } else { sendersBuilder = new SpannableStringBuilder(getWrappedFromString(from)); } final CharSequence digestLine = getSingleMessageInboxLine(context, sendersBuilder.toString(), conversation.subject, conversation.snippet); digest.addLine(digestLine); numDigestItems++; } finally { if (messageCursor != null) { messageCursor.close(); } if (cursor != null) { cursor.close(); } } } } while (numDigestItems <= maxNumDigestItems && conversationCursor.moveToNext()); } else { // The body of the notification is the account name, or the label name. notification.setContentText(isInbox ? notificationAccount : notificationLabelName); } } else { // For notifications for a single new conversation, we want to get the information from // the conversation // Move the cursor to the most recent unread conversation seekToLatestUnreadConversation(conversationCursor); final Conversation conversation = new Conversation(conversationCursor); Cursor cursor = null; MessageCursor messageCursor = null; boolean multipleUnseenThread = false; String from = null; try { final Uri uri = conversation.messageListUri.buildUpon() .appendQueryParameter(UIProvider.LABEL_QUERY_PARAMETER, folder.persistentId).build(); cursor = context.getContentResolver().query(uri, UIProvider.MESSAGE_PROJECTION, null, null, null); messageCursor = new MessageCursor(cursor); // Use the information from the last sender in the conversation that triggered // this notification. String fromAddress = ""; if (messageCursor.moveToPosition(messageCursor.getCount() - 1)) { final Message message = messageCursor.getMessage(); fromAddress = message.getFrom(); from = getDisplayableSender(fromAddress); notification.setLargeIcon(getContactIcon(context, from, getSenderAddress(fromAddress), folder)); } // Assume that the last message in this conversation is unread int firstUnseenMessagePos = messageCursor.getPosition(); while (messageCursor.moveToPosition(messageCursor.getPosition() - 1)) { final Message message = messageCursor.getMessage(); final boolean unseen = !message.seen; if (unseen) { firstUnseenMessagePos = messageCursor.getPosition(); if (!multipleUnseenThread && !fromAddress.contentEquals(message.getFrom())) { multipleUnseenThread = true; } } } // TODO(skennedy) Can we remove this check? if (Utils.isRunningJellybeanOrLater()) { // For a new-style notification if (multipleUnseenThread) { // The title of a single conversation is the list of senders. int sendersLength = res.getInteger(R.integer.swipe_senders_length); final SpannableStringBuilder sendersBuilder = getStyledSenders(context, conversationCursor, sendersLength, notificationAccount); notification.setContentTitle(sendersBuilder); // For a single new conversation, the ticker is based on the sender's name. notificationTicker = sendersBuilder.toString(); } else { from = getWrappedFromString(from); // The title of a single message the sender. notification.setContentTitle(from); // For a single new conversation, the ticker is based on the sender's name. notificationTicker = from; } // The notification content will be the subject of the conversation. notification.setContentText(getSingleMessageLittleText(context, conversation.subject)); // The notification subtext will be the subject of the conversation for inbox // notifications, or will based on the the label name for user label // notifications. notification.setSubText(isInbox ? notificationAccount : notificationLabelName); if (multipleUnseenThread) { notification.setLargeIcon(getDefaultNotificationIcon(context, folder, true)); } final NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle( notification); // Seek the message cursor to the first unread message final Message message; if (messageCursor.moveToPosition(firstUnseenMessagePos)) { message = messageCursor.getMessage(); bigText.bigText(getSingleMessageBigText(context, conversation.subject, message)); } else { LogUtils.e(LOG_TAG, "Failed to load message"); message = null; } if (message != null) { final Set<String> notificationActions = folderPreferences.getNotificationActions(account); final int notificationId = getNotificationId(account.getAccountManagerAccount(), folder); NotificationActionUtils.addNotificationActions(context, notificationIntent, notification, account, conversation, message, folder, notificationId, when, notificationActions); } } else { // For an old-style notification // The title of a single conversation notification is built from both the sender // and subject of the new message. notification.setContentTitle( getSingleMessageNotificationTitle(context, from, conversation.subject)); // The notification content will be the subject of the conversation for inbox // notifications, or will based on the the label name for user label // notifications. notification.setContentText(isInbox ? notificationAccount : notificationLabelName); // For a single new conversation, the ticker is based on the sender's name. notificationTicker = from; } } finally { if (messageCursor != null) { messageCursor.close(); } if (cursor != null) { cursor.close(); } } } // Build the notification ticker if (notificationLabelName != null && notificationTicker != null) { // This is a per label notification, format the ticker with that information notificationTicker = res.getString(R.string.label_notification_ticker, notificationLabelName, notificationTicker); } if (notificationTicker != null) { // If we didn't generate a notification ticker, it will default to account name notification.setTicker(notificationTicker); } // Set the number in the notification if (unreadCount > 1) { notification.setNumber(unreadCount); } notification.setContentIntent(clickIntent); }
From source file:com.android.mail.utils.NotificationUtils.java
/** * Configure the notification for one conversation. When there are multiple conversations, * this method is used to configure bundled notification for Android Wear. *//*from w w w .j a v a2 s . c o m*/ private static ConfigResult configureNotifForOneConversation(Context context, Account account, FolderPreferences folderPreferences, NotificationCompat.Builder notificationBuilder, NotificationCompat.WearableExtender wearExtender, Cursor conversationCursor, Intent notificationIntent, Folder folder, long when, Resources res, boolean isInbox, String notificationLabelName, int notificationId, final ContactFetcher contactFetcher) { final ConfigResult result = new ConfigResult(); final Conversation conversation = new Conversation(conversationCursor); // Set of all unique senders for unseen messages final HashSet<String> senderAddressesSet = new HashSet<String>(); Cursor cursor = null; MessageCursor messageCursor = null; boolean multipleUnseenThread = false; String from = null; try { final Uri uri = conversation.messageListUri.buildUpon() .appendQueryParameter(UIProvider.LABEL_QUERY_PARAMETER, folder.persistentId).build(); cursor = context.getContentResolver().query(uri, UIProvider.MESSAGE_PROJECTION, null, null, null); messageCursor = new MessageCursor(cursor); // Use the information from the last sender in the conversation that triggered // this notification. String fromAddress = ""; if (messageCursor.moveToPosition(messageCursor.getCount() - 1)) { final Message message = messageCursor.getMessage(); fromAddress = message.getFrom(); if (fromAddress == null) { // No sender. Go back to default value. LogUtils.e(LOG_TAG, "No sender found for message: %d", message.getId()); fromAddress = ""; } from = getDisplayableSender(fromAddress); result.contactIconInfo = getContactIcon(context, account.getAccountManagerAccount().name, from, getSenderAddress(fromAddress), folder, contactFetcher); addEmailAddressToSet(fromAddress, senderAddressesSet); notificationBuilder.setLargeIcon(result.contactIconInfo.icon); } // Assume that the last message in this conversation is unread int firstUnseenMessagePos = messageCursor.getPosition(); while (messageCursor.moveToPosition(messageCursor.getPosition() - 1)) { final Message message = messageCursor.getMessage(); final boolean unseen = !message.seen; if (unseen) { firstUnseenMessagePos = messageCursor.getPosition(); addEmailAddressToSet(message.getFrom(), senderAddressesSet); if (!multipleUnseenThread && !fromAddress.contentEquals(message.getFrom())) { multipleUnseenThread = true; } } } final String subject = ConversationItemView.filterTag(context, conversation.subject); // TODO(skennedy) Can we remove this check? if (Utils.isRunningJellybeanOrLater()) { // For a new-style notification if (multipleUnseenThread) { // The title of a single conversation is the list of senders. int sendersLength = res.getInteger(R.integer.swipe_senders_length); final SpannableStringBuilder sendersBuilder = getStyledSenders(context, conversationCursor, sendersLength, account); notificationBuilder.setContentTitle(sendersBuilder); // For a single new conversation, the ticker is based on the sender's name. result.notificationTicker = sendersBuilder.toString(); } else { from = getWrappedFromString(from); // The title of a single message the sender. notificationBuilder.setContentTitle(from); // For a single new conversation, the ticker is based on the sender's name. result.notificationTicker = from; } // The notification content will be the subject of the conversation. notificationBuilder.setContentText(getSingleMessageLittleText(context, subject)); // The notification subtext will be the subject of the conversation for inbox // notifications, or will based on the the label name for user label // notifications. notificationBuilder.setSubText(isInbox ? account.getDisplayName() : notificationLabelName); final NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle( notificationBuilder); // Seek the message cursor to the first unread message final Message message; if (messageCursor.moveToPosition(firstUnseenMessagePos)) { message = messageCursor.getMessage(); bigText.bigText(getSingleMessageBigText(context, subject, message)); } else { LogUtils.e(LOG_TAG, "Failed to load message"); message = null; } if (message != null) { final Set<String> notificationActions = folderPreferences.getNotificationActions(account); NotificationActionUtils.addNotificationActions(context, notificationIntent, notificationBuilder, wearExtender, account, conversation, message, folder, notificationId, when, notificationActions); } } else { // For an old-style notification // The title of a single conversation notification is built from both the sender // and subject of the new message. notificationBuilder.setContentTitle(getSingleMessageNotificationTitle(context, from, subject)); // The notification content will be the subject of the conversation for inbox // notifications, or will based on the the label name for user label // notifications. notificationBuilder.setContentText(isInbox ? account.getDisplayName() : notificationLabelName); // For a single new conversation, the ticker is based on the sender's name. result.notificationTicker = from; } tagNotificationsWithPeople(notificationBuilder, senderAddressesSet); } finally { if (messageCursor != null) { messageCursor.close(); } if (cursor != null) { cursor.close(); } } return result; }