mirror of https://github.com/M66B/FairEmail.git
Small layout improvements
This commit is contained in:
parent
d55b594858
commit
7e0cb664b6
|
@ -2936,11 +2936,13 @@ public class HtmlHelper {
|
||||||
return ssb.toString();
|
return ssb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Spanned highlightHeaders(Context context, Address[] from, Address[] to, Long r, String headers, boolean blocklist) {
|
static Spanned highlightHeaders(Context context, Address[] from, Address[] to, Long time, String headers, boolean blocklist) {
|
||||||
SpannableStringBuilder ssb = new SpannableStringBuilderEx(headers.replaceAll("\\t", " "));
|
SpannableStringBuilder ssb = new SpannableStringBuilderEx(headers.replaceAll("\\t", " "));
|
||||||
int textColorLink = Helper.resolveColor(context, android.R.attr.textColorLink);
|
int textColorLink = Helper.resolveColor(context, android.R.attr.textColorLink);
|
||||||
int colorVerified = Helper.resolveColor(context, R.attr.colorVerified);
|
int colorVerified = Helper.resolveColor(context, R.attr.colorVerified);
|
||||||
int colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
|
int colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
|
||||||
|
int colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator);
|
||||||
|
float stroke = context.getResources().getDisplayMetrics().density;
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (String line : headers.split("\n")) {
|
for (String line : headers.split("\n")) {
|
||||||
|
@ -2952,6 +2954,10 @@ public class HtmlHelper {
|
||||||
index += line.length() + 1;
|
index += line.length() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssb.append("\n\uFFFC"); // Object replacement character
|
||||||
|
ssb.setSpan(new LineSpan(colorSeparator, stroke, 0), ssb.length() - 1, ssb.length(), 0);
|
||||||
|
ssb.append('\n');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// https://datatracker.ietf.org/doc/html/rfc2821#section-4.4
|
// https://datatracker.ietf.org/doc/html/rfc2821#section-4.4
|
||||||
final DateFormat DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.MEDIUM);
|
final DateFormat DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.MEDIUM);
|
||||||
|
@ -2960,8 +2966,9 @@ public class HtmlHelper {
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(headers.getBytes());
|
ByteArrayInputStream bis = new ByteArrayInputStream(headers.getBytes());
|
||||||
InternetHeaders iheaders = new InternetHeaders(bis, true);
|
InternetHeaders iheaders = new InternetHeaders(bis, true);
|
||||||
|
|
||||||
String dh = iheaders.getHeader("Date", null);
|
|
||||||
Date tx = null;
|
Date tx = null;
|
||||||
|
|
||||||
|
String dh = iheaders.getHeader("Date", null);
|
||||||
try {
|
try {
|
||||||
if (dh != null)
|
if (dh != null)
|
||||||
tx = mdf.parse(dh);
|
tx = mdf.parse(dh);
|
||||||
|
@ -2969,20 +2976,22 @@ public class HtmlHelper {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tx != null) {
|
||||||
|
ssb.append('\n');
|
||||||
int s = ssb.length();
|
int s = ssb.length();
|
||||||
ssb.append("\n#0 ");
|
|
||||||
if (tx != null)
|
|
||||||
ssb.append(DTF.format(tx));
|
ssb.append(DTF.format(tx));
|
||||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), s, ssb.length(), 0);
|
ssb.setSpan(new StyleSpan(Typeface.BOLD), s, ssb.length(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
ssb.append('\n');
|
ssb.append('\n');
|
||||||
s = ssb.length();
|
int s = ssb.length();
|
||||||
ssb.append("from");
|
ssb.append("from");
|
||||||
ssb.setSpan(new ForegroundColorSpan(textColorLink), s, ssb.length(), 0);
|
ssb.setSpan(new ForegroundColorSpan(textColorLink), s, ssb.length(), 0);
|
||||||
ssb.append(' ').append(MessageHelper.formatAddresses(from, true, false));
|
ssb.append(' ').append(MessageHelper.formatAddresses(from, true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tx != null || from != null)
|
||||||
ssb.append('\n');
|
ssb.append('\n');
|
||||||
|
|
||||||
Date rx = null;
|
Date rx = null;
|
||||||
|
@ -2998,7 +3007,7 @@ public class HtmlHelper {
|
||||||
h = h.substring(0, semi);
|
h = h.substring(0, semi);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = ssb.length();
|
int s = ssb.length();
|
||||||
ssb.append('#').append(Integer.toString(received.length - i));
|
ssb.append('#').append(Integer.toString(received.length - i));
|
||||||
if (rx != null) {
|
if (rx != null) {
|
||||||
ssb.append(' ').append(DTF.format(rx));
|
ssb.append(' ').append(DTF.format(rx));
|
||||||
|
@ -3064,29 +3073,34 @@ public class HtmlHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s = ssb.length();
|
if (time != null) {
|
||||||
ssb.append("\n#").append(Integer.toString(received == null ? 1 : received.length + 1));
|
ssb.append('\n');
|
||||||
if (r != null) {
|
int s = ssb.length();
|
||||||
ssb.append(' ').append(DTF.format(r));
|
ssb.append(DTF.format(time));
|
||||||
if (rx != null)
|
if (rx != null)
|
||||||
ssb.append(" \u0394")
|
ssb.append(" \u0394")
|
||||||
.append(Helper.formatDuration(r - rx.getTime()));
|
.append(Helper.formatDuration(time - rx.getTime()));
|
||||||
}
|
|
||||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), s, ssb.length(), 0);
|
ssb.setSpan(new StyleSpan(Typeface.BOLD), s, ssb.length(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
ssb.append('\n');
|
ssb.append('\n');
|
||||||
s = ssb.length();
|
int s = ssb.length();
|
||||||
ssb.append("to");
|
ssb.append("to");
|
||||||
ssb.setSpan(new ForegroundColorSpan(textColorLink), s, ssb.length(), 0);
|
ssb.setSpan(new ForegroundColorSpan(textColorLink), s, ssb.length(), 0);
|
||||||
ssb.append(' ').append(MessageHelper.formatAddresses(to, true, false));
|
ssb.append(' ').append(MessageHelper.formatAddresses(to, true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (time != null || to != null)
|
||||||
ssb.append('\n');
|
ssb.append('\n');
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssb.append("\n\uFFFC"); // Object replacement character
|
||||||
|
ssb.setSpan(new LineSpan(colorSeparator, stroke, 0), ssb.length() - 1, ssb.length(), 0);
|
||||||
|
ssb.append('\n');
|
||||||
|
|
||||||
return ssb;
|
return ssb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue