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:
parent
ff9e94e722
commit
de70ee5f78
@ -98,7 +98,7 @@ public class Rfc822Output {
|
|||||||
/**
|
/**
|
||||||
* Returns an HTML encoded message alternate
|
* Returns an HTML encoded message alternate
|
||||||
*/
|
*/
|
||||||
/*package*/ static String getHtmlAlternate(Body body) {
|
/*package*/ static String getHtmlAlternate(Body body, boolean useSmartReply) {
|
||||||
if (body.mHtmlReply == null) {
|
if (body.mHtmlReply == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -111,8 +111,10 @@ public class Rfc822Output {
|
|||||||
htmlIntro = NEWLINE_PATTERN.matcher(htmlIntro).replaceAll(NEWLINE_HTML);
|
htmlIntro = NEWLINE_PATTERN.matcher(htmlIntro).replaceAll(NEWLINE_HTML);
|
||||||
altMessage.append(htmlIntro);
|
altMessage.append(htmlIntro);
|
||||||
}
|
}
|
||||||
String htmlBody = getHtmlBody(body.mHtmlReply);
|
if (!useSmartReply) {
|
||||||
altMessage.append(htmlBody);
|
String htmlBody = getHtmlBody(body.mHtmlReply);
|
||||||
|
altMessage.append(htmlBody);
|
||||||
|
}
|
||||||
return altMessage.toString();
|
return altMessage.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +163,7 @@ public class Rfc822Output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
messageBody[INDEX_BODY_TEXT] = text;
|
messageBody[INDEX_BODY_TEXT] = text;
|
||||||
messageBody[INDEX_BODY_HTML] = getHtmlAlternate(body);
|
messageBody[INDEX_BODY_HTML] = getHtmlAlternate(body, useSmartReply);
|
||||||
return messageBody;
|
return messageBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,16 +350,21 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
|||||||
Body body = createTestBody(message);
|
Body body = createTestBody(message);
|
||||||
String html;
|
String html;
|
||||||
|
|
||||||
html = Rfc822Output.getHtmlAlternate(body);
|
// Generic case
|
||||||
|
html = Rfc822Output.getHtmlAlternate(body, false);
|
||||||
assertEquals(TEXT + REPLY_INTRO_HTML + BODY_HTML_REPLY, html);
|
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()
|
// HTML special characters; dependent upon TextUtils#htmlEncode()
|
||||||
message.mId = -1; // Changing the message; need to reset the id
|
message.mId = -1; // Changing the message; need to reset the id
|
||||||
message.mText = "<>&'\"";
|
message.mText = "<>&'\"";
|
||||||
message.save(mMockContext);
|
message.save(mMockContext);
|
||||||
body = createTestBody(message);
|
body = createTestBody(message);
|
||||||
|
|
||||||
html = Rfc822Output.getHtmlAlternate(body);
|
html = Rfc822Output.getHtmlAlternate(body, false);
|
||||||
assertEquals("<>&'"" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html);
|
assertEquals("<>&'"" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html);
|
||||||
|
|
||||||
// Newlines in user text
|
// Newlines in user text
|
||||||
@ -368,7 +373,7 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
|||||||
message.save(mMockContext);
|
message.save(mMockContext);
|
||||||
body = createTestBody(message);
|
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);
|
assertEquals("dos<br>unix<br>three<br><br><br>" + REPLY_INTRO_HTML + BODY_HTML_REPLY, html);
|
||||||
|
|
||||||
// Null HTML reply
|
// Null HTML reply
|
||||||
@ -377,7 +382,7 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
|||||||
message.save(mMockContext);
|
message.save(mMockContext);
|
||||||
body = createTestBody(message);
|
body = createTestBody(message);
|
||||||
|
|
||||||
html = Rfc822Output.getHtmlAlternate(body);
|
html = Rfc822Output.getHtmlAlternate(body, false);
|
||||||
assertNull(html);
|
assertNull(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user