1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

add MessageFormat.AUTO so that text/html messages are created only when necessary.

This commit is contained in:
ashley willis 2011-11-14 17:28:45 -06:00
parent b3bfcbde15
commit 9201d16659
4 changed files with 22 additions and 1 deletions

View File

@ -677,11 +677,13 @@
<string-array name="account_settings_message_format_entries">
<item>@string/account_settings_message_format_text</item>
<item>@string/account_settings_message_format_html</item>
<item>@string/account_settings_message_format_auto</item>
</string-array>
<string-array name="account_settings_message_format_values">
<item>TEXT</item>
<item>HTML</item>
<item>AUTO</item>
</string-array>
</resources>

View File

@ -568,6 +568,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_settings_message_format_label">Message Format</string>
<string name="account_settings_message_format_text">Plain Text (images and formatting will be removed)</string>
<string name="account_settings_message_format_html">HTML (images and formatting are preserved)</string>
<string name="account_settings_message_format_auto">Automatic (plain text unless replying to an html message)</string>
<string name="account_settings_message_read_receipt_label">Read receipt</string>
<string name="account_settings_message_read_receipt_summary">Always request a read receipt</string>

View File

@ -191,7 +191,7 @@ public class Account implements BaseAccount {
}
public enum MessageFormat {
TEXT, HTML
TEXT, HTML, AUTO
}
protected Account(Context context) {

View File

@ -75,6 +75,7 @@ import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBody;
public class MessageCompose extends K9Activity implements OnClickListener, OnFocusChangeListener {
private static final int DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE = 1;
private static final String ACTION_COMPOSE = "com.fsck.k9.intent.action.COMPOSE";
private static final String ACTION_REPLY = "com.fsck.k9.intent.action.REPLY";
private static final String ACTION_REPLY_ALL = "com.fsck.k9.intent.action.REPLY_ALL";
private static final String ACTION_FORWARD = "com.fsck.k9.intent.action.FORWARD";
@ -280,6 +281,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
Intent i = new Intent(context, MessageCompose.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
i.setAction(ACTION_COMPOSE);
context.startActivity(i);
}
@ -533,6 +535,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
mMessageFormat = mAccount.getMessageFormat();
if (mMessageFormat == MessageFormat.AUTO) {
if (ACTION_COMPOSE.equals(action)) {
mMessageFormat = MessageFormat.TEXT;
} else if (mSourceMessageBody != null) {
// mSourceMessageBody is set to something when replying to and forwarding decrypted
// messages, so we set the format to plain text.
mMessageFormat = MessageFormat.TEXT;
}
}
mReadReceipt = mAccount.isMessageReadReceiptAlways();
if (!mSourceMessageProcessed) {
@ -2243,6 +2255,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* @throws MessagingException
*/
private void populateUIWithQuotedMessage(boolean shown) throws MessagingException {
if (mMessageFormat == MessageFormat.AUTO) {
mMessageFormat = MimeUtility.findFirstPartByMimeType(mSourceMessage, "text/html") == null
? MessageFormat.TEXT
: MessageFormat.HTML;
}
// TODO -- I am assuming that mSourceMessageBody will always be a text part. Is this a safe assumption?
// Handle the original message in the reply