本文整理了Java中com.fsck.k9.mail.Address.getPersonal()
方法的一些代码示例,展示了Address.getPersonal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getPersonal()
方法的具体详情如下:
包路径:com.fsck.k9.mail.Address
类名称:Address
方法名:getPersonal
暂无
代码示例来源: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
public String getNameOrUnknown(Context context) {
String name = address.getPersonal();
if (name != null) {
return name;
}
return context.getString(R.string.unknown_recipient);
}
代码示例来源: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
/**
* Packs an address list into a String that is very quick to read
* and parse. Packed lists can be unpacked with unpackAddressList()
* The packed list is a ",\u0000" separated list of:
* address;\u0000personal
* @param addresses Array of addresses to pack.
* @return Packed addresses.
*/
public static String pack(Address[] addresses) {
if (addresses == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0, count = addresses.length; i < count; i++) {
Address address = addresses[i];
sb.append(address.getAddress());
String personal = address.getPersonal();
if (personal != null) {
sb.append(";\u0000");
// Escape quotes in the address part on the way in
personal = personal.replaceAll("\"", "\\\"");
sb.append(personal);
}
if (i < count - 1) {
sb.append(",\u0000");
}
}
return sb.toString();
}
代码示例来源: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
/* 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 hashCode_withoutPersonal() throws Exception {
Address address = Address.parse("alice@example.org")[0];
assertNull(address.getPersonal());
address.hashCode();
}
代码示例来源:origin: k9mail/k-9
/**
* test with multi email addresses
*/
@Test
public void parse_withMultipleEmails_shouldDecodeBoth() {
Address[] addresses = Address.parse("lorem@ipsum.us,mark@twain.com");
assertEquals(2, addresses.length);
assertEquals("lorem@ipsum.us", addresses[0].getAddress());
assertEquals(null, addresses[0].getPersonal());
assertEquals("mark@twain.com", addresses[1].getAddress());
assertEquals(null, addresses[1].getPersonal());
}
代码示例来源: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
@Test
public void parse_withEncodedPersonal_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
private Identity createIdentity() {
Identity identity = new Identity();
identity.setName(TEST_IDENTITY_ADDRESS.getPersonal());
identity.setEmail(TEST_IDENTITY_ADDRESS.getAddress());
identity.setDescription("test identity");
identity.setSignatureUse(false);
return identity;
}
}
代码示例来源:origin: k9mail/k-9
/**
* test name + valid email
*/
@Test
public void parse_withValidEmailAndPersonal_shouldSetBoth() {
Address[] addresses = Address.parse("Max Mustermann <maxmuster@mann.com>");
assertEquals(1, addresses.length);
assertEquals("maxmuster@mann.com", addresses[0].getAddress());
assertEquals("Max Mustermann", addresses[0].getPersonal());
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!