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);
}
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;
}
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));
}
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);
}
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));
}
Aggregations