From 27d5a8f30f426a6125d0e7655473effa05ab8a02 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 29 Oct 2019 13:21:34 +0100 Subject: [PATCH] Simplified raw message file viewer --- .../java/eu/faircode/email/ActivityEML.java | 38 ++--- app/src/main/res/layout/activity_eml.xml | 138 +++++------------- app/src/main/res/values/strings.xml | 2 + 3 files changed, 47 insertions(+), 131 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityEML.java b/app/src/main/java/eu/faircode/email/ActivityEML.java index e12a09bbf9..5c10d3c16d 100644 --- a/app/src/main/java/eu/faircode/email/ActivityEML.java +++ b/app/src/main/java/eu/faircode/email/ActivityEML.java @@ -44,12 +44,14 @@ import com.sun.mail.imap.IMAPFolder; import java.io.InputStream; import java.util.List; +import java.util.Locale; import java.util.Properties; import javax.mail.Flags; import javax.mail.Folder; import javax.mail.Message; import javax.mail.Session; +import javax.mail.internet.ContentType; import javax.mail.internet.MimeMessage; public class ActivityEML extends ActivityBase { @@ -64,13 +66,9 @@ public class ActivityEML extends ActivityBase { final TextView tvTo = findViewById(R.id.tvTo); final TextView tvFrom = findViewById(R.id.tvFrom); - final TextView tvReplyTo = findViewById(R.id.tvReplyTo); - final TextView tvCc = findViewById(R.id.tvCc); final TextView tvSubject = findViewById(R.id.tvSubject); - final TextView tvHeaders = findViewById(R.id.tvHeaders); - final TextView tvParts = findViewById(R.id.tvParts); + final TextView tvAttachments = findViewById(R.id.tvAttachments); final TextView tvBody = findViewById(R.id.tvBody); - final TextView tvHtml = findViewById(R.id.tvHtml); final ContentLoadingProgressBar pbWait = findViewById(R.id.pbWait); final Group grpReady = findViewById(R.id.grpReady); @@ -118,10 +116,7 @@ public class ActivityEML extends ActivityBase { result.from = MessageHelper.formatAddresses(helper.getFrom()); result.to = MessageHelper.formatAddresses(helper.getTo()); - result.replyto = MessageHelper.formatAddresses(helper.getReply()); - result.cc = MessageHelper.formatAddresses(helper.getCc()); result.subject = helper.getSubject(); - result.headers = HtmlHelper.highlightHeaders(context, helper.getHeaders()); MessageHelper.MessageParts parts = helper.getMessageParts(); @@ -129,20 +124,18 @@ public class ActivityEML extends ActivityBase { for (MessageHelper.AttachmentPart apart : parts.getAttachmentParts()) { if (sb.length() > 0) sb.append("
"); - sb.append(apart.part.getContentType()); + ContentType ct = new ContentType(apart.part.getContentType()); + sb.append(ct.getBaseType().toLowerCase(Locale.ROOT)); if (apart.disposition != null) sb.append(' ').append(apart.disposition); if (apart.filename != null) sb.append(' ').append(apart.filename); } - result.parts = HtmlHelper.fromHtml(sb.toString()); + result.attachments = HtmlHelper.fromHtml(sb.toString()); - result.html = parts.getHtml(context); - if (result.html != null) { - result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, result.html, false)); - if (result.html.length() > 100 * 1024) - result.html = null; - } + String html = parts.getHtml(context); + if (html != null) + result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, html, false)); return result; } @@ -152,13 +145,9 @@ public class ActivityEML extends ActivityBase { protected void onExecuted(Bundle args, Result result) { tvFrom.setText(result.from); tvTo.setText(result.to); - tvReplyTo.setText(result.replyto); - tvCc.setText(result.cc); tvSubject.setText(result.subject); - tvHeaders.setText(result.headers); - tvParts.setText(result.parts); + tvAttachments.setText(result.attachments); tvBody.setText(result.body); - tvHtml.setText(result.html); grpReady.setVisibility(View.VISIBLE); } @@ -205,6 +194,7 @@ public class ActivityEML extends ActivityBase { adapter.addAll(accounts); new AlertDialog.Builder(ActivityEML.this) + .setTitle(R.string.title_save_eml) .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -289,12 +279,8 @@ public class ActivityEML extends ActivityBase { private class Result { String from; String to; - String replyto; - String cc; String subject; - Spanned headers; - Spanned parts; + Spanned attachments; Spanned body; - String html; } } diff --git a/app/src/main/res/layout/activity_eml.xml b/app/src/main/res/layout/activity_eml.xml index fbf45eff4d..61737ce717 100644 --- a/app/src/main/res/layout/activity_eml.xml +++ b/app/src/main/res/layout/activity_eml.xml @@ -16,6 +16,27 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> + + + + + app:layout_constraintTop_toBottomOf="@id/vSeparatorHeader" /> + app:layout_constraintTop_toBottomOf="@id/vSeparatorHeader" /> - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/tvTo" /> - - - - + app:layout_constraintTop_toBottomOf="@id/vSeparatorAttachments" /> + app:layout_constraintTop_toBottomOf="@id/tvAttachments" /> - - - - + vSeparatorAttachments,tvAttachments, + vSeparatorBody,tvBody" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f4962ea9da..fbbf8b0c45 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -552,6 +552,7 @@ Show inline attachments Download all Save all + Save raw message file Trash Copy … @@ -865,6 +866,7 @@ Long press a message to start selecting multiple messages; Hold and swipe up or down to select more messages Downloading messages can take some time, depending on the speed of the provider, internet connection and device and on the number of messages. While downloading messages the app might respond slower. Long press for options + This is a summary of the content of a raw message file. Save the raw message with the save icon in the action bar to view all content. Open link The title and the link address are different