use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageHeader method populate.
public void populate(final Message message, final Account account, boolean showStar) {
Address fromAddress = null;
Address[] fromAddresses = message.getFrom();
if (fromAddresses.length > 0) {
fromAddress = fromAddresses[0];
}
final Contacts contacts = K9.isShowContactName() ? mContacts : null;
final CharSequence from = mMessageHelper.getSenderDisplayName(fromAddress);
final CharSequence to = MessageHelper.toFriendly(message.getRecipients(Message.RecipientType.TO), contacts);
final CharSequence cc = MessageHelper.toFriendly(message.getRecipients(Message.RecipientType.CC), contacts);
final CharSequence bcc = MessageHelper.toFriendly(message.getRecipients(Message.RecipientType.BCC), contacts);
mMessage = message;
mAccount = account;
if (K9.isShowContactPicture()) {
mContactBadge.setVisibility(View.VISIBLE);
mContactsPictureLoader = ContactPicture.getContactPictureLoader();
} else {
mContactBadge.setVisibility(View.GONE);
}
if (shouldShowSender(message)) {
mSenderView.setVisibility(VISIBLE);
String sender = getResources().getString(R.string.message_view_sender_label, MessageHelper.toFriendly(message.getSender(), contacts));
mSenderView.setText(sender);
} else {
mSenderView.setVisibility(View.GONE);
}
String dateTime = DateUtils.formatDateTime(mContext, message.getSentDate().getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_YEAR);
mDateView.setText(dateTime);
if (K9.isShowContactPicture()) {
if (fromAddress != null) {
mContactBadge.setContact(fromAddress);
mContactsPictureLoader.setContactPicture(mContactBadge, fromAddress);
} else {
mContactBadge.setImageResource(R.drawable.ic_contact_picture);
}
}
mFromView.setText(from);
updateAddressField(mToView, to, mToLabel);
updateAddressField(mCcView, cc, mCcLabel);
updateAddressField(mBccView, bcc, mBccLabel);
mAnsweredIcon.setVisibility(message.isSet(Flag.ANSWERED) ? View.VISIBLE : View.GONE);
mForwardedIcon.setVisibility(message.isSet(Flag.FORWARDED) ? View.VISIBLE : View.GONE);
if (showStar) {
mFlagged.setVisibility(View.VISIBLE);
mFlagged.setChecked(message.isSet(Flag.FLAGGED));
} else {
mFlagged.setVisibility(View.GONE);
}
mChip.setBackgroundColor(mAccount.getChipColor());
setVisibility(View.VISIBLE);
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class ReplyToParser method getRecipientsToReplyAllTo.
public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) {
List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to);
HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses);
ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses);
ArrayList<Address> ccAddresses = new ArrayList<>();
for (Address address : message.getFrom()) {
if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) {
toAddresses.add(address);
alreadyAddedAddresses.add(address);
}
}
for (Address address : message.getRecipients(RecipientType.TO)) {
if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) {
toAddresses.add(address);
alreadyAddedAddresses.add(address);
}
}
for (Address address : message.getRecipients(RecipientType.CC)) {
if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) {
ccAddresses.add(address);
alreadyAddedAddresses.add(address);
}
}
return new ReplyToAddresses(toAddresses, ccAddresses);
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class ListHeaders method extractAddress.
private static Address extractAddress(String headerValue) {
if (headerValue == null || headerValue.isEmpty()) {
return null;
}
Matcher matcher = MAILTO_CONTAINER_PATTERN.matcher(headerValue);
if (!matcher.find()) {
return null;
}
Uri mailToUri = Uri.parse(matcher.group(1));
Address[] emailAddress = MailTo.parse(mailToUri).getTo();
return emailAddress.length >= 1 ? emailAddress[0] : null;
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MailToTest method testGetTo_multipleEmailAddress.
@Test
public void testGetTo_multipleEmailAddress() {
Uri uri = Uri.parse("mailto:test1@abc.com?to=test2@abc.com");
MailTo mailToHelper = MailTo.parse(uri);
Address[] emailAddressList = mailToHelper.getTo();
assertEquals(emailAddressList[0].getAddress(), "test1@abc.com");
assertEquals(emailAddressList[1].getAddress(), "test2@abc.com");
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MailToTest method testGetBcc_multipleEmailAddress.
@Test
public void testGetBcc_multipleEmailAddress() {
Uri uri = Uri.parse("mailto:?bcc=test3@abc.com&bcc=test4@abc.com");
MailTo mailToHelper = MailTo.parse(uri);
Address[] emailAddressList = mailToHelper.getBcc();
assertEquals(emailAddressList[0].getAddress(), "test3@abc.com");
assertEquals(emailAddressList[1].getAddress(), "test4@abc.com");
}
Aggregations