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

redo our messagelist sigil code to not break sender colorization

This commit is contained in:
Jesse Vincent 2010-10-25 03:21:08 +00:00
parent 724169e982
commit 6704279042
2 changed files with 10 additions and 11 deletions

View File

@ -978,6 +978,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>
<string name="messagelist_sent_to_me_sigil">»</string>
<string name="messagelist_sent_cc_me_sigil"></string>
</resources>

View File

@ -2709,26 +2709,25 @@ public class MessageList
* from.
*/
CharSequence sender = formatSender(message);
holder.preview.setText(new SpannableStringBuilder(sender).append(" ").append(message.preview),
holder.preview.setText(new SpannableStringBuilder(recipientSigil(message)).append(message.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,
sender.length(),
(message.sender.length()+1),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
);
str.setSpan(new ForegroundColorSpan(Color.rgb(128,128,128)), // TODO: How do I can specify the android.R.attr.textColorTertiary
sender.length(),
(message.sender.length()+1),
str.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
);
}
else
{
holder.from.setText(formatSender(message));
holder.from.setText(new SpannableStringBuilder(recipientSigil(message)).append( message.sender));
holder.from.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
}
@ -2742,19 +2741,19 @@ public class MessageList
holder.position = position;
}
private CharSequence formatSender (MessageInfoHolder message)
private String recipientSigil (MessageInfoHolder message)
{
if (message.toMe)
{
return String.format(getString(R.string.messagelist_sent_to_me_format), message.sender);
return getString(R.string.messagelist_sent_to_me_sigil);
}
else if (message.ccMe)
{
return String.format(getString(R.string.messagelist_sent_cc_me_format), message.sender);
return getString(R.string.messagelist_sent_cc_me_sigil);
}
else
{
return message.sender;
return "";
}
}