mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
On the MessageList and the MessageView, prefer to use the display name registered in the Contacts rather than raw addresses.
Update issue 2144
This commit is contained in:
parent
e5c4f35737
commit
b1074329e4
@ -77,7 +77,7 @@
|
|||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:fadingEdge="vertical"
|
android:fadingEdge="vertical"
|
||||||
android:bufferType="spannable"
|
android:bufferType="spannable"
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -230,7 +230,7 @@ Vítejte v nastavení pošty K-9 Mail. K-9 je open source poštovní klient pro
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">Načti více zpráv</string>
|
<string name="message_list_load_more_messages_action">Načti více zpráv</string>
|
||||||
<string name="message_list_to_fmt">Komu:<xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">Komu:</string>
|
||||||
<string name="message_list_delete_action">Smazat</string>
|
<string name="message_list_delete_action">Smazat</string>
|
||||||
<string name="message_list_mark_read_action">Označit jako přečtené</string>
|
<string name="message_list_mark_read_action">Označit jako přečtené</string>
|
||||||
<string name="message_list_mark_unread_action">Označit jako nepřečtené</string>
|
<string name="message_list_mark_unread_action">Označit jako nepřečtené</string>
|
||||||
|
@ -224,7 +224,7 @@ Willkommen zum \"K-9 Mail\"-Setup. K-9 ist eine quelloffene E-Mail-Anwendung fü
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">Weitere Nachrichten abrufen</string>
|
<string name="message_list_load_more_messages_action">Weitere Nachrichten abrufen</string>
|
||||||
<string name="message_list_to_fmt">An: <xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">An: </string>
|
||||||
<string name="message_list_delete_action">Löschen</string>
|
<string name="message_list_delete_action">Löschen</string>
|
||||||
<string name="message_list_mark_read_action">Gelesen</string>
|
<string name="message_list_mark_read_action">Gelesen</string>
|
||||||
<string name="message_list_mark_unread_action">Nicht gelesen</string>
|
<string name="message_list_mark_unread_action">Nicht gelesen</string>
|
||||||
|
@ -227,7 +227,7 @@
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">Charger plus de messages</string>
|
<string name="message_list_load_more_messages_action">Charger plus de messages</string>
|
||||||
<string name="message_list_to_fmt">Pour\u00A0: <xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">Pour\u00A0: </string>
|
||||||
<string name="message_list_delete_action">Supprimer</string>
|
<string name="message_list_delete_action">Supprimer</string>
|
||||||
<string name="message_list_mark_read_action">Marquer comme lu</string>
|
<string name="message_list_mark_read_action">Marquer comme lu</string>
|
||||||
<string name="message_list_mark_unread_action">Marquer comme non lu</string>
|
<string name="message_list_mark_unread_action">Marquer comme non lu</string>
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
<string name="end_of_folder">Non vi sono altri messaggi</string>
|
<string name="end_of_folder">Non vi sono altri messaggi</string>
|
||||||
<string name="message_header_mua">K-9 per Android <xliff:g id="version">%s</xliff:g></string>
|
<string name="message_header_mua">K-9 per Android <xliff:g id="version">%s</xliff:g></string>
|
||||||
<string name="message_compose_content_hint">Testo del messaggio</string>
|
<string name="message_compose_content_hint">Testo del messaggio</string>
|
||||||
<string name="message_list_to_fmt">A:<xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">A:</string>
|
||||||
<string name="message_view_from_format">Da: <xliff:g id="name">%s</xliff:g> <<xliff:g id="email">%s</xliff:g>></string>
|
<string name="message_view_from_format">Da: <xliff:g id="name">%s</xliff:g> <<xliff:g id="email">%s</xliff:g>></string>
|
||||||
<string name="message_view_cc_label">Cc:</string>
|
<string name="message_view_cc_label">Cc:</string>
|
||||||
<string name="message_delete_failed">Impossibile cancellare il messaggio</string>
|
<string name="message_delete_failed">Impossibile cancellare il messaggio</string>
|
||||||
|
@ -235,7 +235,7 @@ K-9 Mail セットアップにようこそ。\nK-9 はオープンソースで
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">他メールを読込</string>
|
<string name="message_list_load_more_messages_action">他メールを読込</string>
|
||||||
<string name="message_list_to_fmt">宛先:<xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">宛先:</string>
|
||||||
<string name="message_list_delete_action">削除</string>
|
<string name="message_list_delete_action">削除</string>
|
||||||
<string name="message_list_mark_read_action">既読にする</string>
|
<string name="message_list_mark_read_action">既読にする</string>
|
||||||
<string name="message_list_mark_unread_action">未読にする</string>
|
<string name="message_list_mark_unread_action">未読にする</string>
|
||||||
|
@ -238,7 +238,7 @@ Witaj w K-9 Mail, darmowym programie pocztowym dla systemu Android. Najistotniej
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">Pobierz więcej wiadomości</string>
|
<string name="message_list_load_more_messages_action">Pobierz więcej wiadomości</string>
|
||||||
<string name="message_list_to_fmt">Do:<xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">Do:</string>
|
||||||
<string name="message_list_delete_action">Usuń</string>
|
<string name="message_list_delete_action">Usuń</string>
|
||||||
<string name="message_list_mark_read_action">Przecz.</string>
|
<string name="message_list_mark_read_action">Przecz.</string>
|
||||||
<string name="message_list_mark_unread_action">Nieprz.</string>
|
<string name="message_list_mark_unread_action">Nieprz.</string>
|
||||||
@ -853,4 +853,4 @@ Witaj w K-9 Mail, darmowym programie pocztowym dla systemu Android. Najistotniej
|
|||||||
<string name="misc_preferences_attachment_title">Obejdź błędy w Galerii</string>
|
<string name="misc_preferences_attachment_title">Obejdź błędy w Galerii</string>
|
||||||
<string name="misc_preferences_attachment_description">Wyświetla przyciski dodawania zdjęć oraz filmów jako załączników</string>
|
<string name="misc_preferences_attachment_description">Wyświetla przyciski dodawania zdjęć oraz filmów jako załączników</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -217,7 +217,7 @@
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">Загрузить болюше сообщений</string>
|
<string name="message_list_load_more_messages_action">Загрузить болюше сообщений</string>
|
||||||
<string name="message_list_to_fmt">Для:<xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">Для:</string>
|
||||||
<string name="message_list_delete_action">Удалить</string>
|
<string name="message_list_delete_action">Удалить</string>
|
||||||
<string name="message_list_mark_read_action">Отметить как прочитанное</string>
|
<string name="message_list_mark_read_action">Отметить как прочитанное</string>
|
||||||
<string name="message_list_mark_unread_action">Отметить как непрочитанное</string>
|
<string name="message_list_mark_unread_action">Отметить как непрочитанное</string>
|
||||||
|
@ -240,7 +240,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||||||
<xliff:g id="sending">%s</xliff:g>
|
<xliff:g id="sending">%s</xliff:g>
|
||||||
<xliff:g id="push">%s</xliff:g></string>
|
<xliff:g id="push">%s</xliff:g></string>
|
||||||
<string name="message_list_load_more_messages_action">Load more messages</string>
|
<string name="message_list_load_more_messages_action">Load more messages</string>
|
||||||
<string name="message_list_to_fmt">To:<xliff:g id="counterParty">%s</xliff:g></string>
|
<string name="message_list_to_fmt">To:</string>
|
||||||
<string name="message_list_delete_action">Delete</string>
|
<string name="message_list_delete_action">Delete</string>
|
||||||
<string name="message_list_mark_read_action">Mark read</string>
|
<string name="message_list_mark_read_action">Mark read</string>
|
||||||
<string name="message_list_mark_unread_action">Mark unread</string>
|
<string name="message_list_mark_unread_action">Mark unread</string>
|
||||||
|
@ -1,74 +1,26 @@
|
|||||||
package com.fsck.k9.activity;
|
package com.fsck.k9.activity;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.text.Spannable;
|
|
||||||
import android.text.style.TextAppearanceSpan;
|
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.ContextMenu;
|
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
|
||||||
import android.view.GestureDetector;
|
|
||||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.text.format.DateFormat;
|
|
||||||
|
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.AccountStats;
|
|
||||||
import com.fsck.k9.FontSizes;
|
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.SearchSpecification;
|
|
||||||
import com.fsck.k9.activity.setup.AccountSettings;
|
|
||||||
import com.fsck.k9.activity.setup.FolderSettings;
|
|
||||||
import com.fsck.k9.activity.setup.Prefs;
|
|
||||||
import com.fsck.k9.activity.FolderInfoHolder;
|
import com.fsck.k9.activity.FolderInfoHolder;
|
||||||
import com.fsck.k9.controller.MessagingController;
|
import com.fsck.k9.controller.MessagingController;
|
||||||
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||||
import com.fsck.k9.controller.MessagingListener;
|
import com.fsck.k9.helper.Contacts;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.mail.Flag;
|
import com.fsck.k9.mail.Flag;
|
||||||
import com.fsck.k9.mail.Folder;
|
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.Message.RecipientType;
|
import com.fsck.k9.mail.Message.RecipientType;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.store.LocalStore;
|
|
||||||
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
|
||||||
import com.fsck.k9.mail.store.LocalStore.LocalMessage;
|
import com.fsck.k9.mail.store.LocalStore.LocalMessage;
|
||||||
|
|
||||||
public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
||||||
@ -78,7 +30,7 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||||||
public String fullDate;
|
public String fullDate;
|
||||||
public Date compareDate;
|
public Date compareDate;
|
||||||
public String compareSubject;
|
public String compareSubject;
|
||||||
public String sender;
|
public CharSequence sender;
|
||||||
public String senderAddress;
|
public String senderAddress;
|
||||||
public String compareCounterparty;
|
public String compareCounterparty;
|
||||||
public String preview;
|
public String preview;
|
||||||
@ -96,6 +48,8 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||||||
public String account;
|
public String account;
|
||||||
public String uri;
|
public String uri;
|
||||||
|
|
||||||
|
private Contacts mContacts;
|
||||||
|
|
||||||
private SORT_TYPE sortType = SORT_TYPE.SORT_DATE;
|
private SORT_TYPE sortType = SORT_TYPE.SORT_DATE;
|
||||||
|
|
||||||
private boolean sortAscending = true;
|
private boolean sortAscending = true;
|
||||||
@ -111,6 +65,9 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||||||
public MessageInfoHolder(Context context, Message m)
|
public MessageInfoHolder(Context context, Message m)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
|
|
||||||
|
mContacts = Contacts.getInstance(context);
|
||||||
|
|
||||||
Account account = m.getFolder().getAccount();
|
Account account = m.getFolder().getAccount();
|
||||||
mController = MessagingController.getInstance(K9.app);
|
mController = MessagingController.getInstance(K9.app);
|
||||||
sortType = mController.getSortType();
|
sortType = mController.getSortType();
|
||||||
@ -122,6 +79,9 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||||||
public MessageInfoHolder(Context context ,Message m, SORT_TYPE t_sort, boolean asc)
|
public MessageInfoHolder(Context context ,Message m, SORT_TYPE t_sort, boolean asc)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
|
|
||||||
|
mContacts = Contacts.getInstance(context);
|
||||||
|
|
||||||
Account account = m.getFolder().getAccount();
|
Account account = m.getFolder().getAccount();
|
||||||
mController = MessagingController.getInstance(K9.app);
|
mController = MessagingController.getInstance(K9.app);
|
||||||
sortType = t_sort;
|
sortType = t_sort;
|
||||||
@ -133,11 +93,15 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||||||
public MessageInfoHolder(Context context, Message m, FolderInfoHolder folder, Account account)
|
public MessageInfoHolder(Context context, Message m, FolderInfoHolder folder, Account account)
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
|
|
||||||
|
mContacts = Contacts.getInstance(context);
|
||||||
|
|
||||||
mController = MessagingController.getInstance(K9.app);
|
mController = MessagingController.getInstance(K9.app);
|
||||||
sortType = mController.getSortType();
|
sortType = mController.getSortType();
|
||||||
sortAscending = mController.isSortAscending(sortType);
|
sortAscending = mController.isSortAscending(sortType);
|
||||||
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
||||||
populate(context, m, folder, account);
|
populate(context, m, folder, account);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populate(Context context, Message m, FolderInfoHolder folder, Account account)
|
public void populate(Context context, Message m, FolderInfoHolder folder, Account account)
|
||||||
@ -175,13 +139,13 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||||||
|
|
||||||
if (addrs.length > 0 && account.isAnIdentity(addrs[0]))
|
if (addrs.length > 0 && account.isAnIdentity(addrs[0]))
|
||||||
{
|
{
|
||||||
this.compareCounterparty = Address.toFriendly(message .getRecipients(RecipientType.TO));
|
CharSequence to = Address.toFriendly(message .getRecipients(RecipientType.TO), mContacts);
|
||||||
this.sender = String.format(context.getString(R.string.message_list_to_fmt), this.compareCounterparty);
|
this.compareCounterparty = to.toString();
|
||||||
}
|
this.sender = new SpannableStringBuilder(context.getString(R.string.message_list_to_fmt)).append(to); }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.sender = Address.toFriendly(addrs);
|
this.sender = Address.toFriendly(addrs, mContacts);
|
||||||
this.compareCounterparty = this.sender;
|
this.compareCounterparty = this.sender.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addrs.length > 0)
|
if (addrs.length > 0)
|
||||||
|
@ -12,11 +12,14 @@ import android.app.Dialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.style.TextAppearanceSpan;
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@ -59,6 +62,7 @@ import com.fsck.k9.activity.setup.Prefs;
|
|||||||
import com.fsck.k9.controller.MessagingController;
|
import com.fsck.k9.controller.MessagingController;
|
||||||
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||||
import com.fsck.k9.controller.MessagingListener;
|
import com.fsck.k9.controller.MessagingListener;
|
||||||
|
import com.fsck.k9.helper.Contacts;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.mail.Flag;
|
import com.fsck.k9.mail.Flag;
|
||||||
@ -437,6 +441,7 @@ public class MessageList
|
|||||||
{
|
{
|
||||||
context=this;
|
context=this;
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mInflater = getLayoutInflater();
|
mInflater = getLayoutInflater();
|
||||||
initializeLayout();
|
initializeLayout();
|
||||||
onNewIntent(getIntent());
|
onNewIntent(getIntent());
|
||||||
@ -2416,22 +2421,21 @@ 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(message.sender + " " + message.preview,
|
holder.preview.setText(new SpannableStringBuilder(message.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(
|
str.setSpan(new StyleSpan(Typeface.BOLD),
|
||||||
new TextAppearanceSpan(
|
|
||||||
null,
|
|
||||||
Typeface.BOLD,
|
|
||||||
-1,
|
|
||||||
holder.subject.getTextColors(),
|
|
||||||
holder.subject.getLinkTextColors()),
|
|
||||||
0,
|
0,
|
||||||
message.sender.length(),
|
message.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
|
||||||
|
message.sender.length(),
|
||||||
|
str.length(),
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -428,11 +428,11 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
public void setHeaders(
|
public void setHeaders(
|
||||||
final String subject,
|
final String subject,
|
||||||
final String from,
|
final CharSequence from,
|
||||||
final String date,
|
final String date,
|
||||||
final String time,
|
final String time,
|
||||||
final String to,
|
final CharSequence to,
|
||||||
final String cc,
|
final CharSequence cc,
|
||||||
final int accountColor,
|
final int accountColor,
|
||||||
final boolean unread,
|
final boolean unread,
|
||||||
final boolean hasAttachments,
|
final boolean hasAttachments,
|
||||||
@ -2093,11 +2093,11 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
final Message message) throws MessagingException
|
final Message message) throws MessagingException
|
||||||
{
|
{
|
||||||
String subjectText = message.getSubject();
|
String subjectText = message.getSubject();
|
||||||
String fromText = Address.toFriendly(message.getFrom());
|
CharSequence fromText = Address.toFriendly(message.getFrom(), mContacts);
|
||||||
String dateText = getDateFormat().format(message.getSentDate());
|
String dateText = getDateFormat().format(message.getSentDate());
|
||||||
String timeText = getTimeFormat().format(message.getSentDate());
|
String timeText = getTimeFormat().format(message.getSentDate());
|
||||||
String toText = Address.toFriendly(message.getRecipients(RecipientType.TO));
|
CharSequence toText = Address.toFriendly(message.getRecipients(RecipientType.TO), mContacts);
|
||||||
String ccText = Address.toFriendly(message.getRecipients(RecipientType.CC));
|
CharSequence ccText = Address.toFriendly(message.getRecipients(RecipientType.CC), mContacts);
|
||||||
|
|
||||||
int color = mAccount.getChipColor();
|
int color = mAccount.getChipColor();
|
||||||
boolean hasAttachments = ((LocalMessage) message).getAttachmentCount() > 0;
|
boolean hasAttachments = ((LocalMessage) message).getAttachmentCount() > 0;
|
||||||
|
@ -4570,7 +4570,7 @@ public class MessagingController implements Runnable
|
|||||||
if (message != null && message.getFrom() != null)
|
if (message != null && message.getFrom() != null)
|
||||||
{
|
{
|
||||||
Address[] fromAddrs = message.getFrom();
|
Address[] fromAddrs = message.getFrom();
|
||||||
String from = fromAddrs.length > 0 ? fromAddrs[0].toFriendly() : null;
|
String from = fromAddrs.length > 0 ? fromAddrs[0].toFriendly().toString() : null;
|
||||||
String subject = message.getSubject();
|
String subject = message.getSubject();
|
||||||
if (subject == null)
|
if (subject == null)
|
||||||
{
|
{
|
||||||
@ -4593,7 +4593,7 @@ public class MessagingController implements Runnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
|
Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
|
||||||
String to = rcpts.length > 0 ? rcpts[0].toFriendly() : null;
|
String to = rcpts.length > 0 ? rcpts[0].toFriendly().toString() : null;
|
||||||
if (to != null)
|
if (to != null)
|
||||||
{
|
{
|
||||||
messageNotice.append(String.format(context.getString(R.string.message_list_to_fmt), to) +": "+subject);
|
messageNotice.append(String.format(context.getString(R.string.message_list_to_fmt), to) +": "+subject);
|
||||||
|
@ -147,6 +147,8 @@ public abstract class Contacts
|
|||||||
*/
|
*/
|
||||||
public abstract Cursor searchContacts(CharSequence filter);
|
public abstract Cursor searchContacts(CharSequence filter);
|
||||||
|
|
||||||
|
public abstract Cursor searchByAddress(String address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the name from a {@link Cursor} instance returned by
|
* Extract the name from a {@link Cursor} instance returned by
|
||||||
* {@link #searchContacts(CharSequence)}.
|
* {@link #searchContacts(CharSequence)}.
|
||||||
|
@ -173,6 +173,45 @@ public class ContactsSdk3_4 extends com.fsck.k9.helper.Contacts
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cursor searchByAddress(String address)
|
||||||
|
{
|
||||||
|
final String where;
|
||||||
|
final String[] args;
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
where = null;
|
||||||
|
args = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
where = Contacts.ContactMethods.DATA + " = ?";
|
||||||
|
args = new String[] {address};
|
||||||
|
}
|
||||||
|
|
||||||
|
final Cursor c = mContentResolver.query(
|
||||||
|
Contacts.ContactMethods.CONTENT_EMAIL_URI,
|
||||||
|
PROJECTION,
|
||||||
|
where,
|
||||||
|
args,
|
||||||
|
SORT_ORDER);
|
||||||
|
|
||||||
|
if (c != null)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* To prevent expensive execution in the UI thread:
|
||||||
|
* Cursors get lazily executed, so if you don't call anything on
|
||||||
|
* the cursor before returning it from the background thread you'll
|
||||||
|
* have a complied program for the cursor, but it won't have been
|
||||||
|
* executed to generate the data yet. Often the execution is more
|
||||||
|
* expensive than the compilation...
|
||||||
|
*/
|
||||||
|
c.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(Cursor c)
|
public String getName(Cursor c)
|
||||||
{
|
{
|
||||||
|
@ -149,6 +149,34 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cursor searchByAddress(String address)
|
||||||
|
{
|
||||||
|
final String filter = (address == null) ? "" : address;
|
||||||
|
final Uri uri = Uri.withAppendedPath(Email.CONTENT_FILTER_URI, Uri.encode(filter));
|
||||||
|
final Cursor c = mContentResolver.query(
|
||||||
|
uri,
|
||||||
|
PROJECTION,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
SORT_ORDER);
|
||||||
|
|
||||||
|
if (c != null)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* To prevent expensive execution in the UI thread:
|
||||||
|
* Cursors get lazily executed, so if you don't call anything on
|
||||||
|
* the cursor before returning it from the background thread you'll
|
||||||
|
* have a complied program for the cursor, but it won't have been
|
||||||
|
* executed to generate the data yet. Often the execution is more
|
||||||
|
* expensive than the compilation...
|
||||||
|
*/
|
||||||
|
c.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(Cursor c)
|
public String getName(Cursor c)
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
|
||||||
package com.fsck.k9.mail;
|
package com.fsck.k9.mail;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.util.Rfc822Token;
|
import android.text.util.Rfc822Token;
|
||||||
import android.text.util.Rfc822Tokenizer;
|
import android.text.util.Rfc822Tokenizer;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
|
import com.fsck.k9.helper.Contacts;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
import org.apache.james.mime4j.codec.EncoderUtil;
|
import org.apache.james.mime4j.codec.EncoderUtil;
|
||||||
import org.apache.james.mime4j.field.address.AddressList;
|
import org.apache.james.mime4j.field.address.AddressList;
|
||||||
@ -14,7 +19,11 @@ import org.apache.james.mime4j.field.address.NamedMailbox;
|
|||||||
import org.apache.james.mime4j.field.address.parser.ParseException;
|
import org.apache.james.mime4j.field.address.parser.ParseException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class Address
|
public class Address
|
||||||
{
|
{
|
||||||
@ -23,6 +32,8 @@ public class Address
|
|||||||
* Immutable empty {@link Address} array
|
* Immutable empty {@link Address} array
|
||||||
*/
|
*/
|
||||||
private static final Address[] EMPTY_ADDRESS_ARRAY = new Address[0];
|
private static final Address[] EMPTY_ADDRESS_ARRAY = new Address[0];
|
||||||
|
private static Map<String,String> sContactsName = new ConcurrentHashMap<String, String>();
|
||||||
|
private static final String NO_ENTRY = "";
|
||||||
|
|
||||||
String mAddress;
|
String mAddress;
|
||||||
|
|
||||||
@ -230,11 +241,43 @@ public class Address
|
|||||||
* is not available.
|
* is not available.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String toFriendly()
|
public CharSequence toFriendly()
|
||||||
{
|
{
|
||||||
|
return toFriendly((Contacts)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence toFriendly(Contacts contacts)
|
||||||
|
{
|
||||||
|
if (contacts != null) {
|
||||||
|
String name = sContactsName.get(mAddress);
|
||||||
|
if (name != null && name != NO_ENTRY) {
|
||||||
|
return Html.fromHtml("<font color=\"Blue\">" + name + "</font>"); // TODO: use setSpan
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
Cursor cursor = contacts.searchByAddress(mAddress);
|
||||||
|
if (cursor != null) {
|
||||||
|
try {
|
||||||
|
if (cursor.getCount() > 0) {
|
||||||
|
cursor.moveToFirst();
|
||||||
|
name = contacts.getName(cursor);
|
||||||
|
sContactsName.put(mAddress, name);
|
||||||
|
return Html.fromHtml("<font color=\"Blue\">" + name + "</font>"); // TODO: use setSpan
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sContactsName.put(mAddress, NO_ENTRY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Log.i(K9.LOG_TAG, "cursor closed");
|
||||||
|
// cursor.close(); // TODO: should close cursor.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mPersonal != null && mPersonal.length() > 0)
|
if (mPersonal != null && mPersonal.length() > 0)
|
||||||
{
|
{
|
||||||
return mPersonal;
|
return mPersonal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -242,22 +285,27 @@ public class Address
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toFriendly(Address[] addresses)
|
public static CharSequence toFriendly(Address[] addresses)
|
||||||
|
{
|
||||||
|
return toFriendly(addresses, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence toFriendly(Address[] addresses, Contacts contacts)
|
||||||
{
|
{
|
||||||
if (addresses == null)
|
if (addresses == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuffer sb = new StringBuffer();
|
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||||
for (int i = 0; i < addresses.length; i++)
|
for (int i = 0; i < addresses.length; i++)
|
||||||
{
|
{
|
||||||
sb.append(addresses[i].toFriendly());
|
sb.append(addresses[i].toFriendly(contacts));
|
||||||
if (i < addresses.length - 1)
|
if (i < addresses.length - 1)
|
||||||
{
|
{
|
||||||
sb.append(',');
|
sb.append(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user