| 2789 | } |
| 2790 | |
| 2791 | static boolean isStyled(Document d) { |
| 2792 | ObjectHolder<Boolean> result = new ObjectHolder<>(false); |
| 2793 | |
| 2794 | d.body().filter(new NodeFilter() { |
| 2795 | private final List<String> STRUCTURE = Collections.unmodifiableList(Arrays.asList( |
| 2796 | "body", "div", "p", "span", "br", |
| 2797 | "strong", "b", "em", "i", "blockquote", "hr" |
| 2798 | )); |
| 2799 | |
| 2800 | @Override |
| 2801 | public FilterResult head(Node node, int depth) { |
| 2802 | if (node instanceof Element) { |
| 2803 | Element e = (Element) node; |
| 2804 | |
| 2805 | String style = e.attr("style"); |
| 2806 | if (!TextUtils.isEmpty(style)) { |
| 2807 | String[] params = style.split(";"); |
| 2808 | for (String param : params) { |
| 2809 | int colon = param.indexOf(':'); |
| 2810 | if (colon <= 0) |
| 2811 | continue; |
| 2812 | String key = param.substring(0, colon).trim(); |
| 2813 | if ("color".equalsIgnoreCase(key) || |
| 2814 | "background-color".equalsIgnoreCase(key) || |
| 2815 | "font-family".equalsIgnoreCase(key) || |
| 2816 | "font-size".equalsIgnoreCase(key) || |
| 2817 | "text-align".equalsIgnoreCase(key) || |
| 2818 | "text-decoration".equalsIgnoreCase(key) /* line-through */) { |
| 2819 | Log.i("Style element=" + node + " style=" + style); |
| 2820 | result.value = true; |
| 2821 | return FilterResult.STOP; |
| 2822 | } |
| 2823 | } |
| 2824 | } |
| 2825 | |
| 2826 | if (STRUCTURE.contains(e.tagName())) |
| 2827 | return FilterResult.CONTINUE; |
| 2828 | |
| 2829 | if (!TextUtils.isEmpty(e.attr("fairemail"))) |
| 2830 | return FilterResult.CONTINUE; |
| 2831 | |
| 2832 | //Element p = e.parent(); |
| 2833 | //if ("blockquote".equals(e.tagName()) && |
| 2834 | // p != null && |
| 2835 | // !TextUtils.isEmpty(p.attr("fairemail"))) |
| 2836 | // return FilterResult.CONTINUE; |
| 2837 | |
| 2838 | Log.i("Style element=" + node); |
| 2839 | result.value = true; |
| 2840 | return FilterResult.STOP; |
| 2841 | |
| 2842 | } else |
| 2843 | return FilterResult.CONTINUE; |
| 2844 | } |
| 2845 | |
| 2846 | @Override |
| 2847 | public FilterResult tail(Node node, int depth) { |
| 2848 | return FilterResult.CONTINUE; |