mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Use setter for quoted text like signature
This commit is contained in:
parent
71e766999c
commit
68850b1dc9
@ -1382,13 +1382,19 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
textBodyBuilder.setAppendSignature(false);
|
textBodyBuilder.setAppendSignature(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextBody body;
|
TextBody body;
|
||||||
if (messageFormat == SimpleMessageFormat.HTML) {
|
if (messageFormat == SimpleMessageFormat.HTML) {
|
||||||
body = textBodyBuilder.buildTextHtml(mQuotedHtmlContent);
|
if (mQuotedHtmlContent == null) {
|
||||||
|
textBodyBuilder.setIncludeQuotedText(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
body = textBodyBuilder.buildTextPlain(mQuotedText.getText().toString());
|
textBodyBuilder.setQuotedTextHtml(mQuotedHtmlContent);
|
||||||
|
}
|
||||||
|
body = textBodyBuilder.buildTextHtml();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
textBodyBuilder.setQuotedText(mQuotedText.getText().toString());
|
||||||
|
body = textBodyBuilder.buildTextPlain();
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ public class TextBodyBuilder {
|
|||||||
// message parts
|
// message parts
|
||||||
private String mMessageContent;
|
private String mMessageContent;
|
||||||
private String mSignature;
|
private String mSignature;
|
||||||
|
private String mQuotedText;
|
||||||
|
private InsertableHtmlContent mQuotedTextHtml;
|
||||||
|
|
||||||
public TextBodyBuilder(String messageContent) {
|
public TextBodyBuilder(String messageContent) {
|
||||||
mMessageContent = messageContent;
|
mMessageContent = messageContent;
|
||||||
@ -36,7 +38,7 @@ public class TextBodyBuilder {
|
|||||||
* @return {@link TextBody} instance that contains the entered text and
|
* @return {@link TextBody} instance that contains the entered text and
|
||||||
* possibly the quoted original message.
|
* possibly the quoted original message.
|
||||||
*/
|
*/
|
||||||
public TextBody buildTextHtml(InsertableHtmlContent quotedHtmlContent) {
|
public TextBody buildTextHtml() {
|
||||||
// The length of the formatted version of the user-supplied text/reply
|
// The length of the formatted version of the user-supplied text/reply
|
||||||
int composedMessageLength;
|
int composedMessageLength;
|
||||||
|
|
||||||
@ -47,7 +49,9 @@ public class TextBodyBuilder {
|
|||||||
String text = mMessageContent;
|
String text = mMessageContent;
|
||||||
|
|
||||||
// Do we have to modify an existing message to include our reply?
|
// Do we have to modify an existing message to include our reply?
|
||||||
if (mIncludeQuotedText && quotedHtmlContent != null) {
|
if (mIncludeQuotedText) {
|
||||||
|
InsertableHtmlContent quotedHtmlContent = getQuotedTextHtml();
|
||||||
|
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) {
|
||||||
Log.d(K9.LOG_TAG, "insertable: " + quotedHtmlContent.toDebugString());
|
Log.d(K9.LOG_TAG, "insertable: " + quotedHtmlContent.toDebugString());
|
||||||
}
|
}
|
||||||
@ -134,7 +138,7 @@ public class TextBodyBuilder {
|
|||||||
* @return {@link TextBody} instance that contains the entered text and
|
* @return {@link TextBody} instance that contains the entered text and
|
||||||
* possibly the quoted original message.
|
* possibly the quoted original message.
|
||||||
*/
|
*/
|
||||||
public TextBody buildTextPlain(String quotedText) {
|
public TextBody buildTextPlain() {
|
||||||
// The length of the formatted version of the user-supplied text/reply
|
// The length of the formatted version of the user-supplied text/reply
|
||||||
int composedMessageLength;
|
int composedMessageLength;
|
||||||
|
|
||||||
@ -149,7 +153,8 @@ public class TextBodyBuilder {
|
|||||||
composedMessageOffset = 0;
|
composedMessageOffset = 0;
|
||||||
|
|
||||||
// Do we have to modify an existing message to include our reply?
|
// Do we have to modify an existing message to include our reply?
|
||||||
if (mIncludeQuotedText && !StringUtils.isNullOrEmpty(quotedText)) {
|
if (mIncludeQuotedText) {
|
||||||
|
String quotedText = getQuotedText();
|
||||||
|
|
||||||
if (mAppendSignature) {
|
if (mAppendSignature) {
|
||||||
// Append signature to the text/reply
|
// Append signature to the text/reply
|
||||||
@ -209,6 +214,18 @@ public class TextBodyBuilder {
|
|||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getQuotedText() {
|
||||||
|
String quotedText = "";
|
||||||
|
if (!StringUtils.isNullOrEmpty(mQuotedText)) {
|
||||||
|
quotedText = mQuotedText;
|
||||||
|
}
|
||||||
|
return quotedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InsertableHtmlContent getQuotedTextHtml() {
|
||||||
|
return mQuotedTextHtml;
|
||||||
|
}
|
||||||
|
|
||||||
public String textToHtmlFragment(String text) {
|
public String textToHtmlFragment(String text) {
|
||||||
return HtmlConverter.textToHtmlFragment(text);
|
return HtmlConverter.textToHtmlFragment(text);
|
||||||
}
|
}
|
||||||
@ -223,6 +240,14 @@ public class TextBodyBuilder {
|
|||||||
mIncludeQuotedText = includeQuotedText;
|
mIncludeQuotedText = includeQuotedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setQuotedText(String quotedText) {
|
||||||
|
mQuotedText = quotedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuotedTextHtml(InsertableHtmlContent quotedTextHtml) {
|
||||||
|
mQuotedTextHtml = quotedTextHtml;
|
||||||
|
}
|
||||||
|
|
||||||
public void setInsertSeparator(boolean insertSeparator) {
|
public void setInsertSeparator(boolean insertSeparator) {
|
||||||
mInsertSeparator = insertSeparator;
|
mInsertSeparator = insertSeparator;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class TextBodyBuilderTest {
|
|||||||
String messageContent = "message content";
|
String messageContent = "message content";
|
||||||
String signature = "signature";
|
String signature = "signature";
|
||||||
|
|
||||||
TextBody textBody = new TestingTextBodyBuilder(
|
TestingTextBodyBuilder textBodyBuilder = new TestingTextBodyBuilder(
|
||||||
includeQuotedText,
|
includeQuotedText,
|
||||||
isDraft,
|
isDraft,
|
||||||
quoteStyle,
|
quoteStyle,
|
||||||
@ -145,7 +145,9 @@ public class TextBodyBuilderTest {
|
|||||||
isSignatureUse,
|
isSignatureUse,
|
||||||
messageContent,
|
messageContent,
|
||||||
signature
|
signature
|
||||||
).buildTextPlain(quotedText);
|
);
|
||||||
|
textBodyBuilder.setQuotedText(quotedText);
|
||||||
|
TextBody textBody = textBodyBuilder.buildTextPlain();
|
||||||
|
|
||||||
assertThat(textBody, instanceOf(TextBody.class));
|
assertThat(textBody, instanceOf(TextBody.class));
|
||||||
assertThat(textBody.getText(), is(expectedText));
|
assertThat(textBody.getText(), is(expectedText));
|
||||||
@ -314,7 +316,8 @@ public class TextBodyBuilderTest {
|
|||||||
insertableHtmlContent.setQuotedContent(new StringBuilder(quotedText));
|
insertableHtmlContent.setQuotedContent(new StringBuilder(quotedText));
|
||||||
String messageContent = "message content";
|
String messageContent = "message content";
|
||||||
String signature = "signature";
|
String signature = "signature";
|
||||||
TextBody textBody = new TestingTextBodyBuilder(
|
|
||||||
|
TestingTextBodyBuilder textBodyBuilder = new TestingTextBodyBuilder(
|
||||||
includeQuotedText,
|
includeQuotedText,
|
||||||
isDraft,
|
isDraft,
|
||||||
quoteStyle,
|
quoteStyle,
|
||||||
@ -323,7 +326,9 @@ public class TextBodyBuilderTest {
|
|||||||
isSignatureUse,
|
isSignatureUse,
|
||||||
messageContent,
|
messageContent,
|
||||||
signature
|
signature
|
||||||
).buildTextHtml(insertableHtmlContent);
|
);
|
||||||
|
textBodyBuilder.setQuotedTextHtml(insertableHtmlContent);
|
||||||
|
TextBody textBody = textBodyBuilder.buildTextHtml();
|
||||||
|
|
||||||
assertThat(textBody, instanceOf(TextBody.class));
|
assertThat(textBody, instanceOf(TextBody.class));
|
||||||
assertThat(textBody.getText(), is(expectedText));
|
assertThat(textBody.getText(), is(expectedText));
|
||||||
|
Loading…
Reference in New Issue
Block a user