List of usage examples for android.text SpannableStringBuilder append
public SpannableStringBuilder append(char text)
From source file:org.dalmasso.ietfsched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from w w w .j a v a 2 s .co m private void onSessionQueryComplete(Cursor cursor) { try { mSessionCursor = true; if (!cursor.moveToFirst()) { return; } // Format time block this session occupies final long blockStart = cursor.getLong(SessionsQuery.BLOCK_START); final long blockEnd = cursor.getLong(SessionsQuery.BLOCK_END); final String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(blockStart, blockEnd, roomName, getActivity()); mTitleString = cursor.getString(SessionsQuery.TITLE); mTitle.setText(mTitleString); mSubtitle.setText(subtitle); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtag = cursor.getString(SessionsQuery.HASHTAG); mTagDisplay = (TextView) mRootView.findViewById(R.id.session_tags_button); if (!TextUtils.isEmpty(mHashtag)) { // Create the button text SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(getString(R.string.tag_stream) + " "); int boldStart = sb.length(); sb.append(getHashtagsString()); sb.setSpan(sBoldSpan, boldStart, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mTagDisplay.setText(sb); mTagDisplay.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { /* Intent intent = new Intent(getActivity(), TagStreamActivity.class); intent.putExtra(TagStreamFragment.EXTRA_QUERY, getHashtagsString()); startActivity(intent); */ Log.d(TAG, "on click mTagDisplay"); } }); } else { mTagDisplay.setVisibility(View.GONE); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); // Unregister around setting checked state to avoid triggering // listener since change isn't user generated. mStarred.setOnCheckedChangeListener(null); mStarred.setChecked(cursor.getInt(SessionsQuery.STARRED) != 0); mStarred.setOnCheckedChangeListener(this); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } /* final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } */ // Show empty message when all data is loaded, and nothing to show // if (mSpeakersCursor && !mHasSummaryContent) { if (!mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } else { mTabHost.setCurrentTabByTag(TAG_SUMMARY); } // AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + mTitleString); updateLinksTab(cursor); updateNotesTab(); } finally { cursor.close(); } }
From source file:com.andrada.sitracker.ui.fragment.AboutDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/*w ww . jav a2 s . co m*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } SpannableStringBuilder aboutBody = new SpannableStringBuilder(); SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); SpannableString whatsNewLink = new SpannableString(getString(R.string.whats_new)); whatsNewLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showWhatsNew(getActivity()); } }, 0, whatsNewLink.length(), 0); aboutBody.append(licensesLink); aboutBody.append("\n\n"); aboutBody.append(whatsNewLink); AboutDialogView aboutBodyView = AboutDialogView_.build(getActivity()); aboutBodyView.bindData(getString(R.string.app_version_format, versionName), aboutBody); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.android.mms.ui.ConversationListItem.java
private CharSequence formatMessage() { final int color = android.R.styleable.Theme_textColorSecondary; String from = mConversation.getRecipients().formatNames(", "); if (MessageUtils.isWapPushNumber(from)) { String[] mAddresses = from.split(":"); from = mAddresses[mContext.getResources().getInteger(R.integer.wap_push_address_index)]; }//from w w w . j a va2 s .c om /** * Add boolean to know that the "from" haven't the Arabic and '+'. * Make sure the "from" display normally for RTL. */ boolean isEnName = false; boolean isLayoutRtl = (TextUtils .getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL); if (isLayoutRtl && from != null) { if (from.length() >= 1) { Pattern pattern = Pattern.compile("[^-]+"); Matcher matcher = pattern.matcher(from); isEnName = matcher.matches(); if (isEnName && from.charAt(0) != '\u202D') { from = "\u202D" + from + "\u202C"; } } } SpannableStringBuilder buf = new SpannableStringBuilder(from); if (mConversation.getMessageCount() > 1) { int before = buf.length(); if (isLayoutRtl && isEnName) { buf.insert(1, mConversation.getMessageCount() + " "); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.message_count_color)), 1, buf.length() - before, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } else { buf.append(mContext.getResources().getString(R.string.message_count_format, mConversation.getMessageCount())); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.message_count_color)), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } } if (mConversation.hasDraft()) { if (isLayoutRtl && isEnName) { int before = buf.length(); buf.insert(1, '\u202E' + mContext.getResources().getString(R.string.draft_separator) + '\u202C'); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.drawable.text_color_black)), 1, buf.length() - before + 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); before = buf.length(); int size; buf.insert(1, mContext.getResources().getString(R.string.has_draft)); size = android.R.style.TextAppearance_Small; buf.setSpan(new TextAppearanceSpan(mContext, size), 1, buf.length() - before + 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.drawable.text_color_red)), 1, buf.length() - before + 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } else { buf.append(mContext.getResources().getString(R.string.draft_separator)); int before = buf.length(); int size; buf.append(mContext.getResources().getString(R.string.has_draft)); size = android.R.style.TextAppearance_Small; buf.setSpan(new TextAppearanceSpan(mContext, size, color), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.drawable.text_color_red)), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } } // Unread messages are shown in bold if (mConversation.hasUnreadMessages()) { buf.setSpan(STYLE_BOLD, 0, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } return buf; }
From source file:com.google.android.apps.iosched2.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//* ww w . j a v a 2 s. c o m*/ private void onSessionQueryComplete(Cursor cursor) { try { mSessionCursor = true; if (!cursor.moveToFirst()) { return; } // Format time block this session occupies final long blockStart = cursor.getLong(SessionsQuery.BLOCK_START); final long blockEnd = cursor.getLong(SessionsQuery.BLOCK_END); final String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(blockStart, blockEnd, roomName, getActivity()); mTitleString = cursor.getString(SessionsQuery.TITLE); mTitle.setText(mTitleString); mSubtitle.setText(subtitle); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtag = cursor.getString(SessionsQuery.HASHTAG); mTagDisplay = (TextView) mRootView.findViewById(R.id.session_tags_button); if (!TextUtils.isEmpty(mHashtag)) { // Create the button text SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(getString(R.string.tag_stream) + " "); int boldStart = sb.length(); sb.append(getHashtagsString()); sb.setSpan(sBoldSpan, boldStart, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mTagDisplay.setText(sb); mTagDisplay.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Intent intent = new Intent(getActivity(), TagStreamActivity.class); Intent intent = new Intent(getActivity(), Setup.TagStreamActivityClass); intent.putExtra(TagStreamFragment.EXTRA_QUERY, getHashtagsString()); startActivity(intent); } }); } else { mTagDisplay.setVisibility(View.GONE); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); // Unregister around setting checked state to avoid triggering // listener since change isn't user generated. mStarred.setOnCheckedChangeListener(null); mStarred.setChecked(cursor.getInt(SessionsQuery.STARRED) != 0); mStarred.setOnCheckedChangeListener(this); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } final View levelBlock = mRootView.findViewById(R.id.session_level_block); final String sessionLevel = cursor.getString(SessionsQuery.LEVEL); if (!TextUtils.isEmpty(sessionLevel)) { UIUtils.setTextMaybeHtml(mLevel, sessionLevel); levelBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { levelBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + mTitleString); updateLinksTab(cursor); updateNotesTab(); } finally { cursor.close(); } }
From source file:com.heneryh.aquanotes.ui.CtlrStatusFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//* w w w . j av a 2 s .c om*/ private void updateControllerTabs(Ctlr cntl, Cursor cursor) { try { mSessionCursor = true; // Header Area cntl.mTitleString = cursor.getString(ControllersQuery.TITLE); cntl.mSubtitle = cursor.getString(ControllersQuery.WAN_URL); cntl.mTitleView.setText(cntl.mTitleString); cntl.mSubtitleView.setText(cntl.mSubtitle); // Probes Tab Area cntl.mUrl = "http://test"; //cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(cntl.mUrl)) { cntl.mUrl = ""; } cntl.mHashtag = ""; //cursor.getString(SessionsQuery.HASHTAG); if (!TextUtils.isEmpty(cntl.mHashtag)) { // Create the button text SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(getString(R.string.tag_stream) + " "); int boldStart = sb.length(); sb.append(getHashtagsString(cntl.mHashtag)); sb.setSpan(sBoldSpan, boldStart, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); cntl.mTagDisplayView.setText(sb); cntl.mTagDisplayView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(getActivity(), TagStreamActivity.class); intent.putExtra(TagStreamFragment.EXTRA_QUERY, getHashtagsString("was hash tag")); startActivity(intent); } }); } else { cntl.mTagDisplayView.setVisibility(View.GONE); } cntl.mRoomName = "Room"; cntl.mRoomId = "Rm 202"; //cursor.getString(SessionsQuery.ROOM_ID); // Unregister around setting checked state to avoid triggering // listener since change isn't user generated. // cntl.mStarred.setOnCheckedChangeListener(null); // cntl.mStarred.setChecked(false); // cntl.mStarred.setOnCheckedChangeListener(this); final String sessionAbstract = "I can work on the order these show up, it is just a sort on the query. Note there is a title above in the header between the l/r icons. Also a title down in the tab host header. I will do one or the other not both. Oh, and you have to swipe l/r once to get that top title to sync."; //cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(cntl.mAbstractView, sessionAbstract); cntl.mAbstractView.setVisibility(View.VISIBLE); cntl.mHasSummaryContent = true; } else { cntl.mAbstractView.setVisibility(View.GONE); } final String sessionRequirements = "How shall I lay out this screen??? Suggestions?"; //cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(cntl.mRequirementsView, sessionRequirements); cntl.mRequirementsBlockView.setVisibility(View.VISIBLE); cntl.mHasSummaryContent = true; } else { cntl.mRequirementsBlockView.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !cntl.mHasSummaryContent) { cntl.mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + cntl.mTitleString); // updateLinksTab(cursor); // updateNotesTab(); updateWorkspaceHeader(cntl.index); } finally { // cursor.close(); } }
From source file:com.gh4a.fragment.PullRequestFragment.java
private void fillLabels(List<Label> labels) { View labelGroup = mListHeaderView.findViewById(R.id.label_container); if (labels != null && !labels.isEmpty()) { TextView labelView = (TextView) mListHeaderView.findViewById(R.id.labels); SpannableStringBuilder builder = new SpannableStringBuilder(); for (Label label : labels) { int pos = builder.length(); IssueLabelSpan span = new IssueLabelSpan(getActivity(), label, true); builder.append(label.getName()); builder.setSpan(span, pos, pos + label.getName().length(), 0); }/*from w w w . j a v a 2 s .c om*/ labelView.setText(builder); labelGroup.setVisibility(View.VISIBLE); } else { labelGroup.setVisibility(View.GONE); } }
From source file:com.google.android.marvin.mytalkback.speechrules.NodeSpeechRuleProcessor.java
/** * If the supplied node has a label, replaces the builder text with a * version formatted with the label./*from w w w . j ava 2 s .co m*/ */ private void formatTextWithLabel(AccessibilityNodeInfoCompat node, SpannableStringBuilder builder) { final AccessibilityNodeInfoCompat labelNode = AccessibilityNodeInfoCompatUtils.getLabeledBy(node); if (labelNode == null) { return; } final SpannableStringBuilder labelDescription = new SpannableStringBuilder(); appendDescriptionForTree(labelNode, labelDescription, null, null); if (TextUtils.isEmpty(labelDescription)) { return; } final String labeled = mContext.getString(R.string.template_labeled_item, builder, labelDescription); // Replace the text of the builder. builder.clear(); builder.append(labeled); }
From source file:com.concentriclivers.mms.com.android.mms.transaction.MessagingNotification.java
/** * updateNotification is *the* main function for building the actual notification handed to * the NotificationManager//w ww . jav a2s. com * @param context * @param isNew if we've got a new message, show the ticker * @param uniqueThreadCount */ private static void updateNotification(Context context, boolean isNew, int uniqueThreadCount) { // TDH Log.d("NotificationDebug", "updateNotification()"); // If the user has turned off notifications in settings, don't do any notifying. if (!MessagingPreferenceActivity.getNotificationEnabled(context)) { if (DEBUG) { Log.d(TAG, "updateNotification: notifications turned off in prefs, bailing"); } // TDH Log.d("NotificationDebug", "Notifications not enabled!"); return; } // Figure out what we've got -- whether all sms's, mms's, or a mixture of both. int messageCount = sNotificationSet.size(); // TDH: Log.d("NotificationDebug", "messageCount: " + messageCount); if (messageCount == 0) { Log.d("NotificationDebug", "WTF. Should have at least one message."); return; } NotificationInfo mostRecentNotification = sNotificationSet.first(); // TDH: Use NotificationCompat2 (and in other places but it is obvious where). final NotificationCompat2.Builder noti = new NotificationCompat2.Builder(context) .setWhen(mostRecentNotification.mTimeMillis); if (isNew) { noti.setTicker(mostRecentNotification.mTicker); } // TDH Log.d("NotificationDebug", "Creating TaskStackBuilder"); TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); // TDH Log.d("NotificationDebug", "Created TaskStackBuilder. UniqueThreadCount: " + uniqueThreadCount); // If we have more than one unique thread, change the title (which would // normally be the contact who sent the message) to a generic one that // makes sense for multiple senders, and change the Intent to take the // user to the conversation list instead of the specific thread. // Cases: // 1) single message from single thread - intent goes to ComposeMessageActivity // 2) multiple messages from single thread - intent goes to ComposeMessageActivity // 3) messages from multiple threads - intent goes to ConversationList final Resources res = context.getResources(); String title = null; Bitmap avatar = null; if (uniqueThreadCount > 1) { // messages from multiple threads Intent mainActivityIntent = new Intent(Intent.ACTION_MAIN); mainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); mainActivityIntent.setType("vnd.android-dir/mms-sms"); taskStackBuilder.addNextIntent(mainActivityIntent); title = context.getString(R.string.message_count_notification, messageCount); } else { // same thread, single or multiple messages title = mostRecentNotification.mTitle; BitmapDrawable contactDrawable = (BitmapDrawable) mostRecentNotification.mSender.getAvatar(context, null); if (contactDrawable != null) { // Show the sender's avatar as the big icon. Contact bitmaps are 96x96 so we // have to scale 'em up to 128x128 to fill the whole notification large icon. avatar = contactDrawable.getBitmap(); if (avatar != null) { final int idealIconHeight = res .getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final int idealIconWidth = res .getDimensionPixelSize(android.R.dimen.notification_large_icon_width); if (avatar.getHeight() < idealIconHeight) { // Scale this image to fit the intended size avatar = Bitmap.createScaledBitmap(avatar, idealIconWidth, idealIconHeight, true); } if (avatar != null) { noti.setLargeIcon(avatar); } } } taskStackBuilder.addParentStack(ComposeMessageActivity.class); taskStackBuilder.addNextIntent(mostRecentNotification.mClickIntent); } // TDH Log.d("NotificationDebug", "title: " + title); // Always have to set the small icon or the notification is ignored noti.setSmallIcon(R.drawable.stat_notify_sms); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Update the notification. noti.setContentTitle(title) .setContentIntent(taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)); // TDH: Can't do these yet. // .addKind(Notification.KIND_MESSAGE) // .setPriority(Notification.PRIORITY_DEFAULT); // TODO: set based on contact coming // // from a favorite. int defaults = 0; if (isNew) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String vibrateWhen; if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) { vibrateWhen = sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null); } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) { vibrateWhen = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false) ? context.getString(R.string.prefDefault_vibrate_true) : context.getString(R.string.prefDefault_vibrate_false); } else { vibrateWhen = context.getString(R.string.prefDefault_vibrateWhen); } boolean vibrateAlways = vibrateWhen.equals("always"); boolean vibrateSilent = vibrateWhen.equals("silent"); AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); boolean nowSilent = audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE; if (vibrateAlways || vibrateSilent && nowSilent) { defaults |= Notification.DEFAULT_VIBRATE; } String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null); noti.setSound(TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr)); if (DEBUG) { Log.d(TAG, "updateNotification: new message, adding sound to the notification"); } } defaults |= Notification.DEFAULT_LIGHTS; noti.setDefaults(defaults); // set up delete intent noti.setDeleteIntent(PendingIntent.getBroadcast(context, 0, sNotificationOnDeleteIntent, 0)); final Notification notification; if (messageCount == 1) { // We've got a single message // TDH Log.d("NotificationDebug", "Single message, with text: " + mostRecentNotification.formatBigMessage(context)); // This sets the text for the collapsed form: noti.setContentText(mostRecentNotification.formatBigMessage(context)); if (mostRecentNotification.mAttachmentBitmap != null) { // The message has a picture, show that notification = new NotificationCompat2.BigPictureStyle(noti) .bigPicture(mostRecentNotification.mAttachmentBitmap) // This sets the text for the expanded picture form: .setSummaryText(mostRecentNotification.formatPictureMessage(context)).build(); } else { // Show a single notification -- big style with the text of the whole message notification = new NotificationCompat2.BigTextStyle(noti) .bigText(mostRecentNotification.formatBigMessage(context)).build(); } } else { // We've got multiple messages if (uniqueThreadCount == 1) { // We've got multiple messages for the same thread. // Starting with the oldest new message, display the full text of each message. // Begin a line for each subsequent message. SpannableStringBuilder buf = new SpannableStringBuilder(); NotificationInfo infos[] = sNotificationSet.toArray(new NotificationInfo[sNotificationSet.size()]); int len = infos.length; for (int i = len - 1; i >= 0; i--) { NotificationInfo info = infos[i]; buf.append(info.formatBigMessage(context)); if (i != 0) { buf.append('\n'); } } noti.setContentText(context.getString(R.string.message_count_notification, messageCount)); // Show a single notification -- big style with the text of all the messages notification = new NotificationCompat2.BigTextStyle(noti).bigText(buf) // Forcibly show the last line, with the app's smallIcon in it, if we // kicked the smallIcon out with an avatar bitmap .setSummaryText((avatar == null) ? null : " ").build(); } else { // Build a set of the most recent notification per threadId. HashSet<Long> uniqueThreads = new HashSet<Long>(sNotificationSet.size()); ArrayList<NotificationInfo> mostRecentNotifPerThread = new ArrayList<NotificationInfo>(); Iterator<NotificationInfo> notifications = sNotificationSet.iterator(); while (notifications.hasNext()) { NotificationInfo notificationInfo = notifications.next(); if (!uniqueThreads.contains(notificationInfo.mThreadId)) { uniqueThreads.add(notificationInfo.mThreadId); mostRecentNotifPerThread.add(notificationInfo); } } // When collapsed, show all the senders like this: // Fred Flinstone, Barry Manilow, Pete... noti.setContentText(formatSenders(context, mostRecentNotifPerThread)); NotificationCompat2.InboxStyle inboxStyle = new NotificationCompat2.InboxStyle(noti); // We have to set the summary text to non-empty so the content text doesn't show // up when expanded. inboxStyle.setSummaryText(" "); // At this point we've got multiple messages in multiple threads. We only // want to show the most recent message per thread, which are in // mostRecentNotifPerThread. int uniqueThreadMessageCount = mostRecentNotifPerThread.size(); int maxMessages = Math.min(MAX_MESSAGES_TO_SHOW, uniqueThreadMessageCount); for (int i = 0; i < maxMessages; i++) { NotificationInfo info = mostRecentNotifPerThread.get(i); inboxStyle.addLine(info.formatInboxMessage(context)); } notification = inboxStyle.build(); if (DEBUG) { Log.d(TAG, "updateNotification: multi messages," + " showing inboxStyle notification"); } } } // TDH Log.d("NotificationDebug", "Showing notification: " + notification); nm.notify(NOTIFICATION_ID, notification); }
From source file:cc.mintcoin.wallet.ui.TransactionsListFragment.java
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final SpannableStringBuilder emptyText = new SpannableStringBuilder( getString(direction == Direction.SENT ? R.string.wallet_transactions_fragment_empty_text_sent : R.string.wallet_transactions_fragment_empty_text_received)); emptyText.setSpan(new StyleSpan(Typeface.BOLD), 0, emptyText.length(), SpannableStringBuilder.SPAN_POINT_MARK); if (direction != Direction.SENT) emptyText.append("\n\n").append(getString(R.string.wallet_transactions_fragment_empty_text_howto)); setEmptyText(emptyText);//from www. j a va 2s . c om }
From source file:biz.wiz.android.wallet.ui.TransactionsListFragment.java
@Override public void onLoadFinished(final Loader<List<Transaction>> loader, final List<Transaction> transactions) { adapter.replace(transactions);/*from ww w.j a v a 2 s. c o m*/ final SpannableStringBuilder emptyText = new SpannableStringBuilder( getString(direction == Direction.SENT ? R.string.wallet_transactions_fragment_empty_text_sent : R.string.wallet_transactions_fragment_empty_text_received)); emptyText.setSpan(new StyleSpan(Typeface.BOLD), 0, emptyText.length(), SpannableStringBuilder.SPAN_POINT_MARK); if (direction != Direction.SENT) emptyText.append("\n\n").append(getString(R.string.wallet_transactions_fragment_empty_text_howto)); setEmptyText(emptyText); setEmptyText("wallet bip32 seed is " + wallet.getKeyChainSeed().getMnemonicCode()); }