mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 07:01:05 +00:00
Added headers to EML viewer
This commit is contained in:
parent
fb3eb4f909
commit
2cf51238dc
2 changed files with 54 additions and 11 deletions
|
@ -25,7 +25,9 @@ import android.content.Context;
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ public class ActivityEml extends ActivityBase {
|
||||||
final TextView tvCc = findViewById(R.id.tvCc);
|
final TextView tvCc = findViewById(R.id.tvCc);
|
||||||
final TextView tvBcc = findViewById(R.id.tvBcc);
|
final TextView tvBcc = findViewById(R.id.tvBcc);
|
||||||
final TextView tvSubject = findViewById(R.id.tvSubject);
|
final TextView tvSubject = findViewById(R.id.tvSubject);
|
||||||
|
final TextView tvHeaders = findViewById(R.id.tvHeaders);
|
||||||
final TextView tvParts = findViewById(R.id.tvParts);
|
final TextView tvParts = findViewById(R.id.tvParts);
|
||||||
final TextView tvBody = findViewById(R.id.tvBody);
|
final TextView tvBody = findViewById(R.id.tvBody);
|
||||||
final TextView tvHtml = findViewById(R.id.tvHtml);
|
final TextView tvHtml = findViewById(R.id.tvHtml);
|
||||||
|
@ -110,6 +113,21 @@ public class ActivityEml extends ActivityBase {
|
||||||
result.bcc = MessageHelper.formatAddresses(helper.getBcc());
|
result.bcc = MessageHelper.formatAddresses(helper.getBcc());
|
||||||
result.subject = helper.getSubject();
|
result.subject = helper.getSubject();
|
||||||
|
|
||||||
|
String headers = helper.getHeaders();
|
||||||
|
int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
|
||||||
|
SpannableStringBuilder ssb = new SpannableStringBuilder(headers);
|
||||||
|
int index = 0;
|
||||||
|
for (String line : headers.split("\n")) {
|
||||||
|
if (line.length() > 0 && !Character.isWhitespace(line.charAt(0))) {
|
||||||
|
int colon = line.indexOf(':');
|
||||||
|
if (colon > 0)
|
||||||
|
ssb.setSpan(new ForegroundColorSpan(colorAccent), index, index + colon, 0);
|
||||||
|
}
|
||||||
|
index += line.length() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.headers = ssb;
|
||||||
|
|
||||||
MessageHelper.MessageParts parts = helper.getMessageParts();
|
MessageHelper.MessageParts parts = helper.getMessageParts();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -144,6 +162,7 @@ public class ActivityEml extends ActivityBase {
|
||||||
tvCc.setText(result.cc);
|
tvCc.setText(result.cc);
|
||||||
tvBcc.setText(result.bcc);
|
tvBcc.setText(result.bcc);
|
||||||
tvSubject.setText(result.subject);
|
tvSubject.setText(result.subject);
|
||||||
|
tvHeaders.setText(result.headers);
|
||||||
tvParts.setText(result.parts);
|
tvParts.setText(result.parts);
|
||||||
tvBody.setText(result.body);
|
tvBody.setText(result.body);
|
||||||
tvHtml.setText(result.html);
|
tvHtml.setText(result.html);
|
||||||
|
@ -168,6 +187,7 @@ public class ActivityEml extends ActivityBase {
|
||||||
String cc;
|
String cc;
|
||||||
String bcc;
|
String bcc;
|
||||||
String subject;
|
String subject;
|
||||||
|
Spanned headers;
|
||||||
Spanned parts;
|
Spanned parts;
|
||||||
Spanned body;
|
Spanned body;
|
||||||
String html;
|
String html;
|
||||||
|
|
|
@ -133,7 +133,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvBcc" />
|
app:layout_constraintTop_toBottomOf="@id/tvBcc" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorParts"
|
android:id="@+id/vSeparatorHeaders"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
|
@ -142,6 +142,28 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvSubject" />
|
app:layout_constraintTop_toBottomOf="@id/tvSubject" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvHeaders"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:text="Headers"
|
||||||
|
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
|
<TextView
|
||||||
android:id="@+id/tvParts"
|
android:id="@+id/tvParts"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -234,6 +256,7 @@
|
||||||
tvCcTitle,tvCc,
|
tvCcTitle,tvCc,
|
||||||
tvBccTitle,tvBcc,
|
tvBccTitle,tvBcc,
|
||||||
tvSubject,
|
tvSubject,
|
||||||
|
vSeparatorHeaders,tvHeaders,
|
||||||
vSeparatorParts,tvParts,
|
vSeparatorParts,tvParts,
|
||||||
vSeparatorBody,tvBody,
|
vSeparatorBody,tvBody,
|
||||||
vSeparatorHtml,tvHtml,
|
vSeparatorHtml,tvHtml,
|
||||||
|
|
Loading…
Reference in a new issue