Add gmail-style "to me" and "cc me" indicators in messagelist
This commit is contained in:
parent
d02ddda19b
commit
8d9c074a27
4 changed files with 45 additions and 4 deletions
|
@ -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="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>
|
||||
|
|
|
@ -23,6 +23,8 @@ public class MessageInfoHolder
|
|||
public boolean downloaded;
|
||||
public boolean partially_downloaded;
|
||||
public boolean dirty;
|
||||
public boolean toMe;
|
||||
public boolean ccMe;
|
||||
public Message message;
|
||||
public FolderInfoHolder folder;
|
||||
public boolean selected;
|
||||
|
|
|
@ -2678,25 +2678,28 @@ public class MessageList
|
|||
* compose a custom view containing the preview and the
|
||||
* 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);
|
||||
Spannable str = (Spannable)holder.preview.getText();
|
||||
|
||||
// Create our span sections, and assign a format to each.
|
||||
str.setSpan(new StyleSpan(Typeface.BOLD),
|
||||
0,
|
||||
message.sender.length(),
|
||||
sender.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
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(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.from.setText(message.sender);
|
||||
holder.from.setText(formatSender(message));
|
||||
|
||||
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
|
||||
}
|
||||
|
||||
|
@ -2709,6 +2712,22 @@ public class MessageList
|
|||
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)
|
||||
{
|
||||
if (footerView == null)
|
||||
|
|
|
@ -98,6 +98,24 @@ public class MessageHelper
|
|||
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.uid = message.getUid();
|
||||
|
|
Loading…
Reference in a new issue