mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -05:00
Respect "Show contact names" option when determining sender for
notification. Fixes #4765.
This commit is contained in:
parent
c0e0ac9d34
commit
be68a6cbe6
@ -48,6 +48,7 @@ import com.fsck.k9.Preferences;
|
|||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.activity.FolderList;
|
import com.fsck.k9.activity.FolderList;
|
||||||
import com.fsck.k9.activity.MessageList;
|
import com.fsck.k9.activity.MessageList;
|
||||||
|
import com.fsck.k9.helper.Contacts;
|
||||||
import com.fsck.k9.helper.HtmlConverter;
|
import com.fsck.k9.helper.HtmlConverter;
|
||||||
import com.fsck.k9.helper.power.TracingPowerManager;
|
import com.fsck.k9.helper.power.TracingPowerManager;
|
||||||
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
|
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) {
|
private CharSequence getMessageSender(Context context, Account account, Message message) {
|
||||||
try {
|
try {
|
||||||
String from = null;
|
|
||||||
boolean isSelf = false;
|
boolean isSelf = false;
|
||||||
|
final Contacts contacts = K9.showContactName() ? Contacts.getInstance(context) : null;
|
||||||
|
final Address[] fromAddrs = message.getFrom();
|
||||||
|
|
||||||
if (message.getFrom() != null) {
|
if (fromAddrs != null) {
|
||||||
Address[] fromAddrs = message.getFrom();
|
|
||||||
if (fromAddrs.length > 0) {
|
|
||||||
from = fromAddrs[0].toFriendly().toString();
|
|
||||||
}
|
|
||||||
isSelf = account.isAnIdentity(fromAddrs);
|
isSelf = account.isAnIdentity(fromAddrs);
|
||||||
|
if (!isSelf && fromAddrs.length > 0) {
|
||||||
|
return fromAddrs[0].toFriendly(contacts).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from != null && !isSelf) {
|
if (isSelf) {
|
||||||
return from;
|
|
||||||
} else if (isSelf) {
|
|
||||||
// show To: if the message was sent from me
|
// show To: if the message was sent from me
|
||||||
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
|
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
|
||||||
String to = rcpts.length > 0 ? rcpts[0].toFriendly().toString() : null;
|
|
||||||
if (to != null) {
|
if (rcpts != null && rcpts.length > 0) {
|
||||||
return context.getString(R.string.message_to_fmt, to);
|
return context.getString(R.string.message_to_fmt,
|
||||||
|
rcpts[0].toFriendly(contacts).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.getString(R.string.general_no_sender);
|
return context.getString(R.string.general_no_sender);
|
||||||
|
Loading…
Reference in New Issue
Block a user