Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2c5229e authored by Joe Steele's avatar Joe Steele
Browse files

Change when <html> tags are applied to messages.

Previously, <html>, <head>, & <body> tags were
attached to messages before they were stored locally.
But now that the <head> element also needs to include
a <meta> element (for proper MessageWebView display),
it seems unecesary to store all these tags with each
message.

Now the tags are no longer stored with the messages.  Instead,
MessageWebView applies the tags before displaying the message.

This also eliminates the need to upgrade an older
message database where all the old messages would have
otherwise needed to be wrapped with the new tags.
parent 73102233
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3047,7 +3047,7 @@ public class MessageCompose extends K9Activity implements OnClickListener {
            if (part != null) {
                if (K9.DEBUG)
                    Log.d(K9.LOG_TAG, "getBodyTextFromMessage: HTML requested, text found.");
                return HtmlConverter.textToHtml(MimeUtility.getTextFromPart(part), true);
                return HtmlConverter.textToHtml(MimeUtility.getTextFromPart(part), false);
            }
        } else if (format == SimpleMessageFormat.TEXT) {
            // Text takes precedence, then html.
+0 −3
Original line number Diff line number Diff line
@@ -1376,7 +1376,6 @@ public class MimeUtility {

            StringBuilder text = new StringBuilder();
            StringBuilder html = new StringBuilder();
            html.append(HtmlConverter.getHtmlHeader());

            for (Viewable viewable : viewables) {
                if (viewable instanceof Textual) {
@@ -1428,8 +1427,6 @@ public class MimeUtility {
                }
            }

            html.append(HtmlConverter.getHtmlFooter());

            return new ViewableContainer(text.toString(), html.toString(), attachments);
        } catch (Exception e) {
            throw new MessagingException("Couldn't extract viewable parts", e);
+5 −6
Original line number Diff line number Diff line
@@ -152,15 +152,14 @@ public class MessageWebView extends TitleBarWebView {
    }

    public void setText(String text, String contentType) {
        String content = text;
        String content = "<html><head><meta name=\"viewport\" content=\"width=device-width\"/>";
        if (K9.getK9MessageViewTheme() == K9.Theme.DARK)  {
            // It's a little wrong to just throw in the <style> before the opening <html>
            // but it's less wrong than trying to edit the html stream
            content = "<style>* { background: black ! important; color: white !important }" +
            content += "<style type=\"text/css\">" +
                   "* { background: black ! important; color: white !important }" +
                   ":link, :link * { color: #CCFF33 !important }" +
                   ":visited, :visited * { color: #551A8B !important }</style> "
                   + content;
                   ":visited, :visited * { color: #551A8B !important }</style> ";
        }
        content += "</head><body>" + text + "</body></html>";
        loadDataWithBaseURL("http://", content, contentType, "utf-8", null);
    }

+1 −1
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
        if (pgpData != null) {
            text = pgpData.getDecryptedData();
            if (text != null) {
                text = HtmlConverter.textToHtml(text, true);
                text = HtmlConverter.textToHtml(text, false);
            }
        }