本文整理了Java中com.fsck.k9.mail.Message.getRecipients()
方法的一些代码示例,展示了Message.getRecipients()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getRecipients()
方法的具体详情如下:
包路径:com.fsck.k9.mail.Message
类名称:Message
方法名:getRecipients
暂无
代码示例来源:origin: k9mail/k-9
private void initRecipientsFromDraftMessage(Message message) {
addToAddresses(message.getRecipients(RecipientType.TO));
Address[] ccRecipients = message.getRecipients(RecipientType.CC);
addCcAddresses(ccRecipients);
Address[] bccRecipients = message.getRecipients(RecipientType.BCC);
addBccAddresses(bccRecipients);
}
代码示例来源:origin: k9mail/k-9
private void removeRecipientsFromList(ArrayList<String> result, Message message, RecipientType recipientType) {
for (Address address : message.getRecipients(recipientType)) {
String addr = address.getAddress();
if (addr != null) {
result.remove(addr);
}
}
}
代码示例来源:origin: k9mail/k-9
private void addRecipientsToList(ArrayList<String> result, Message message, RecipientType recipientType) {
for (Address address : message.getRecipients(recipientType)) {
String addr = address.getAddress();
if (addr != null) {
result.add(addr.toLowerCase());
}
}
}
代码示例来源:origin: k9mail/k-9
private void onAddRecipientsToClipboard(Message.RecipientType recipientType) {
onAddAddressesToClipboard(mMessage.getRecipients(recipientType));
}
代码示例来源:origin: k9mail/k-9
@Override
public void sendMessage(Message message) throws MessagingException {
List<Address> addresses = new ArrayList<>();
{
addresses.addAll(Arrays.asList(message.getRecipients(RecipientType.TO)));
addresses.addAll(Arrays.asList(message.getRecipients(RecipientType.CC)));
addresses.addAll(Arrays.asList(message.getRecipients(RecipientType.BCC)));
}
message.setRecipients(RecipientType.BCC, null);
Map<String, List<String>> charsetAddressesMap = new HashMap<>();
for (Address address : addresses) {
String addressString = address.getAddress();
String charset = CharsetSupport.getCharsetFromAddress(addressString);
List<String> addressesOfCharset = charsetAddressesMap.get(charset);
if (addressesOfCharset == null) {
addressesOfCharset = new ArrayList<>();
charsetAddressesMap.put(charset, addressesOfCharset);
}
addressesOfCharset.add(addressString);
}
for (Map.Entry<String, List<String>> charsetAddressesMapEntry :
charsetAddressesMap.entrySet()) {
String charset = charsetAddressesMapEntry.getKey();
List<String> addressesOfCharset = charsetAddressesMapEntry.getValue();
message.setCharset(charset);
sendMessageTo(addressesOfCharset, message);
}
}
代码示例来源:origin: k9mail/k-9
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);
}
代码示例来源:origin: k9mail/k-9
Identity recipient = null;
for (Address address : message.getRecipients(Message.RecipientType.TO)) {
Identity identity = account.findIdentity(address);
if (identity != null) {
Address[] ccAddresses = message.getRecipients(Message.RecipientType.CC);
if (ccAddresses.length > 0) {
for (Address address : ccAddresses) {
for (Address address : message.getRecipients(Message.RecipientType.X_ORIGINAL_TO)) {
Identity identity = account.findIdentity(address);
if (identity != null) {
for (Address address : message.getRecipients(Message.RecipientType.DELIVERED_TO)) {
Identity identity = account.findIdentity(address);
if (identity != null) {
for (Address address : message.getRecipients(Message.RecipientType.X_ENVELOPE_TO)) {
Identity identity = account.findIdentity(address);
if (identity != null) {
代码示例来源:origin: k9mail/k-9
@Override
protected Void doInBackground(Void... params) {
try {
contacts.markAsContacted(message.getRecipients(RecipientType.TO));
contacts.markAsContacted(message.getRecipients(RecipientType.CC));
contacts.markAsContacted(message.getRecipients(RecipientType.BCC));
updateReferencedMessage();
} catch (Exception e) {
Timber.e(e, "Failed to mark contact as contacted.");
}
MessagingController.getInstance(context).sendMessage(account, message, plaintextSubject, null);
if (draftId != null) {
// TODO set draft id to invalid in MessageCompose!
MessagingController.getInstance(context).deleteDraft(account, draftId);
}
return null;
}
代码示例来源:origin: k9mail/k-9
.append("<br>\r\n");
if (originalMessage.getRecipients(RecipientType.TO) != null && originalMessage.getRecipients(RecipientType.TO).length != 0) {
header.append("<b>").append(resourceProvider.messageHeaderTo()).append("</b> ")
.append(HtmlConverter.textToHtmlFragment(Address.toString(originalMessage.getRecipients(RecipientType.TO))))
.append("<br>\r\n");
if (originalMessage.getRecipients(RecipientType.CC) != null && originalMessage.getRecipients(RecipientType.CC).length != 0) {
header.append("<b>").append(resourceProvider.messageHeaderCc()).append("</b> ")
.append(HtmlConverter.textToHtmlFragment(Address.toString(originalMessage.getRecipients(RecipientType.CC))))
.append("<br>\r\n");
代码示例来源:origin: k9mail/k-9
Address[] to = message.getRecipients(Message.RecipientType.TO);
if (to != null && to.length > 0) {
text.append(resourceProvider.messageHeaderTo());
Address[] cc = message.getRecipients(Message.RecipientType.CC);
if (cc != null && cc.length > 0) {
text.append(resourceProvider.messageHeaderCc());
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyAllTo_should_returnFromAndToAndCcRecipients() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
assertArrayEquals(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class), recipientsToReplyAllTo.to);
assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_prefer_from_ifOtherIsIdentity() throws Exception {
when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
when(account.isAnIdentity(any(Address[].class))).thenReturn(true);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(TO_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
}
代码示例来源:origin: k9mail/k-9
private String getMessageSender(Account account, Message message) {
boolean isSelf = false;
final Contacts contacts = K9.showContactName() ? Contacts.getInstance(context) : null;
final Address[] fromAddresses = message.getFrom();
if (fromAddresses != null) {
isSelf = account.isAnIdentity(fromAddresses);
if (!isSelf && fromAddresses.length > 0) {
return MessageHelper.toFriendly(fromAddresses[0], contacts).toString();
}
}
if (isSelf) {
// show To: if the message was sent from me
Address[] recipients = message.getRecipients(Message.RecipientType.TO);
if (recipients != null && recipients.length > 0) {
String recipientDisplayName = MessageHelper.toFriendly(recipients[0], contacts).toString();
return resourceProvider.recipientDisplayName(recipientDisplayName);
}
}
return null;
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyAllTo_should_excludeIdentityAddresses() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
when(message.getFrom()).thenReturn(EMPTY_ADDRESSES);
when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
Address excludedCcAddress = CC_ADDRESSES[1];
Address excludedToAddress = TO_ADDRESSES[0];
when(account.isAnIdentity(eq(excludedToAddress))).thenReturn(true);
when(account.isAnIdentity(eq(excludedCcAddress))).thenReturn(true);
ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
assertArrayEquals(arrayExcept(TO_ADDRESSES, excludedToAddress), recipientsToReplyAllTo.to);
assertArrayEquals(arrayExcept(CC_ADDRESSES, excludedCcAddress), recipientsToReplyAllTo.cc);
}
代码示例来源:origin: k9mail/k-9
public ReplyToAddresses getRecipientsToReplyTo(Message message, Account account) {
Address[] candidateAddress;
Address[] replyToAddresses = message.getReplyTo();
Address[] listPostAddresses = ListHeaders.getListPostAddresses(message);
Address[] fromAddresses = message.getFrom();
if (replyToAddresses.length > 0) {
candidateAddress = replyToAddresses;
} else if (listPostAddresses.length > 0) {
candidateAddress = listPostAddresses;
} else {
candidateAddress = fromAddresses;
}
boolean replyToAddressIsUserIdentity = account.isAnIdentity(candidateAddress);
if (replyToAddressIsUserIdentity) {
candidateAddress = message.getRecipients(RecipientType.TO);
}
return new ReplyToAddresses(candidateAddress);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyAllTo_should_excludeDuplicates() throws Exception {
when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
when(message.getFrom()).thenReturn(arrayConcatenate(FROM_ADDRESSES, REPLY_TO_ADDRESSES, Address.class));
when(message.getRecipients(RecipientType.TO)).thenReturn(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class));
when(message.getRecipients(RecipientType.CC)).thenReturn(arrayConcatenate(CC_ADDRESSES, TO_ADDRESSES, Address.class));
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
assertArrayContainsAll(REPLY_TO_ADDRESSES, recipientsToReplyAllTo.to);
assertArrayContainsAll(FROM_ADDRESSES, recipientsToReplyAllTo.to);
assertArrayContainsAll(TO_ADDRESSES, recipientsToReplyAllTo.to);
int totalExpectedAddresses = REPLY_TO_ADDRESSES.length + FROM_ADDRESSES.length + TO_ADDRESSES.length;
assertEquals(totalExpectedAddresses, recipientsToReplyAllTo.to.length);
assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
}
代码示例来源:origin: k9mail/k-9
public void populate(final Message message, final Account account) {
final Contacts contacts = K9.showContactName() ? mContacts : null;
final CharSequence from = MessageHelper.toFriendly(message.getFrom(), contacts);
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);
Address[] toAddrs = message.getRecipients(Message.RecipientType.TO);
Address[] ccAddrs = message.getRecipients(Message.RecipientType.CC);
boolean fromMe = mMessageHelper.toMe(account, fromAddrs);
代码示例来源:origin: k9mail/k-9
cv.put("forwarded", message.isSet(Flag.FORWARDED) ? 1 : 0);
cv.put("folder_id", databaseId);
cv.put("to_list", Address.pack(message.getRecipients(RecipientType.TO)));
cv.put("cc_list", Address.pack(message.getRecipients(RecipientType.CC)));
cv.put("bcc_list", Address.pack(message.getRecipients(RecipientType.BCC)));
cv.put("reply_to_list", Address.pack(message.getReplyTo()));
cv.put("attachment_count", attachmentCount);
代码示例来源:origin: k9mail/k-9
Address[] to = message.getRecipients(Message.RecipientType.TO);
if (to != null && to.length > 0) {
addTableRow(html, resourceProvider.messageHeaderTo(),
Address[] cc = message.getRecipients(Message.RecipientType.CC);
if (cc != null && cc.length > 0) {
addTableRow(html, resourceProvider.messageHeaderCc(),
代码示例来源:origin: jberkel/sms-backup-plus
private void assertMessage(Message message) {
assertThat(message).isNotNull();
assertThat(message.getSubject()).isEqualTo("Call with Test Testor");
assertThat(message.getFrom()[0].toString()).isEqualTo("Test Testor <unknown.number@unknown.email>");
assertThat(message.getRecipients(Message.RecipientType.TO)[0]).isEqualTo(me);
}
内容来源于网络,如有侵权,请联系作者删除!