diff --git a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java index 00de12681..c9eb5893d 100644 --- a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java +++ b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java @@ -98,7 +98,7 @@ public class Rfc822Output { /** * Returns an HTML encoded message alternate */ - /*package*/ static String getHtmlAlternate(Body body) { + /*package*/ static String getHtmlAlternate(Body body, boolean useSmartReply) { if (body.mHtmlReply == null) { return null; } @@ -111,8 +111,10 @@ public class Rfc822Output { htmlIntro = NEWLINE_PATTERN.matcher(htmlIntro).replaceAll(NEWLINE_HTML); altMessage.append(htmlIntro); } - String htmlBody = getHtmlBody(body.mHtmlReply); - altMessage.append(htmlBody); + if (!useSmartReply) { + String htmlBody = getHtmlBody(body.mHtmlReply); + altMessage.append(htmlBody); + } return altMessage.toString(); } @@ -161,7 +163,7 @@ public class Rfc822Output { } } messageBody[INDEX_BODY_TEXT] = text; - messageBody[INDEX_BODY_HTML] = getHtmlAlternate(body); + messageBody[INDEX_BODY_HTML] = getHtmlAlternate(body, useSmartReply); return messageBody; } diff --git a/tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java b/tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java index 51684d513..0369e18b9 100644 --- a/tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java +++ b/tests/src/com/android/emailcommon/internet/Rfc822OutputTests.java @@ -350,16 +350,21 @@ public class Rfc822OutputTests extends ProviderTestCase2 { Body body = createTestBody(message); String html; - html = Rfc822Output.getHtmlAlternate(body); + // Generic case + html = Rfc822Output.getHtmlAlternate(body, false); assertEquals(TEXT + REPLY_INTRO_HTML + BODY_HTML_REPLY, html); + // "smart reply" enabled; html body should not be added + html = Rfc822Output.getHtmlAlternate(body, true); + assertEquals(TEXT + REPLY_INTRO_HTML, html); + // HTML special characters; dependent upon TextUtils#htmlEncode() message.mId = -1; // Changing the message; need to reset the id message.mText = "<>&'\""; message.save(mMockContext); body = createTestBody(message); - html = Rfc822Output.getHtmlAlternate(body); + html = Rfc822Output.getHtmlAlternate(body, false); assertEquals("<>&'"" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html); // Newlines in user text @@ -368,7 +373,7 @@ public class Rfc822OutputTests extends ProviderTestCase2 { message.save(mMockContext); body = createTestBody(message); - html = Rfc822Output.getHtmlAlternate(body); + html = Rfc822Output.getHtmlAlternate(body, false); assertEquals("dos
unix
three


" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html); // Null HTML reply @@ -377,7 +382,7 @@ public class Rfc822OutputTests extends ProviderTestCase2 { message.save(mMockContext); body = createTestBody(message); - html = Rfc822Output.getHtmlAlternate(body); + html = Rfc822Output.getHtmlAlternate(body, false); assertNull(html); }