com.fsck.k9.mail.Message.getFrom()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(280)

本文整理了Java中com.fsck.k9.mail.Message.getFrom()方法的一些代码示例,展示了Message.getFrom()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getFrom()方法的具体详情如下:
包路径:com.fsck.k9.mail.Message
类名称:Message
方法名:getFrom

Message.getFrom介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

  1. public static boolean shouldShowSender(Message message) {
  2. Address[] from = message.getFrom();
  3. Address[] sender = message.getSender();
  4. return sender != null && sender.length != 0 && !Arrays.equals(from, sender);
  5. }

代码示例来源:origin: k9mail/k-9

  1. private String getSenderEmailAddress(Message message) {
  2. Address[] from = message.getFrom();
  3. if (from == null || from.length == 0) {
  4. return null;
  5. }
  6. return from[0].getAddress();
  7. }

代码示例来源:origin: k9mail/k-9

  1. @NonNull
  2. private Intent getDecryptVerifyIntent() {
  3. Intent decryptIntent = new Intent(OpenPgpApi.ACTION_DECRYPT_VERIFY);
  4. Address[] from = currentMessage.getFrom();
  5. if (from.length > 0) {
  6. decryptIntent.putExtra(OpenPgpApi.EXTRA_SENDER_ADDRESS, from[0].getAddress());
  7. // we add this here independently of the autocrypt peer update, to allow picking up signing keys as gossip
  8. decryptIntent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, from[0].getAddress());
  9. }
  10. autocryptOperations.addAutocryptPeerUpdateToIntentIfPresent(currentMessage, decryptIntent);
  11. decryptIntent.putExtra(OpenPgpApi.EXTRA_SUPPORT_OVERRIDE_CRYPTO_WARNING, true);
  12. decryptIntent.putExtra(OpenPgpApi.EXTRA_DECRYPTION_RESULT, cachedDecryptionResult);
  13. return decryptIntent;
  14. }

代码示例来源:origin: k9mail/k-9

  1. private static String getJisVariantFromFromHeaders(Message message) {
  2. Address addresses[] = message.getFrom();
  3. if (addresses == null || addresses.length == 0) {
  4. return null;
  5. }
  6. return getJisVariantFromAddress(addresses[0].getAddress());
  7. }

代码示例来源:origin: k9mail/k-9

  1. private void onAddSenderToContacts() {
  2. if (mMessage != null) {
  3. try {
  4. final Address senderEmail = mMessage.getFrom()[0];
  5. mContacts.createContact(senderEmail);
  6. } catch (Exception e) {
  7. Timber.e(e, "Couldn't create contact");
  8. }
  9. }
  10. }

代码示例来源:origin: k9mail/k-9

  1. @Override
  2. public boolean onLongClick(View view) {
  3. int id = view.getId();
  4. if (id == R.id.from) {
  5. onAddAddressesToClipboard(mMessage.getFrom());
  6. } else if (id == R.id.to) {
  7. onAddRecipientsToClipboard(Message.RecipientType.TO);
  8. } else if (id == R.id.cc) {
  9. onAddRecipientsToClipboard(Message.RecipientType.CC);
  10. }
  11. return true;
  12. }

代码示例来源:origin: k9mail/k-9

  1. public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) {
  2. List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to);
  3. HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses);
  4. ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses);
  5. ArrayList<Address> ccAddresses = new ArrayList<>();
  6. for (Address address : message.getFrom()) {
  7. if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) {
  8. toAddresses.add(address);
  9. alreadyAddedAddresses.add(address);
  10. }
  11. }
  12. for (Address address : message.getRecipients(RecipientType.TO)) {
  13. if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) {
  14. toAddresses.add(address);
  15. alreadyAddedAddresses.add(address);
  16. }
  17. }
  18. for (Address address : message.getRecipients(RecipientType.CC)) {
  19. if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) {
  20. ccAddresses.add(address);
  21. alreadyAddedAddresses.add(address);
  22. }
  23. }
  24. return new ReplyToAddresses(toAddresses, ccAddresses);
  25. }

代码示例来源:origin: k9mail/k-9

  1. public boolean addAutocryptPeerUpdateToIntentIfPresent(Message currentMessage, Intent intent) {
  2. AutocryptHeader autocryptHeader = autocryptHeaderParser.getValidAutocryptHeader(currentMessage);
  3. if (autocryptHeader == null) {
  4. return false;
  5. }
  6. String messageFromAddress = currentMessage.getFrom()[0].getAddress();
  7. if (!autocryptHeader.addr.equalsIgnoreCase(messageFromAddress)) {
  8. return false;
  9. }
  10. Date messageDate = currentMessage.getSentDate();
  11. Date internalDate = currentMessage.getInternalDate();
  12. Date effectiveDate = messageDate.before(internalDate) ? messageDate : internalDate;
  13. AutocryptPeerUpdate data = AutocryptPeerUpdate.create(
  14. autocryptHeader.keyData, effectiveDate, autocryptHeader.isPreferEncryptMutual);
  15. intent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, messageFromAddress);
  16. intent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_UPDATE, data);
  17. return true;
  18. }

代码示例来源:origin: k9mail/k-9

  1. public String generateMessageId(Message message) {
  2. String hostname = null;
  3. Address[] from = message.getFrom();
  4. if (from != null && from.length >= 1) {
  5. hostname = from[0].getHostname();
  6. }
  7. if (hostname == null) {
  8. Address[] replyTo = message.getReplyTo();
  9. if (replyTo != null && replyTo.length >= 1) {
  10. hostname = replyTo[0].getHostname();
  11. }
  12. }
  13. if (hostname == null) {
  14. hostname = "email.android.com";
  15. }
  16. String uuid = generateUuid();
  17. return "<" + uuid + "@" + hostname + ">";
  18. }

代码示例来源:origin: k9mail/k-9

  1. private String getMessageSender(Account account, Message message) {
  2. boolean isSelf = false;
  3. final Contacts contacts = K9.showContactName() ? Contacts.getInstance(context) : null;
  4. final Address[] fromAddresses = message.getFrom();
  5. if (fromAddresses != null) {
  6. isSelf = account.isAnIdentity(fromAddresses);
  7. if (!isSelf && fromAddresses.length > 0) {
  8. return MessageHelper.toFriendly(fromAddresses[0], contacts).toString();
  9. }
  10. }
  11. if (isSelf) {
  12. // show To: if the message was sent from me
  13. Address[] recipients = message.getRecipients(Message.RecipientType.TO);
  14. if (recipients != null && recipients.length > 0) {
  15. String recipientDisplayName = MessageHelper.toFriendly(recipients[0], contacts).toString();
  16. return resourceProvider.recipientDisplayName(recipientDisplayName);
  17. }
  18. }
  19. return null;
  20. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyTo_should_prefer_from_ifOtherIsIdentity() throws Exception {
  3. when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
  4. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
  5. when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  6. when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
  7. when(account.isAnIdentity(any(Address[].class))).thenReturn(true);
  8. ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
  9. assertArrayEquals(TO_ADDRESSES, result.to);
  10. assertArrayEquals(EMPTY_ADDRESSES, result.cc);
  11. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyAllTo_should_returnFromAndToAndCcRecipients() throws Exception {
  3. when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
  4. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
  5. when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  6. when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
  7. when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
  8. ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
  9. assertArrayEquals(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class), recipientsToReplyAllTo.to);
  10. assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
  11. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyTo_should_return_from_otherwise() throws Exception {
  3. when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
  4. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
  5. when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  6. ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
  7. assertArrayEquals(FROM_ADDRESSES, result.to);
  8. assertArrayEquals(EMPTY_ADDRESSES, result.cc);
  9. verify(account).isAnIdentity(result.to);
  10. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field() throws Exception {
  3. when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
  4. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
  5. when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  6. ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
  7. assertArrayEquals(REPLY_TO_ADDRESSES, result.to);
  8. assertArrayEquals(EMPTY_ADDRESSES, result.cc);
  9. verify(account).isAnIdentity(result.to);
  10. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyTo_should_prefer_listPost_over_from_field() throws Exception {
  3. when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
  4. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
  5. when(message.getFrom()).thenReturn(FROM_ADDRESSES);
  6. ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
  7. assertArrayEquals(LIST_POST_ADDRESSES, result.to);
  8. assertArrayEquals(EMPTY_ADDRESSES, result.cc);
  9. verify(account).isAnIdentity(result.to);
  10. }

代码示例来源:origin: k9mail/k-9

  1. public ReplyToAddresses getRecipientsToReplyTo(Message message, Account account) {
  2. Address[] candidateAddress;
  3. Address[] replyToAddresses = message.getReplyTo();
  4. Address[] listPostAddresses = ListHeaders.getListPostAddresses(message);
  5. Address[] fromAddresses = message.getFrom();
  6. if (replyToAddresses.length > 0) {
  7. candidateAddress = replyToAddresses;
  8. } else if (listPostAddresses.length > 0) {
  9. candidateAddress = listPostAddresses;
  10. } else {
  11. candidateAddress = fromAddresses;
  12. }
  13. boolean replyToAddressIsUserIdentity = account.isAnIdentity(candidateAddress);
  14. if (replyToAddressIsUserIdentity) {
  15. candidateAddress = message.getRecipients(RecipientType.TO);
  16. }
  17. return new ReplyToAddresses(candidateAddress);
  18. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyAllTo_should_excludeIdentityAddresses() throws Exception {
  3. when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
  4. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
  5. when(message.getFrom()).thenReturn(EMPTY_ADDRESSES);
  6. when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
  7. when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
  8. Address excludedCcAddress = CC_ADDRESSES[1];
  9. Address excludedToAddress = TO_ADDRESSES[0];
  10. when(account.isAnIdentity(eq(excludedToAddress))).thenReturn(true);
  11. when(account.isAnIdentity(eq(excludedCcAddress))).thenReturn(true);
  12. ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
  13. assertArrayEquals(arrayExcept(TO_ADDRESSES, excludedToAddress), recipientsToReplyAllTo.to);
  14. assertArrayEquals(arrayExcept(CC_ADDRESSES, excludedCcAddress), recipientsToReplyAllTo.cc);
  15. }

代码示例来源:origin: k9mail/k-9

  1. @Test
  2. public void getRecipientsToReplyAllTo_should_excludeDuplicates() throws Exception {
  3. when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
  4. when(message.getFrom()).thenReturn(arrayConcatenate(FROM_ADDRESSES, REPLY_TO_ADDRESSES, Address.class));
  5. when(message.getRecipients(RecipientType.TO)).thenReturn(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class));
  6. when(message.getRecipients(RecipientType.CC)).thenReturn(arrayConcatenate(CC_ADDRESSES, TO_ADDRESSES, Address.class));
  7. when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
  8. ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
  9. assertArrayContainsAll(REPLY_TO_ADDRESSES, recipientsToReplyAllTo.to);
  10. assertArrayContainsAll(FROM_ADDRESSES, recipientsToReplyAllTo.to);
  11. assertArrayContainsAll(TO_ADDRESSES, recipientsToReplyAllTo.to);
  12. int totalExpectedAddresses = REPLY_TO_ADDRESSES.length + FROM_ADDRESSES.length + TO_ADDRESSES.length;
  13. assertEquals(totalExpectedAddresses, recipientsToReplyAllTo.to.length);
  14. assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
  15. }

代码示例来源:origin: k9mail/k-9

  1. String mailFrom = constructSmtpMailFromCommand(message.getFrom(), is8bitEncodingAllowed);

代码示例来源:origin: k9mail/k-9

  1. Address[] from = message.getFrom();
  2. if (from != null && from.length > 0) {
  3. addTableRow(html, resourceProvider.messageHeaderFrom(),

相关文章