From 800bfead670b41fdb31a34951e0e9a6046fead67 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 14 Feb 2017 07:38:46 +0100 Subject: [PATCH] Display sender and subject of unread messages in bold --- .../list/MailListRemoteViewFactory.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/widget/list/MailListRemoteViewFactory.java b/k9mail/src/main/java/com/fsck/k9/widget/list/MailListRemoteViewFactory.java index bcee773bf..5e20fb9e6 100644 --- a/k9mail/src/main/java/com/fsck/k9/widget/list/MailListRemoteViewFactory.java +++ b/k9mail/src/main/java/com/fsck/k9/widget/list/MailListRemoteViewFactory.java @@ -10,7 +10,10 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.graphics.Color; +import android.graphics.Typeface; import android.os.Binder; +import android.text.SpannableString; +import android.text.style.StyleSpan; import android.view.View; import android.widget.RemoteViews; import android.widget.RemoteViewsService; @@ -90,13 +93,16 @@ public class MailListRemoteViewFactory implements RemoteViewsService.RemoteViews RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.mail_list_item); MailItem item = mailItems.get(position); + CharSequence sender = Boolean.valueOf(item.unread) ? bold(item.sender) : item.sender; + CharSequence subject = Boolean.valueOf(item.unread) ? bold(item.subject) : item.subject; + /* Populate the views from the mailItem object */ if (senderAboveSubject) { - remoteView.setTextViewText(R.id.sender, item.sender); - remoteView.setTextViewText(R.id.mail_subject, item.subject); + remoteView.setTextViewText(R.id.sender, sender); + remoteView.setTextViewText(R.id.mail_subject, subject); } else { - remoteView.setTextViewText(R.id.sender, item.subject); - remoteView.setTextViewText(R.id.mail_subject, item.sender); + remoteView.setTextViewText(R.id.sender, subject); + remoteView.setTextViewText(R.id.mail_subject, sender); } remoteView.setTextViewText(R.id.mail_date, item.getDateFormatted("%d %s")); remoteView.setTextViewText(R.id.mail_preview, item.preview); @@ -142,6 +148,11 @@ public class MailListRemoteViewFactory implements RemoteViewsService.RemoteViews return true; } + private CharSequence bold(String text) { + SpannableString spannableString = new SpannableString(text); + spannableString.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), 0); + return spannableString; + } private static class MailItem { private static Calendar cl = Calendar.getInstance();