use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageInfoHolder method create.
public static MessageInfoHolder create(Context context, LocalMessage message, Account account) {
Contacts contactHelper = K9.isShowContactName() ? Contacts.getInstance(context) : null;
MessageInfoHolder target = new MessageInfoHolder();
target.message = message;
target.compareDate = message.getSentDate();
if (target.compareDate == null) {
target.compareDate = message.getInternalDate();
}
target.read = message.isSet(Flag.SEEN);
Address[] addrs = message.getFrom();
String counterParty;
if (addrs.length > 0 && account.isAnIdentity(addrs[0])) {
CharSequence to = MessageHelper.toFriendly(message.getRecipients(RecipientType.TO), contactHelper);
counterParty = to.toString();
target.sender = new SpannableStringBuilder(context.getString(R.string.message_to_label)).append(to);
} else {
target.sender = MessageHelper.toFriendly(addrs, contactHelper);
counterParty = target.sender.toString();
}
if (addrs.length > 0) {
target.senderAddress = addrs[0].getAddress();
} else {
// a reasonable fallback "whomever we were corresponding with
target.senderAddress = counterParty;
}
target.uid = message.getUid();
target.uri = message.getUri();
return target;
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageCompose method processMessageToReplyTo.
private void processMessageToReplyTo(MessageViewInfo messageViewInfo) throws MessagingException {
Message message = messageViewInfo.message;
if (messageViewInfo.subject != null) {
final String subject = PREFIX.matcher(messageViewInfo.subject).replaceFirst("");
if (!subject.toLowerCase(Locale.US).startsWith("re:")) {
subjectView.setText("Re: " + subject);
} else {
subjectView.setText(subject);
}
} else {
subjectView.setText("");
}
/*
* If a reply-to was included with the message use that, otherwise use the from
* or sender address.
*/
boolean isReplyAll = action == Action.REPLY_ALL;
recipientPresenter.initFromReplyToMessage(message, isReplyAll);
if (message.getMessageId() != null && message.getMessageId().length() > 0) {
repliedToMessageId = message.getMessageId();
String[] refs = message.getReferences();
if (refs != null && refs.length > 0) {
referencedMessageIds = TextUtils.join("", refs) + " " + repliedToMessageId;
} else {
referencedMessageIds = repliedToMessageId;
}
} else {
Timber.d("could not get Message-ID.");
}
// Quote the message and setup the UI.
quotedMessagePresenter.initFromReplyToMessage(messageViewInfo, action);
if (action == Action.REPLY || action == Action.REPLY_ALL) {
setIdentityFromMessage(message);
}
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MailToTest method testGetCc_singleEmailAddress.
@Test
public void testGetCc_singleEmailAddress() {
Uri uri = Uri.parse("mailto:test1@abc.com?cc=test3@abc.com");
MailTo mailToHelper = MailTo.parse(uri);
Address[] emailAddressList = mailToHelper.getCc();
assertEquals(emailAddressList[0].getAddress(), "test3@abc.com");
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class ListHeadersTest method getListPostAddresses_withMailTo_shouldReturnCorrectAddress.
@Test
public void getListPostAddresses_withMailTo_shouldReturnCorrectAddress() throws Exception {
for (String emailAddress : TEST_EMAIL_ADDRESSES) {
String headerValue = "<mailto:" + emailAddress + ">";
Message message = buildMimeMessageWithListPostValue(headerValue);
Address[] result = ListHeaders.getListPostAddresses(message);
assertExtractedAddressMatchesEmail(emailAddress, result);
}
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class ListHeadersTest method getListPostAddresses_withMailtoWithNote_shouldReturnCorrectAddress.
@Test
public void getListPostAddresses_withMailtoWithNote_shouldReturnCorrectAddress() throws Exception {
for (String emailAddress : TEST_EMAIL_ADDRESSES) {
String headerValue = "<mailto:" + emailAddress + "> (Postings are Moderated)";
Message message = buildMimeMessageWithListPostValue(headerValue);
Address[] result = ListHeaders.getListPostAddresses(message);
assertExtractedAddressMatchesEmail(emailAddress, result);
}
}
Aggregations