Don't duplicate HTML in reply / forward

On exchange servers that support "smart reply", the original message is
actually appended by the server. In this situation, we should not append
the original HTML text on the client.

but 4177192

Change-Id: I6fad74ac761e2abfe7cb0f536df4db30f7d5ca9a
This commit is contained in:
Todd Kennedy 2011-03-25 14:22:19 -07:00
parent ff9e94e722
commit de70ee5f78
2 changed files with 15 additions and 8 deletions

View File

@ -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;
}

View File

@ -350,16 +350,21 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
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("&lt;&gt;&amp;&apos;&quot;" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html);
// Newlines in user text
@ -368,7 +373,7 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
message.save(mMockContext);
body = createTestBody(message);
html = Rfc822Output.getHtmlAlternate(body);
html = Rfc822Output.getHtmlAlternate(body, false);
assertEquals("dos<br>unix<br>three<br><br><br>" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html);
// Null HTML reply
@ -377,7 +382,7 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
message.save(mMockContext);
body = createTestBody(message);
html = Rfc822Output.getHtmlAlternate(body);
html = Rfc822Output.getHtmlAlternate(body, false);
assertNull(html);
}