use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageHelperTest method toFriendly_atPrecededByOpeningParenthesisShouldNotTriggerSpoofPrevention.
@Test
public void toFriendly_atPrecededByOpeningParenthesisShouldNotTriggerSpoofPrevention() {
Address address = new Address("gitlab@gitlab.example", "username (@username)");
CharSequence friendly = MessageHelper.toFriendly(address, contacts);
assertEquals("username (@username)", friendly.toString());
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageHelperTest method testToFriendlyWithContactLookup.
@Test
public void testToFriendlyWithContactLookup() throws Exception {
Address address = new Address("test@testor.com");
assertEquals("Tim Testor", MessageHelper.toFriendly(address, contactsWithFakeContact).toString());
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageHelperTest method testToFriendlyShowsPersonalPartIfItExists.
@Test
public void testToFriendlyShowsPersonalPartIfItExists() throws Exception {
Address address = new Address("test@testor.com", "Tim Testor");
assertEquals("Tim Testor", MessageHelper.toFriendly(address, contacts));
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessageHelperTest method testToFriendlyShowsEmailPartIfNoPersonalPartExists.
@Test
public void testToFriendlyShowsEmailPartIfNoPersonalPartExists() throws Exception {
Address address = new Address("test@testor.com");
assertEquals("test@testor.com", MessageHelper.toFriendly(address, contacts));
}
use of com.fsck.k9.mail.Address in project k-9 by k9mail.
the class MessagingController method sendAlternate.
public void sendAlternate(Context context, Account account, LocalMessage message) {
Timber.d("Got message %s:%s:%s for sendAlternate", account.getDescription(), message.getFolder(), message.getUid());
Intent msg = new Intent(Intent.ACTION_SEND);
String quotedText = null;
Part part = MimeUtility.findFirstPartByMimeType(message, "text/plain");
if (part == null) {
part = MimeUtility.findFirstPartByMimeType(message, "text/html");
}
if (part != null) {
quotedText = MessageExtractor.getTextFromPart(part);
}
if (quotedText != null) {
msg.putExtra(Intent.EXTRA_TEXT, quotedText);
}
msg.putExtra(Intent.EXTRA_SUBJECT, message.getSubject());
Address[] from = message.getFrom();
String[] senders = new String[from.length];
for (int i = 0; i < from.length; i++) {
senders[i] = from[i].toString();
}
msg.putExtra(Intents.Share.EXTRA_FROM, senders);
Address[] to = message.getRecipients(RecipientType.TO);
String[] recipientsTo = new String[to.length];
for (int i = 0; i < to.length; i++) {
recipientsTo[i] = to[i].toString();
}
msg.putExtra(Intent.EXTRA_EMAIL, recipientsTo);
Address[] cc = message.getRecipients(RecipientType.CC);
String[] recipientsCc = new String[cc.length];
for (int i = 0; i < cc.length; i++) {
recipientsCc[i] = cc[i].toString();
}
msg.putExtra(Intent.EXTRA_CC, recipientsCc);
msg.setType("text/plain");
context.startActivity(Intent.createChooser(msg, context.getString(R.string.send_alternate_chooser_title)));
}
Aggregations