本文整理了Java中com.fsck.k9.mail.Address
类的一些代码示例,展示了Address
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address
类的具体详情如下:
包路径:com.fsck.k9.mail.Address
类名称:Address
暂无
代码示例来源:origin: k9mail/k-9
public Recipient(String name, String email, String addressLabel, long contactId, String lookupKey,
int timesContacted, String sortKey) {
this.address = new Address(email, name);
this.contactId = contactId;
this.addressLabel = addressLabel;
this.cryptoStatus = RecipientCryptoStatus.UNDEFINED;
this.contactLookupKey = lookupKey;
this.timesContacted = timesContacted;
this.sortKey = sortKey;
}
代码示例来源:origin: k9mail/k-9
@Test
public void parse_withQuotedEncodedPersonal_shouldDecode() {
Address[] addresses = Address.parse(
"\"=?UTF-8?B?WWFob28h44OA44Kk44Os44Kv44OI44Kq44OV44Kh44O8?= \"<directoffer-master@mail.yahoo.co.jp>");
assertEquals("Yahoo!ダイレクトオファー ", addresses[0].getPersonal());
assertEquals("directoffer-master@mail.yahoo.co.jp", addresses[0].getAddress());
}
代码示例来源:origin: k9mail/k-9
@NonNull
private Bundle prepareIntentExtras(Recipient recipient) {
Address address = recipient.address;
Bundle extras = new Bundle();
extras.putStringArray(Intent.EXTRA_EMAIL, new String[] { address.toString() });
extras.putStringArray(Intent.EXTRA_CC, new String[0]);
extras.putStringArray(Intent.EXTRA_BCC, new String[0]);
return extras;
}
代码示例来源:origin: k9mail/k-9
/**
* Assign the contact to the badge.
*
* On 4.3, we pass the address name as extra info so that if the contact doesn't exist
* the name is auto-populated.
*
* @param address the address to look for a contact for.
*/
public void setContact(Address address) {
Bundle extraContactInfo = new Bundle();
extraContactInfo.putString(ContactsContract.Intents.Insert.NAME, address.getPersonal());
assignContactFromEmail(address.getAddress(), true, extraContactInfo);
}
代码示例来源:origin: k9mail/k-9
/**
* Start the activity to add information to an existing contact or add a
* new one.
*
* @param email An {@link Address} instance containing the email address
* of the entity you want to add to the contacts. Optionally
* the instance also contains the (display) name of that
* entity.
*/
public void createContact(final Address email) {
final Uri contactUri = Uri.fromParts("mailto", email.getAddress(), null);
final Intent contactIntent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
contactIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
contactIntent.setData(contactUri);
// Pass along full email string for possible create dialog
contactIntent.putExtra(ContactsContract.Intents.EXTRA_CREATE_DESCRIPTION,
email.toString());
// Only provide personal name hint if we have one
final String senderPersonal = email.getPersonal();
if (senderPersonal != null) {
contactIntent.putExtra(ContactsContract.Intents.Insert.NAME, senderPersonal);
}
mContext.startActivity(contactIntent);
clearCache();
}
代码示例来源:origin: k9mail/k-9
@Test
public void equals_withoutPersonal_doesNotMatchWithAddress() throws Exception {
Address address = Address.parse("alice@example.org")[0];
Address address2 = Address.parse("Alice <alice@example.org>")[0];
boolean result = address.equals(address2);
assertFalse(result);
}
代码示例来源:origin: k9mail/k-9
private void fillContactDataFromAddresses(Address[] addresses, List<Recipient> recipients,
Map<String, Recipient> recipientMap) {
for (Address address : addresses) {
// TODO actually query contacts - not sure if this is possible in a single query tho :(
Recipient recipient = new Recipient(address);
recipients.add(recipient);
recipientMap.put(address.getAddress(), recipient);
}
}
代码示例来源:origin: k9mail/k-9
@Override
protected Recipient defaultObject(String completionText) {
Address[] parsedAddresses = Address.parse(completionText);
if (!CharsetUtil.isASCII(completionText)) {
setError(getContext().getString(R.string.recipient_error_non_ascii));
return null;
}
if (parsedAddresses.length == 0 || parsedAddresses[0].getAddress() == null) {
setError(getContext().getString(R.string.recipient_error_parse_failed));
return null;
}
return new Recipient(parsedAddresses[0]);
}
代码示例来源:origin: k9mail/k-9
private static Address[] toAddressArray(List<String> recipients) {
if (recipients.isEmpty()) {
return EMPTY_ADDRESS_LIST;
}
String addressList = toCommaSeparatedString(recipients);
return Address.parse(addressList);
}
代码示例来源:origin: k9mail/k-9
@Test
public void generateMessageId_withFromAndReplyToAddress() throws Exception {
Message message = new MimeMessage();
message.setFrom(new Address("alice@example.org"));
message.setReplyTo(Address.parse("bob@example.com"));
String result = messageIdGenerator.generateMessageId(message);
assertEquals("<00000000-0000-4000-0000-000000000000@example.org>", result);
}
代码示例来源:origin: k9mail/k-9
@Test
public void equals_withoutPersonal_matchesSame() throws Exception {
Address address = Address.parse("alice@example.org")[0];
Address address2 = Address.parse("alice@example.org")[0];
assertNull(address.getPersonal());
boolean result = address.equals(address2);
assertTrue(result);
}
代码示例来源:origin: k9mail/k-9
@Test
public void hashCode_withoutPersonal() throws Exception {
Address address = Address.parse("alice@example.org")[0];
assertNull(address.getPersonal());
address.hashCode();
}
代码示例来源:origin: k9mail/k-9
private void buildHeader(MimeMessage message) throws MessagingException {
message.addSentDate(sentDate, hideTimeZone);
Address from = new Address(identity.getEmail(), identity.getName());
message.setFrom(from);
message.setRecipients(RecipientType.TO, to);
message.setHeader("Disposition-Notification-To", from.toEncodedString());
message.setHeader("X-Confirm-Reading-To", from.toEncodedString());
message.setHeader("Return-Receipt-To", from.toEncodedString());
message.setReplyTo(new Address[] { new Address(replyTo) });
代码示例来源:origin: k9mail/k-9
public static String toEncodedString(Address[] addresses) {
if (addresses == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < addresses.length; i++) {
sb.append(addresses[i].toEncodedString());
if (i < addresses.length - 1) {
sb.append(',');
}
}
return sb.toString();
}
代码示例来源:origin: k9mail/k-9
private String getDisplayName() {
if (TextUtils.isEmpty(address.getPersonal())) {
return null;
}
String displayName = address.getPersonal();
if (addressLabel != null) {
displayName += " (" + addressLabel + ")";
}
return displayName;
}
代码示例来源:origin: k9mail/k-9
@Override
public boolean equals(Object o) {
// Equality is entirely up to the address
return o instanceof Recipient && address.equals(((Recipient) o).address);
}
代码示例来源: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
/* package, for testing */ static CharSequence toFriendly(Address address, Contacts contacts,
boolean showCorrespondentNames,
boolean changeContactNameColor,
int contactNameColor) {
if (!showCorrespondentNames) {
return address.getAddress();
} else if (contacts != null) {
final String name = contacts.getNameForAddress(address.getAddress());
if (name != null) {
if (changeContactNameColor) {
final SpannableString coloredName = new SpannableString(name);
coloredName.setSpan(new ForegroundColorSpan(contactNameColor),
0,
coloredName.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
);
return coloredName;
} else {
return name;
}
}
}
if (!TextUtils.isEmpty(address.getPersonal()) && !isSpoofAddress(address.getPersonal())) {
return address.getPersonal();
} else {
return address.getAddress();
}
}
代码示例来源:origin: k9mail/k-9
@Test
public void handlesInvalidBase64Encoding() throws Exception {
Address address = Address.parse("=?utf-8?b?invalid#?= <oops@example.com>")[0];
assertEquals("oops@example.com", address.getAddress());
}
}
代码示例来源:origin: k9mail/k-9
public void initFromTrustIdAction(String trustId) {
addToAddresses(Address.parse(trustId));
currentCryptoMode = CryptoMode.CHOICE_ENABLED;
}
内容来源于网络,如有侵权,请联系作者删除!