Refactoring

pull/178/head
M66B 5 years ago
parent e4b3eb6276
commit c009f1c4bf

@ -936,6 +936,27 @@ public class HtmlHelper {
return false;
}
// https://tools.ietf.org/html/rfc3676
static String flow(String text) {
boolean continuation = false;
StringBuilder flowed = new StringBuilder();
for (String line : text.split("\\r?\\n")) {
if (continuation)
while (line.startsWith(">")) {
line = line.substring(1);
if (line.startsWith(" "))
line = line.substring(1);
}
continuation = (line.endsWith(" ") && !"-- ".equals(line));
flowed.append(line);
if (!continuation)
flowed.append("\r\n");
}
return flowed.toString();
}
static String formatPre(String text) {
int level = 0;
StringBuilder sb = new StringBuilder();

@ -1481,26 +1481,8 @@ public class MessageHelper {
warnings.add(context.getString(R.string.title_no_charset, charset));
if (part.isMimeType("text/plain")) {
// https://tools.ietf.org/html/rfc3676
if ("flowed".equalsIgnoreCase(ct.getParameter("format"))) {
boolean continuation = false;
StringBuilder flowed = new StringBuilder();
for (String line : result.split("\\r?\\n")) {
if (continuation)
while (line.startsWith(">")) {
line = line.substring(1);
if (line.startsWith(" "))
line = line.substring(1);
}
continuation = (line.endsWith(" ") && !"-- ".equals(line));
flowed.append(line);
if (!continuation)
flowed.append("\r\n");
}
result = flowed.toString();
}
if ("flowed".equalsIgnoreCase(ct.getParameter("format")))
result = HtmlHelper.flow(result);
result = "<div>" + HtmlHelper.formatPre(result) + "</div>";
} else if (part.isMimeType("text/html")) {
if (TextUtils.isEmpty(charset)) {

Loading…
Cancel
Save