1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-16 22:45:04 -05:00

Add gmail-style "to me" and "cc me" indicators in messagelist

This commit is contained in:
Jesse Vincent 2010-10-21 20:48:45 +00:00
parent d02ddda19b
commit 8d9c074a27
4 changed files with 45 additions and 4 deletions

View File

@ -975,4 +975,6 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="debug_logging_enabled">Debug logging to Android logging system enabled</string> <string name="debug_logging_enabled">Debug logging to Android logging system enabled</string>
<string name="messagelist_sent_to_me_format">» <xliff:g id="sender">%s</xliff:g></string>
<string name="messagelist_sent_cc_me_format"> <xliff:g id="sender">%s</xliff:g></string>
</resources> </resources>

View File

@ -23,6 +23,8 @@ public class MessageInfoHolder
public boolean downloaded; public boolean downloaded;
public boolean partially_downloaded; public boolean partially_downloaded;
public boolean dirty; public boolean dirty;
public boolean toMe;
public boolean ccMe;
public Message message; public Message message;
public FolderInfoHolder folder; public FolderInfoHolder folder;
public boolean selected; public boolean selected;

View File

@ -2678,25 +2678,28 @@ public class MessageList
* compose a custom view containing the preview and the * compose a custom view containing the preview and the
* from. * from.
*/ */
holder.preview.setText(new SpannableStringBuilder(message.sender).append(" ").append(message.preview),
CharSequence sender = formatSender(message);
holder.preview.setText(new SpannableStringBuilder(sender).append(" ").append(message.preview),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
Spannable str = (Spannable)holder.preview.getText(); Spannable str = (Spannable)holder.preview.getText();
// Create our span sections, and assign a format to each. // Create our span sections, and assign a format to each.
str.setSpan(new StyleSpan(Typeface.BOLD), str.setSpan(new StyleSpan(Typeface.BOLD),
0, 0,
message.sender.length(), sender.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
); );
str.setSpan(new ForegroundColorSpan(Color.rgb(128,128,128)), // TODO: How do I can specify the android.R.attr.textColorTertiary str.setSpan(new ForegroundColorSpan(Color.rgb(128,128,128)), // TODO: How do I can specify the android.R.attr.textColorTertiary
message.sender.length(), sender.length(),
str.length(), str.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
); );
} }
else else
{ {
holder.from.setText(message.sender); holder.from.setText(formatSender(message));
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD); holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
} }
@ -2709,6 +2712,22 @@ public class MessageList
holder.position = position; holder.position = position;
} }
private CharSequence formatSender (MessageInfoHolder message)
{
if (message.toMe)
{
return String.format(getString(R.string.messagelist_sent_to_me_format), message.sender);
} else if (message.ccMe)
{
return String.format(getString(R.string.messagelist_sent_cc_me_format), message.sender);
}
else
{
return message.sender;
}
}
public View getFooterView(int position, View convertView, ViewGroup parent) public View getFooterView(int position, View convertView, ViewGroup parent)
{ {
if (footerView == null) if (footerView == null)

View File

@ -98,6 +98,24 @@ public class MessageHelper
target.senderAddress = target.compareCounterparty; target.senderAddress = target.compareCounterparty;
} }
for (Address address : message.getRecipients(RecipientType.TO)) {
if (account.isAnIdentity(address))
{
target.toMe = true;
}
}
if (target.toMe == false ) {
for(Address address : message.getRecipients(RecipientType.CC)) {
if (account.isAnIdentity(address))
{
target.ccMe = true;
}
}
}
target.subject = message.getSubject(); target.subject = message.getSubject();
target.uid = message.getUid(); target.uid = message.getUid();