mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 15:17:03 +02:00
Simplified raw message file viewer
This commit is contained in:
@@ -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("<br>");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,27 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/title_hint_eml"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHint" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFromTitle"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -24,7 +45,7 @@
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHeader" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFrom"
|
||||
@@ -36,7 +57,7 @@
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tvFromTitle"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHeader" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvToTitle"
|
||||
@@ -60,50 +81,6 @@
|
||||
app:layout_constraintStart_toEndOf="@id/tvToTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvReplyToTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_reply_to"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvReplyTo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:text="Reply to"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tvReplyToTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCcTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_cc"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvReplyTo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCc"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:text="Cc"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tvCcTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvReplyTo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSubject"
|
||||
android:layout_width="0dp"
|
||||
@@ -111,12 +88,13 @@
|
||||
android:text="Subject"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCc" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTo" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorHeaders"
|
||||
android:id="@+id/vSeparatorAttachments"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="3dp"
|
||||
@@ -126,39 +104,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSubject" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHeaders"
|
||||
android:id="@+id/tvAttachments"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:fontFamily="monospace"
|
||||
android:text="Headers"
|
||||
android:text="Attachments"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHeaders" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorParts"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHeaders" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvParts"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="Parts"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorParts" />
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAttachments" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorBody"
|
||||
@@ -168,7 +123,7 @@
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvParts" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvAttachments" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBody"
|
||||
@@ -183,43 +138,16 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorHtml"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvBody" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHtml"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:fontFamily="monospace"
|
||||
android:text="HTML"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHtml" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpReady"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="
|
||||
tvFromTitle,tvFrom,
|
||||
vSeparatorHeader,tvFromTitle,tvFrom,
|
||||
tvToTitle,tvTo,
|
||||
tvReplyToTitle,tvReplyTo,
|
||||
tvCcTitle,tvCc,
|
||||
tvSubject,
|
||||
vSeparatorHeaders,tvHeaders,
|
||||
vSeparatorParts,tvParts,
|
||||
vSeparatorBody,tvBody,
|
||||
vSeparatorHtml,tvHtml" />
|
||||
vSeparatorAttachments,tvAttachments,
|
||||
vSeparatorBody,tvBody" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
@@ -552,6 +552,7 @@
|
||||
<string name="title_show_inline">Show inline attachments</string>
|
||||
<string name="title_download_all">Download all</string>
|
||||
<string name="title_save_all">Save all</string>
|
||||
<string name="title_save_eml">Save raw message file</string>
|
||||
|
||||
<string name="title_trash">Trash</string>
|
||||
<string name="title_copy">Copy …</string>
|
||||
@@ -865,6 +866,7 @@
|
||||
<string name="title_hint_message_selection">Long press a message to start selecting multiple messages; Hold and swipe up or down to select more messages</string>
|
||||
<string name="title_hint_sync">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.</string>
|
||||
<string name="title_hint_contact_actions">Long press for options</string>
|
||||
<string name="title_hint_eml">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.</string>
|
||||
|
||||
<string name="title_open_link">Open link</string>
|
||||
<string name="title_different_link">The title and the link address are different</string>
|
||||
|
||||
Reference in New Issue
Block a user