Search in sources :

Example 36 with Address

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());
}
Also used : Address(com.fsck.k9.mail.Address) RobolectricTest(com.fsck.k9.RobolectricTest) Test(org.junit.Test)

Example 37 with Address

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());
}
Also used : Address(com.fsck.k9.mail.Address) RobolectricTest(com.fsck.k9.RobolectricTest) Test(org.junit.Test)

Example 38 with Address

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));
}
Also used : Address(com.fsck.k9.mail.Address) RobolectricTest(com.fsck.k9.RobolectricTest) Test(org.junit.Test)

Example 39 with Address

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));
}
Also used : Address(com.fsck.k9.mail.Address) RobolectricTest(com.fsck.k9.RobolectricTest) Test(org.junit.Test)

Example 40 with Address

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)));
}
Also used : Address(com.fsck.k9.mail.Address) Part(com.fsck.k9.mail.Part) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint)

Aggregations

Address (com.fsck.k9.mail.Address)72 Test (org.junit.Test)40 Uri (android.net.Uri)13 RobolectricTest (com.fsck.k9.RobolectricTest)12 Message (com.fsck.k9.mail.Message)10 Date (java.util.Date)8 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)7 ArrayList (java.util.ArrayList)7 MessagingException (com.fsck.k9.mail.MessagingException)6 Contacts (com.fsck.k9.helper.Contacts)5 Recipient (com.fsck.k9.view.RecipientSelectView.Recipient)5 AddressStyle (com.zegoggles.smssync.preferences.AddressStyle)5 IOException (java.io.IOException)5 Intent (android.content.Intent)4 Cursor (android.database.Cursor)4 MatrixCursor (android.database.MatrixCursor)4 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)4 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)4 TextBody (com.fsck.k9.mail.internet.TextBody)4 SpannableString (android.text.SpannableString)3