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

Respect "Show contact names" option when determining sender for

notification.

Fixes #4765.
This commit is contained in:
Danny Baumann 2013-01-02 16:13:27 +01:00
parent c0e0ac9d34
commit be68a6cbe6

View File

@ -48,6 +48,7 @@ import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.FolderList;
import com.fsck.k9.activity.MessageList;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.HtmlConverter;
import com.fsck.k9.helper.power.TracingPowerManager;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
@ -4419,25 +4420,24 @@ public class MessagingController implements Runnable {
private CharSequence getMessageSender(Context context, Account account, Message message) {
try {
String from = null;
boolean isSelf = false;
final Contacts contacts = K9.showContactName() ? Contacts.getInstance(context) : null;
final Address[] fromAddrs = message.getFrom();
if (message.getFrom() != null) {
Address[] fromAddrs = message.getFrom();
if (fromAddrs.length > 0) {
from = fromAddrs[0].toFriendly().toString();
}
if (fromAddrs != null) {
isSelf = account.isAnIdentity(fromAddrs);
if (!isSelf && fromAddrs.length > 0) {
return fromAddrs[0].toFriendly(contacts).toString();
}
}
if (from != null && !isSelf) {
return from;
} else if (isSelf) {
if (isSelf) {
// show To: if the message was sent from me
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
String to = rcpts.length > 0 ? rcpts[0].toFriendly().toString() : null;
if (to != null) {
return context.getString(R.string.message_to_fmt, to);
if (rcpts != null && rcpts.length > 0) {
return context.getString(R.string.message_to_fmt,
rcpts[0].toFriendly(contacts).toString());
}
return context.getString(R.string.general_no_sender);