Search in sources :

Example 1 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class MessageListAdapter method getPreview.

private String getPreview(Cursor cursor) {
    String previewTypeString = cursor.getString(PREVIEW_TYPE_COLUMN);
    DatabasePreviewType previewType = DatabasePreviewType.fromDatabaseValue(previewTypeString);
    switch(previewType) {
        case NONE:
        case ERROR:
            {
                return "";
            }
        case ENCRYPTED:
            {
                return fragment.getString(R.string.preview_encrypted);
            }
        case TEXT:
            {
                return cursor.getString(PREVIEW_COLUMN);
            }
    }
    throw new AssertionError("Unknown preview type: " + previewType);
}
Also used : DatabasePreviewType(com.fsck.k9.mailstore.DatabasePreviewType)

Example 2 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class MessageListAdapter method newView.

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    View view = fragment.getLayoutInflater().inflate(R.layout.message_list_item, parent, false);
    MessageViewHolder holder = new MessageViewHolder(fragment);
    holder.date = (TextView) view.findViewById(R.id.date);
    holder.chip = view.findViewById(R.id.chip);
    if (fragment.previewLines == 0 && fragment.contactsPictureLoader == null) {
        view.findViewById(R.id.preview).setVisibility(View.GONE);
        holder.preview = (TextView) view.findViewById(R.id.sender_compact);
        holder.flagged = (CheckBox) view.findViewById(R.id.flagged_center_right);
        view.findViewById(R.id.flagged_bottom_right).setVisibility(View.GONE);
    } else {
        view.findViewById(R.id.sender_compact).setVisibility(View.GONE);
        holder.preview = (TextView) view.findViewById(R.id.preview);
        holder.flagged = (CheckBox) view.findViewById(R.id.flagged_bottom_right);
        view.findViewById(R.id.flagged_center_right).setVisibility(View.GONE);
    }
    ContactBadge contactBadge = (ContactBadge) view.findViewById(R.id.contact_badge);
    if (fragment.contactsPictureLoader != null) {
        holder.contactBadge = contactBadge;
    } else {
        contactBadge.setVisibility(View.GONE);
    }
    if (fragment.senderAboveSubject) {
        holder.from = (TextView) view.findViewById(R.id.subject);
        fontSizes.setViewTextSize(holder.from, fontSizes.getMessageListSender());
    } else {
        holder.subject = (TextView) view.findViewById(R.id.subject);
        fontSizes.setViewTextSize(holder.subject, fontSizes.getMessageListSubject());
    }
    fontSizes.setViewTextSize(holder.date, fontSizes.getMessageListDate());
    // 1 preview line is needed even if it is set to 0, because subject is part of the same text view
    holder.preview.setLines(Math.max(fragment.previewLines, 1));
    fontSizes.setViewTextSize(holder.preview, fontSizes.getMessageListPreview());
    holder.threadCount = (TextView) view.findViewById(R.id.thread_count);
    // thread count is next to subject
    fontSizes.setViewTextSize(holder.threadCount, fontSizes.getMessageListSubject());
    view.findViewById(R.id.selected_checkbox_wrapper).setVisibility((fragment.checkboxes) ? View.VISIBLE : View.GONE);
    holder.flagged.setVisibility(fragment.stars ? View.VISIBLE : View.GONE);
    holder.flagged.setOnClickListener(holder);
    holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);
    holder.selected.setOnClickListener(holder);
    view.setTag(holder);
    return view;
}
Also used : ContactBadge(com.fsck.k9.ui.ContactBadge) View(android.view.View) TextView(android.widget.TextView)

Example 3 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubEncryptedAndText__shouldReturnEncrypted.

@Test
public void findEncrypted__withMultipartMixedSubEncryptedAndText__shouldReturnEncrypted() throws Exception {
    Message message = messageFromBody(multipart("mixed", multipart("encrypted", bodypart("application/pgp-encrypted"), bodypart("application/octet-stream")), bodypart("text/plain")));
    List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
    assertEquals(1, encryptedParts.size());
    assertSame(getPart(message, 0), encryptedParts.get(0));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Example 4 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findPrimaryCryptoPart_withMultipartMixedContainingMultipartAlternativeContainingPgpInline.

@Test
public void findPrimaryCryptoPart_withMultipartMixedContainingMultipartAlternativeContainingPgpInline() throws Exception {
    List<Part> outputExtraParts = new ArrayList<>();
    BodyPart pgpInlinePart = bodypart("text/plain", PGP_INLINE_DATA);
    Message message = messageFromBody(multipart("mixed", multipart("alternative", pgpInlinePart, bodypart("text/html")), bodypart("application/octet-stream")));
    Part cryptoPart = MessageDecryptVerifier.findPrimaryEncryptedOrSignedPart(message, outputExtraParts);
    assertSame(pgpInlinePart, cryptoPart);
}
Also used : BodyPart(com.fsck.k9.mail.BodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class MessageDecryptVerifierTest method findEncrypted__withMultipartMixedSubTextAndSigned__shouldReturnSigned.

@Test
public void findEncrypted__withMultipartMixedSubTextAndSigned__shouldReturnSigned() throws Exception {
    Message message = messageFromBody(multipart("mixed", bodypart("text/plain"), multipart("signed", bodypart("text/plain"), bodypart("application/pgp-signature"))));
    List<Part> signedParts = MessageDecryptVerifier.findSignedParts(message, messageCryptoAnnotations);
    assertEquals(1, signedParts.size());
    assertSame(getPart(message, 1), signedParts.get(0));
}
Also used : MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)74 Part (com.fsck.k9.mail.Part)64 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)37 BodyPart (com.fsck.k9.mail.BodyPart)34 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)33 MessageCreationHelper.createTextPart (com.fsck.k9.message.MessageCreationHelper.createTextPart)27 Message (com.fsck.k9.mail.Message)22 TextBody (com.fsck.k9.mail.internet.TextBody)18 MessageCreationHelper.createEmptyPart (com.fsck.k9.message.MessageCreationHelper.createEmptyPart)16 ArrayList (java.util.ArrayList)16 Body (com.fsck.k9.mail.Body)13 MessagingException (com.fsck.k9.mail.MessagingException)13 MessageCreationHelper.createPart (com.fsck.k9.message.MessageCreationHelper.createPart)13 Multipart (com.fsck.k9.mail.Multipart)10 Viewable (com.fsck.k9.mail.internet.Viewable)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)8 Intent (android.content.Intent)6 BinaryMemoryBody (com.fsck.k9.mailstore.BinaryMemoryBody)6 ViewableExtractedText (com.fsck.k9.mailstore.MessageViewInfoExtractor.ViewableExtractedText)6