mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 07:36:31 +02:00
Truncate viewed text only
This commit is contained in:
@@ -237,14 +237,10 @@ public class HtmlHelper {
|
||||
x11ColorMap.put("yellowgreen", 0x9ACD32);
|
||||
}
|
||||
|
||||
static Document sanitize(Context context, String html, boolean show_images, boolean autolink) {
|
||||
Document parsed = JsoupEx.parse(html);
|
||||
return sanitize(context, parsed, show_images, autolink, false);
|
||||
}
|
||||
|
||||
static Document sanitize(Context context, Document parsed, boolean show_images, boolean autolink, boolean more) {
|
||||
static Document sanitizeCompose(Context context, String html, boolean show_images) {
|
||||
try {
|
||||
return _sanitize(context, parsed, show_images, autolink, more);
|
||||
Document parsed = JsoupEx.parse(html);
|
||||
return sanitize(context, parsed, false, show_images);
|
||||
} catch (Throwable ex) {
|
||||
// OutOfMemoryError
|
||||
Log.e(ex);
|
||||
@@ -256,7 +252,21 @@ public class HtmlHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static Document _sanitize(Context context, Document parsed, boolean show_images, boolean autolink, boolean more) {
|
||||
static Document sanitizeView(Context context, Document parsed, boolean show_images) {
|
||||
try {
|
||||
return sanitize(context, parsed, true, show_images);
|
||||
} catch (Throwable ex) {
|
||||
// OutOfMemoryError
|
||||
Log.e(ex);
|
||||
Document document = Document.createShell("");
|
||||
Element strong = document.createElement("strong");
|
||||
strong.text(Log.formatThrowable(ex));
|
||||
document.body().appendChild(strong);
|
||||
return document;
|
||||
}
|
||||
}
|
||||
|
||||
private static Document sanitize(Context context, Document parsed, boolean view, boolean show_images) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean text_color = prefs.getBoolean("text_color", true);
|
||||
boolean text_size = prefs.getBoolean("text_size", true);
|
||||
@@ -328,20 +338,18 @@ public class HtmlHelper {
|
||||
}
|
||||
|
||||
// Limit length
|
||||
if (truncate(parsed, true)) {
|
||||
if (view && truncate(parsed, true)) {
|
||||
parsed.body()
|
||||
.appendElement("br")
|
||||
.appendElement("p")
|
||||
.appendElement("em")
|
||||
.text(context.getString(R.string.title_too_large));
|
||||
|
||||
if (more)
|
||||
parsed.body()
|
||||
.appendElement("p")
|
||||
.appendElement("big")
|
||||
.appendElement("a")
|
||||
.attr("href", "full:")
|
||||
.text(context.getString(R.string.title_show_full));
|
||||
parsed.body()
|
||||
.appendElement("p")
|
||||
.appendElement("big")
|
||||
.appendElement("a")
|
||||
.attr("href", "full:")
|
||||
.text(context.getString(R.string.title_show_full));
|
||||
}
|
||||
|
||||
Whitelist whitelist = Whitelist.relaxed()
|
||||
@@ -688,7 +696,7 @@ public class HtmlHelper {
|
||||
}
|
||||
|
||||
// Autolink
|
||||
if (autolink) {
|
||||
if (view) {
|
||||
final Pattern pattern = Pattern.compile(
|
||||
PatternsCompat.AUTOLINK_EMAIL_ADDRESS.pattern() + "|" +
|
||||
PatternsCompat.AUTOLINK_WEB_URL.pattern());
|
||||
|
||||
Reference in New Issue
Block a user