MCPcopy Create free account
hub / github.com/M66B/FairEmail / _getText

Method _getText

app/src/main/java/eu/faircode/email/HtmlHelper.java:2697–2742  ·  view source on GitHub ↗
(Context context, Document d)

Source from the content-addressed store, hash-verified

2695 }
2696
2697 private static String _getText(Context context, Document d) {
2698 truncate(d, MAX_FULL_TEXT_SIZE);
2699
2700 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
2701 boolean preview_hidden = prefs.getBoolean("preview_hidden", true);
2702 boolean preview_quotes = prefs.getBoolean("preview_quotes", true);
2703
2704 if (!preview_hidden)
2705 for (Element e : d.select("*")) {
2706 String style = e.attr("style");
2707 if (TextUtils.isEmpty(style))
2708 continue;
2709
2710 String[] params = style.split(";");
2711 for (String param : params) {
2712 int colon = param.indexOf(':');
2713 if (colon <= 0)
2714 continue;
2715 String key = param.substring(0, colon)
2716 .trim()
2717 .toLowerCase(Locale.ROOT);
2718 String value = param.substring(colon + 1)
2719 .replace("!important", "")
2720 .trim()
2721 .toLowerCase(Locale.ROOT)
2722 .replaceAll("\\s+", " ");
2723 if ("display".equals(key) && "none".equals(value)) {
2724 e.remove();
2725 break;
2726 }
2727 }
2728 }
2729
2730 if (!preview_quotes) {
2731 if (!removeQuotes(d, false)) {
2732 Element top = d.select("blockquote").first();
2733 if (top != null && top.previousElementSibling() == null)
2734 top.remove();
2735 }
2736 }
2737
2738 for (Element bq : d.select("blockquote"))
2739 bq.prependChild(new TextNode("> "));
2740
2741 return d.body().text();
2742 }
2743
2744 static String getQuoteStyle(Element e) {
2745 CharSequence text = e.text();

Callers 1

getFullTextMethod · 0.95

Calls 11

truncateMethod · 0.95
removeQuotesMethod · 0.95
getBooleanMethod · 0.80
indexOfMethod · 0.80
trimMethod · 0.80
bodyMethod · 0.80
selectMethod · 0.65
isEmptyMethod · 0.45
replaceMethod · 0.45
equalsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected