|
|
@ -22,6 +22,7 @@ package eu.faircode.email;
|
|
|
|
import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_INDIVIDUAL;
|
|
|
|
import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_INDIVIDUAL;
|
|
|
|
import static org.w3c.css.sac.Condition.SAC_CLASS_CONDITION;
|
|
|
|
import static org.w3c.css.sac.Condition.SAC_CLASS_CONDITION;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.ActivityManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
@ -362,6 +363,15 @@ public class HtmlHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int getMaxFormatTextSize(Context context) {
|
|
|
|
|
|
|
|
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
|
|
|
|
|
|
|
int mc = am.getMemoryClass();
|
|
|
|
|
|
|
|
if (mc >= 256)
|
|
|
|
|
|
|
|
return MAX_FORMAT_TEXT_SIZE;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return mc * MAX_FORMAT_TEXT_SIZE / 256;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static Document sanitize(Context context, Document parsed, boolean view, boolean show_images) {
|
|
|
|
private static Document sanitize(Context context, Document parsed, boolean view, boolean show_images) {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
String theme = prefs.getString("theme", "blue_orange_system");
|
|
|
|
String theme = prefs.getString("theme", "blue_orange_system");
|
|
|
@ -425,7 +435,7 @@ public class HtmlHelper {
|
|
|
|
normalizeNamespaces(parsed, display_hidden);
|
|
|
|
normalizeNamespaces(parsed, display_hidden);
|
|
|
|
|
|
|
|
|
|
|
|
// Limit length
|
|
|
|
// Limit length
|
|
|
|
if (view && truncate(parsed, MAX_FORMAT_TEXT_SIZE)) {
|
|
|
|
if (view && truncate(parsed, getMaxFormatTextSize(context))) {
|
|
|
|
parsed.body()
|
|
|
|
parsed.body()
|
|
|
|
.appendElement("p")
|
|
|
|
.appendElement("p")
|
|
|
|
.appendElement("em")
|
|
|
|
.appendElement("em")
|
|
|
@ -2200,7 +2210,7 @@ public class HtmlHelper {
|
|
|
|
static String getText(Context context, String html) {
|
|
|
|
static String getText(Context context, String html) {
|
|
|
|
Document d = sanitizeCompose(context, html, false);
|
|
|
|
Document d = sanitizeCompose(context, html, false);
|
|
|
|
|
|
|
|
|
|
|
|
truncate(d, MAX_FORMAT_TEXT_SIZE);
|
|
|
|
truncate(d, getMaxFormatTextSize(context));
|
|
|
|
|
|
|
|
|
|
|
|
SpannableStringBuilder ssb = fromDocument(context, d, null, null);
|
|
|
|
SpannableStringBuilder ssb = fromDocument(context, d, null, null);
|
|
|
|
|
|
|
|
|
|
|
|