本文整理了Java中com.fsck.k9.mail.Message.getFrom()
方法的一些代码示例,展示了Message.getFrom()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getFrom()
方法的具体详情如下:
包路径:com.fsck.k9.mail.Message
类名称:Message
方法名:getFrom
暂无
代码示例来源:origin: k9mail/k-9
public static boolean shouldShowSender(Message message) {
Address[] from = message.getFrom();
Address[] sender = message.getSender();
return sender != null && sender.length != 0 && !Arrays.equals(from, sender);
}
代码示例来源:origin: k9mail/k-9
private String getSenderEmailAddress(Message message) {
Address[] from = message.getFrom();
if (from == null || from.length == 0) {
return null;
}
return from[0].getAddress();
}
代码示例来源:origin: k9mail/k-9
@NonNull
private Intent getDecryptVerifyIntent() {
Intent decryptIntent = new Intent(OpenPgpApi.ACTION_DECRYPT_VERIFY);
Address[] from = currentMessage.getFrom();
if (from.length > 0) {
decryptIntent.putExtra(OpenPgpApi.EXTRA_SENDER_ADDRESS, from[0].getAddress());
// we add this here independently of the autocrypt peer update, to allow picking up signing keys as gossip
decryptIntent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, from[0].getAddress());
}
autocryptOperations.addAutocryptPeerUpdateToIntentIfPresent(currentMessage, decryptIntent);
decryptIntent.putExtra(OpenPgpApi.EXTRA_SUPPORT_OVERRIDE_CRYPTO_WARNING, true);
decryptIntent.putExtra(OpenPgpApi.EXTRA_DECRYPTION_RESULT, cachedDecryptionResult);
return decryptIntent;
}
代码示例来源:origin: k9mail/k-9
private static String getJisVariantFromFromHeaders(Message message) {
Address addresses[] = message.getFrom();
if (addresses == null || addresses.length == 0) {
return null;
}
return getJisVariantFromAddress(addresses[0].getAddress());
}
代码示例来源:origin: k9mail/k-9
private void onAddSenderToContacts() {
if (mMessage != null) {
try {
final Address senderEmail = mMessage.getFrom()[0];
mContacts.createContact(senderEmail);
} catch (Exception e) {
Timber.e(e, "Couldn't create contact");
}
}
}
代码示例来源:origin: k9mail/k-9
@Override
public boolean onLongClick(View view) {
int id = view.getId();
if (id == R.id.from) {
onAddAddressesToClipboard(mMessage.getFrom());
} else if (id == R.id.to) {
onAddRecipientsToClipboard(Message.RecipientType.TO);
} else if (id == R.id.cc) {
onAddRecipientsToClipboard(Message.RecipientType.CC);
}
return true;
}
代码示例来源: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
public boolean addAutocryptPeerUpdateToIntentIfPresent(Message currentMessage, Intent intent) {
AutocryptHeader autocryptHeader = autocryptHeaderParser.getValidAutocryptHeader(currentMessage);
if (autocryptHeader == null) {
return false;
}
String messageFromAddress = currentMessage.getFrom()[0].getAddress();
if (!autocryptHeader.addr.equalsIgnoreCase(messageFromAddress)) {
return false;
}
Date messageDate = currentMessage.getSentDate();
Date internalDate = currentMessage.getInternalDate();
Date effectiveDate = messageDate.before(internalDate) ? messageDate : internalDate;
AutocryptPeerUpdate data = AutocryptPeerUpdate.create(
autocryptHeader.keyData, effectiveDate, autocryptHeader.isPreferEncryptMutual);
intent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, messageFromAddress);
intent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_UPDATE, data);
return true;
}
代码示例来源:origin: k9mail/k-9
public String generateMessageId(Message message) {
String hostname = null;
Address[] from = message.getFrom();
if (from != null && from.length >= 1) {
hostname = from[0].getHostname();
}
if (hostname == null) {
Address[] replyTo = message.getReplyTo();
if (replyTo != null && replyTo.length >= 1) {
hostname = replyTo[0].getHostname();
}
}
if (hostname == null) {
hostname = "email.android.com";
}
String uuid = generateUuid();
return "<" + uuid + "@" + hostname + ">";
}
代码示例来源: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 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
@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_return_from_otherwise() 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);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(FROM_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
verify(account).isAnIdentity(result.to);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field() 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);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(REPLY_TO_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
verify(account).isAnIdentity(result.to);
}
代码示例来源:origin: k9mail/k-9
@Test
public void getRecipientsToReplyTo_should_prefer_listPost_over_from_field() throws Exception {
when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
when(message.getFrom()).thenReturn(FROM_ADDRESSES);
ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
assertArrayEquals(LIST_POST_ADDRESSES, result.to);
assertArrayEquals(EMPTY_ADDRESSES, result.cc);
verify(account).isAnIdentity(result.to);
}
代码示例来源: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_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
@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
String mailFrom = constructSmtpMailFromCommand(message.getFrom(), is8bitEncodingAllowed);
代码示例来源:origin: k9mail/k-9
Address[] from = message.getFrom();
if (from != null && from.length > 0) {
addTableRow(html, resourceProvider.messageHeaderFrom(),
内容来源于网络,如有侵权,请联系作者删除!