/** * Format given HTML string so it is ready to be presented in a text view * * @param html * @return formatted HTML */ public static CharSequence format(final String html) { if (html == null) return ""; if (html.length() == 0) return ""; StringBuilder formatted = new StringBuilder(html); // Remove e-mail toggle link strip(formatted, TOGGLE_START, TOGGLE_END); // Remove signature strip(formatted, SIGNATURE_START, SIGNATURE_END); // Replace div with e-mail content with block quote replace(formatted, REPLY_START, REPLY_END, BLOCKQUOTE_START, BLOCKQUOTE_END); // Remove hidden div strip(formatted, HIDDEN_REPLY_START, HIDDEN_REPLY_END); // Replace paragraphs with breaks replace(formatted, PARAGRAPH_START, BREAK); replace(formatted, PARAGRAPH_END, BREAK); formatPres(formatted); formatEmailFragments(formatted); trim(formatted); formatted.insert(0, ROOT_START); formatted.append(ROOT_END); return formatted; }