com.fsck.k9.mail.Address类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(217)

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

Address介绍

暂无

代码示例

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

  1. public Recipient(String name, String email, String addressLabel, long contactId, String lookupKey,
  2. int timesContacted, String sortKey) {
  3. this.address = new Address(email, name);
  4. this.contactId = contactId;
  5. this.addressLabel = addressLabel;
  6. this.cryptoStatus = RecipientCryptoStatus.UNDEFINED;
  7. this.contactLookupKey = lookupKey;
  8. this.timesContacted = timesContacted;
  9. this.sortKey = sortKey;
  10. }

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

  1. @Test
  2. public void parse_withQuotedEncodedPersonal_shouldDecode() {
  3. Address[] addresses = Address.parse(
  4. "\"=?UTF-8?B?WWFob28h44OA44Kk44Os44Kv44OI44Kq44OV44Kh44O8?= \"<directoffer-master@mail.yahoo.co.jp>");
  5. assertEquals("Yahoo!ダイレクトオファー ", addresses[0].getPersonal());
  6. assertEquals("directoffer-master@mail.yahoo.co.jp", addresses[0].getAddress());
  7. }

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

  1. @NonNull
  2. private Bundle prepareIntentExtras(Recipient recipient) {
  3. Address address = recipient.address;
  4. Bundle extras = new Bundle();
  5. extras.putStringArray(Intent.EXTRA_EMAIL, new String[] { address.toString() });
  6. extras.putStringArray(Intent.EXTRA_CC, new String[0]);
  7. extras.putStringArray(Intent.EXTRA_BCC, new String[0]);
  8. return extras;
  9. }

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

  1. /**
  2. * Assign the contact to the badge.
  3. *
  4. * On 4.3, we pass the address name as extra info so that if the contact doesn't exist
  5. * the name is auto-populated.
  6. *
  7. * @param address the address to look for a contact for.
  8. */
  9. public void setContact(Address address) {
  10. Bundle extraContactInfo = new Bundle();
  11. extraContactInfo.putString(ContactsContract.Intents.Insert.NAME, address.getPersonal());
  12. assignContactFromEmail(address.getAddress(), true, extraContactInfo);
  13. }

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

  1. /**
  2. * Start the activity to add information to an existing contact or add a
  3. * new one.
  4. *
  5. * @param email An {@link Address} instance containing the email address
  6. * of the entity you want to add to the contacts. Optionally
  7. * the instance also contains the (display) name of that
  8. * entity.
  9. */
  10. public void createContact(final Address email) {
  11. final Uri contactUri = Uri.fromParts("mailto", email.getAddress(), null);
  12. final Intent contactIntent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
  13. contactIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  14. contactIntent.setData(contactUri);
  15. // Pass along full email string for possible create dialog
  16. contactIntent.putExtra(ContactsContract.Intents.EXTRA_CREATE_DESCRIPTION,
  17. email.toString());
  18. // Only provide personal name hint if we have one
  19. final String senderPersonal = email.getPersonal();
  20. if (senderPersonal != null) {
  21. contactIntent.putExtra(ContactsContract.Intents.Insert.NAME, senderPersonal);
  22. }
  23. mContext.startActivity(contactIntent);
  24. clearCache();
  25. }

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

  1. @Test
  2. public void equals_withoutPersonal_doesNotMatchWithAddress() throws Exception {
  3. Address address = Address.parse("alice@example.org")[0];
  4. Address address2 = Address.parse("Alice <alice@example.org>")[0];
  5. boolean result = address.equals(address2);
  6. assertFalse(result);
  7. }

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

  1. private void fillContactDataFromAddresses(Address[] addresses, List<Recipient> recipients,
  2. Map<String, Recipient> recipientMap) {
  3. for (Address address : addresses) {
  4. // TODO actually query contacts - not sure if this is possible in a single query tho :(
  5. Recipient recipient = new Recipient(address);
  6. recipients.add(recipient);
  7. recipientMap.put(address.getAddress(), recipient);
  8. }
  9. }

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

  1. @Override
  2. protected Recipient defaultObject(String completionText) {
  3. Address[] parsedAddresses = Address.parse(completionText);
  4. if (!CharsetUtil.isASCII(completionText)) {
  5. setError(getContext().getString(R.string.recipient_error_non_ascii));
  6. return null;
  7. }
  8. if (parsedAddresses.length == 0 || parsedAddresses[0].getAddress() == null) {
  9. setError(getContext().getString(R.string.recipient_error_parse_failed));
  10. return null;
  11. }
  12. return new Recipient(parsedAddresses[0]);
  13. }

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

  1. private static Address[] toAddressArray(List<String> recipients) {
  2. if (recipients.isEmpty()) {
  3. return EMPTY_ADDRESS_LIST;
  4. }
  5. String addressList = toCommaSeparatedString(recipients);
  6. return Address.parse(addressList);
  7. }

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

  1. @Test
  2. public void generateMessageId_withFromAndReplyToAddress() throws Exception {
  3. Message message = new MimeMessage();
  4. message.setFrom(new Address("alice@example.org"));
  5. message.setReplyTo(Address.parse("bob@example.com"));
  6. String result = messageIdGenerator.generateMessageId(message);
  7. assertEquals("<00000000-0000-4000-0000-000000000000@example.org>", result);
  8. }

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

  1. @Test
  2. public void equals_withoutPersonal_matchesSame() throws Exception {
  3. Address address = Address.parse("alice@example.org")[0];
  4. Address address2 = Address.parse("alice@example.org")[0];
  5. assertNull(address.getPersonal());
  6. boolean result = address.equals(address2);
  7. assertTrue(result);
  8. }

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

  1. @Test
  2. public void hashCode_withoutPersonal() throws Exception {
  3. Address address = Address.parse("alice@example.org")[0];
  4. assertNull(address.getPersonal());
  5. address.hashCode();
  6. }

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

  1. private void buildHeader(MimeMessage message) throws MessagingException {
  2. message.addSentDate(sentDate, hideTimeZone);
  3. Address from = new Address(identity.getEmail(), identity.getName());
  4. message.setFrom(from);
  5. message.setRecipients(RecipientType.TO, to);
  6. message.setHeader("Disposition-Notification-To", from.toEncodedString());
  7. message.setHeader("X-Confirm-Reading-To", from.toEncodedString());
  8. message.setHeader("Return-Receipt-To", from.toEncodedString());
  9. message.setReplyTo(new Address[] { new Address(replyTo) });

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

  1. public static String toEncodedString(Address[] addresses) {
  2. if (addresses == null) {
  3. return null;
  4. }
  5. StringBuilder sb = new StringBuilder();
  6. for (int i = 0; i < addresses.length; i++) {
  7. sb.append(addresses[i].toEncodedString());
  8. if (i < addresses.length - 1) {
  9. sb.append(',');
  10. }
  11. }
  12. return sb.toString();
  13. }

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

  1. private String getDisplayName() {
  2. if (TextUtils.isEmpty(address.getPersonal())) {
  3. return null;
  4. }
  5. String displayName = address.getPersonal();
  6. if (addressLabel != null) {
  7. displayName += " (" + addressLabel + ")";
  8. }
  9. return displayName;
  10. }

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

  1. @Override
  2. public boolean equals(Object o) {
  3. // Equality is entirely up to the address
  4. return o instanceof Recipient && address.equals(((Recipient) o).address);
  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. /* package, for testing */ static CharSequence toFriendly(Address address, Contacts contacts,
  2. boolean showCorrespondentNames,
  3. boolean changeContactNameColor,
  4. int contactNameColor) {
  5. if (!showCorrespondentNames) {
  6. return address.getAddress();
  7. } else if (contacts != null) {
  8. final String name = contacts.getNameForAddress(address.getAddress());
  9. if (name != null) {
  10. if (changeContactNameColor) {
  11. final SpannableString coloredName = new SpannableString(name);
  12. coloredName.setSpan(new ForegroundColorSpan(contactNameColor),
  13. 0,
  14. coloredName.length(),
  15. Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
  16. );
  17. return coloredName;
  18. } else {
  19. return name;
  20. }
  21. }
  22. }
  23. if (!TextUtils.isEmpty(address.getPersonal()) && !isSpoofAddress(address.getPersonal())) {
  24. return address.getPersonal();
  25. } else {
  26. return address.getAddress();
  27. }
  28. }

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

  1. @Test
  2. public void handlesInvalidBase64Encoding() throws Exception {
  3. Address address = Address.parse("=?utf-8?b?invalid#?= <oops@example.com>")[0];
  4. assertEquals("oops@example.com", address.getAddress());
  5. }
  6. }

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

  1. public void initFromTrustIdAction(String trustId) {
  2. addToAddresses(Address.parse(trustId));
  3. currentCryptoMode = CryptoMode.CHOICE_ENABLED;
  4. }

相关文章