1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 09:08:49 -05:00

Added account preference to display quoted text.

This commit is contained in:
Koji Arai 2011-05-15 00:15:01 +09:00
parent 5d6df85aac
commit ce9b280746
5 changed files with 38 additions and 5 deletions

View File

@ -564,6 +564,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_settings_composition">Sending mail</string> <string name="account_settings_composition">Sending mail</string>
<string name="account_settings_default_quoted_text_shown_label">Show quoted text by default</string>
<string name="account_settings_default_quoted_text_shown_summary">When replying to messages, the original message is in your reply.</string>
<string name="account_settings_reply_after_quote_label">Reply after quoted text</string> <string name="account_settings_reply_after_quote_label">Reply after quoted text</string>
<string name="account_settings_reply_after_quote_summary">When replying to messages, the original message will appear above your reply.</string> <string name="account_settings_reply_after_quote_summary">When replying to messages, the original message will appear above your reply.</string>

View File

@ -239,6 +239,13 @@
android:entries="@array/account_settings_quote_style_entries" android:entries="@array/account_settings_quote_style_entries"
android:entryValues="@array/account_settings_quote_style_values" /> android:entryValues="@array/account_settings_quote_style_values" />
<CheckBoxPreference
android:persistent="false"
android:key="default_quoted_text_shown"
android:title="@string/account_settings_default_quoted_text_shown_label"
android:defaultValue="false"
android:summary="@string/account_settings_default_quoted_text_shown_summary" />
<CheckBoxPreference <CheckBoxPreference
android:persistent="false" android:persistent="false"
android:key="reply_after_quote" android:key="reply_after_quote"

View File

@ -60,6 +60,7 @@ public class Account implements BaseAccount {
private static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML; private static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
private static final QuoteStyle DEFAULT_QUOTE_STYLE = QuoteStyle.PREFIX; private static final QuoteStyle DEFAULT_QUOTE_STYLE = QuoteStyle.PREFIX;
private static final String DEFAULT_QUOTE_PREFIX = ">"; private static final String DEFAULT_QUOTE_PREFIX = ">";
private static final boolean DEFAULT_QUOTED_TEXT_SHOWN = true;
private static final boolean DEFAULT_REPLY_AFTER_QUOTE = false; private static final boolean DEFAULT_REPLY_AFTER_QUOTE = false;
/** /**
@ -126,6 +127,7 @@ public class Account implements BaseAccount {
private MessageFormat mMessageFormat; private MessageFormat mMessageFormat;
private QuoteStyle mQuoteStyle; private QuoteStyle mQuoteStyle;
private String mQuotePrefix; private String mQuotePrefix;
private boolean mDefaultQuotedTextShown;
private boolean mReplyAfterQuote; private boolean mReplyAfterQuote;
private boolean mSyncRemoteDeletions; private boolean mSyncRemoteDeletions;
private String mCryptoApp; private String mCryptoApp;
@ -203,6 +205,7 @@ public class Account implements BaseAccount {
mMessageFormat = DEFAULT_MESSAGE_FORMAT; mMessageFormat = DEFAULT_MESSAGE_FORMAT;
mQuoteStyle = DEFAULT_QUOTE_STYLE; mQuoteStyle = DEFAULT_QUOTE_STYLE;
mQuotePrefix = DEFAULT_QUOTE_PREFIX; mQuotePrefix = DEFAULT_QUOTE_PREFIX;
mDefaultQuotedTextShown = DEFAULT_QUOTED_TEXT_SHOWN;
mReplyAfterQuote = DEFAULT_REPLY_AFTER_QUOTE; mReplyAfterQuote = DEFAULT_REPLY_AFTER_QUOTE;
mSyncRemoteDeletions = true; mSyncRemoteDeletions = true;
mCryptoApp = Apg.NAME; mCryptoApp = Apg.NAME;
@ -276,6 +279,7 @@ public class Account implements BaseAccount {
mMessageFormat = MessageFormat.valueOf(prefs.getString(mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT.name())); mMessageFormat = MessageFormat.valueOf(prefs.getString(mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT.name()));
mQuoteStyle = QuoteStyle.valueOf(prefs.getString(mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE.name())); mQuoteStyle = QuoteStyle.valueOf(prefs.getString(mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE.name()));
mQuotePrefix = prefs.getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX); mQuotePrefix = prefs.getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
mDefaultQuotedTextShown = prefs.getBoolean(mUuid + ".defaultQuotedTextShown", DEFAULT_QUOTED_TEXT_SHOWN);
mReplyAfterQuote = prefs.getBoolean(mUuid + ".replyAfterQuote", DEFAULT_REPLY_AFTER_QUOTE); mReplyAfterQuote = prefs.getBoolean(mUuid + ".replyAfterQuote", DEFAULT_REPLY_AFTER_QUOTE);
for (String type : networkTypes) { for (String type : networkTypes) {
Boolean useCompression = prefs.getBoolean(mUuid + ".useCompression." + type, Boolean useCompression = prefs.getBoolean(mUuid + ".useCompression." + type,
@ -527,6 +531,7 @@ public class Account implements BaseAccount {
editor.putString(mUuid + ".messageFormat", mMessageFormat.name()); editor.putString(mUuid + ".messageFormat", mMessageFormat.name());
editor.putString(mUuid + ".quoteStyle", mQuoteStyle.name()); editor.putString(mUuid + ".quoteStyle", mQuoteStyle.name());
editor.putString(mUuid + ".quotePrefix", mQuotePrefix); editor.putString(mUuid + ".quotePrefix", mQuotePrefix);
editor.putBoolean(mUuid + ".defaultQuotedTextShown", mDefaultQuotedTextShown);
editor.putBoolean(mUuid + ".replyAfterQuote", mReplyAfterQuote); editor.putBoolean(mUuid + ".replyAfterQuote", mReplyAfterQuote);
editor.putString(mUuid + ".cryptoApp", mCryptoApp); editor.putString(mUuid + ".cryptoApp", mCryptoApp);
editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature); editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature);
@ -1283,6 +1288,14 @@ public class Account implements BaseAccount {
mQuotePrefix = quotePrefix; mQuotePrefix = quotePrefix;
} }
public synchronized boolean isDefaultQuotedTextShown() {
return mDefaultQuotedTextShown;
}
public synchronized void setDefaultQuotedTextShown(boolean shown) {
mDefaultQuotedTextShown = shown;
}
public synchronized boolean isReplyAfterQuote() { public synchronized boolean isReplyAfterQuote() {
return mReplyAfterQuote; return mReplyAfterQuote;
} }

View File

@ -1966,7 +1966,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
// Quote the message and setup the UI. // Quote the message and setup the UI.
populateUIWithQuotedMessage(); populateUIWithQuotedMessage(mAccount.isDefaultQuotedTextShown());
if (ACTION_REPLY_ALL.equals(action) || ACTION_REPLY.equals(action)) { if (ACTION_REPLY_ALL.equals(action) || ACTION_REPLY.equals(action)) {
Identity useIdentity = null; Identity useIdentity = null;
@ -2021,7 +2021,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
// Quote the message and setup the UI. // Quote the message and setup the UI.
populateUIWithQuotedMessage(); populateUIWithQuotedMessage(true);
if (!mSourceMessageProcessed) { if (!mSourceMessageProcessed) {
if (!loadAttachments(message, 0)) { if (!loadAttachments(message, 0)) {
@ -2218,7 +2218,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* Build and populate the UI with the quoted message. * Build and populate the UI with the quoted message.
* @throws MessagingException * @throws MessagingException
*/ */
private void populateUIWithQuotedMessage() throws MessagingException { private void populateUIWithQuotedMessage(boolean shown) throws MessagingException {
// TODO -- I am assuming that mSourceMessageBody will always be a text part. Is this a safe assumption? // TODO -- I am assuming that mSourceMessageBody will always be a text part. Is this a safe assumption?
// Handle the original message in the reply // Handle the original message in the reply
@ -2232,12 +2232,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// Load the message with the reply header. // Load the message with the reply header.
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null); mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
showOrHideQuotedText(QuotedTextMode.SHOW);
} else if (mMessageFormat == MessageFormat.TEXT) { } else if (mMessageFormat == MessageFormat.TEXT) {
mQuotedText.setText(quoteOriginalTextMessage(mSourceMessage, content, mAccount.getQuoteStyle())); mQuotedText.setText(quoteOriginalTextMessage(mSourceMessage, content, mAccount.getQuoteStyle()));
}
if (shown) {
showOrHideQuotedText(QuotedTextMode.SHOW); showOrHideQuotedText(QuotedTextMode.SHOW);
} }
else {
showOrHideQuotedText(QuotedTextMode.HIDE);
}
} }
/** /**
@ -2448,7 +2452,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// part). // part).
if (mSourceProcessed) { if (mSourceProcessed) {
try { try {
populateUIWithQuotedMessage(); populateUIWithQuotedMessage(true);
} catch (MessagingException e) { } catch (MessagingException e) {
// Hm, if we couldn't populate the UI after source reprocessing, let's just delete it? // Hm, if we couldn't populate the UI after source reprocessing, let's just delete it?
showOrHideQuotedText(QuotedTextMode.HIDE); showOrHideQuotedText(QuotedTextMode.HIDE);

View File

@ -88,6 +88,7 @@ public class AccountSettings extends K9PreferenceActivity {
private static final String PREFERENCE_MESSAGE_FORMAT = "message_format"; private static final String PREFERENCE_MESSAGE_FORMAT = "message_format";
private static final String PREFERENCE_QUOTE_PREFIX = "account_quote_prefix"; private static final String PREFERENCE_QUOTE_PREFIX = "account_quote_prefix";
private static final String PREFERENCE_QUOTE_STYLE = "quote_style"; private static final String PREFERENCE_QUOTE_STYLE = "quote_style";
private static final String PREFERENCE_DEFAULT_QUOTED_TEXT_SHOWN = "default_quoted_text_shown";
private static final String PREFERENCE_REPLY_AFTER_QUOTE = "reply_after_quote"; private static final String PREFERENCE_REPLY_AFTER_QUOTE = "reply_after_quote";
private static final String PREFERENCE_SYNC_REMOTE_DELETIONS = "account_sync_remote_deletetions"; private static final String PREFERENCE_SYNC_REMOTE_DELETIONS = "account_sync_remote_deletetions";
private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; private static final String PREFERENCE_CRYPTO_APP = "crypto_app";
@ -145,6 +146,7 @@ public class AccountSettings extends K9PreferenceActivity {
private ListPreference mMessageFormat; private ListPreference mMessageFormat;
private ListPreference mQuoteStyle; private ListPreference mQuoteStyle;
private EditTextPreference mAccountQuotePrefix; private EditTextPreference mAccountQuotePrefix;
private CheckBoxPreference mAccountDefaultQuotedTextShown;
private CheckBoxPreference mReplyAfterQuote; private CheckBoxPreference mReplyAfterQuote;
private CheckBoxPreference mSyncRemoteDeletions; private CheckBoxPreference mSyncRemoteDeletions;
private CheckBoxPreference mSaveAllHeaders; private CheckBoxPreference mSaveAllHeaders;
@ -226,6 +228,9 @@ public class AccountSettings extends K9PreferenceActivity {
} }
}); });
mAccountDefaultQuotedTextShown = (CheckBoxPreference) findPreference(PREFERENCE_DEFAULT_QUOTED_TEXT_SHOWN);
mAccountDefaultQuotedTextShown.setChecked(mAccount.isDefaultQuotedTextShown());
mReplyAfterQuote = (CheckBoxPreference) findPreference(PREFERENCE_REPLY_AFTER_QUOTE); mReplyAfterQuote = (CheckBoxPreference) findPreference(PREFERENCE_REPLY_AFTER_QUOTE);
mReplyAfterQuote.setChecked(mAccount.isReplyAfterQuote()); mReplyAfterQuote.setChecked(mAccount.isReplyAfterQuote());
@ -695,6 +700,7 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setMessageFormat(Account.MessageFormat.valueOf(mMessageFormat.getValue())); mAccount.setMessageFormat(Account.MessageFormat.valueOf(mMessageFormat.getValue()));
mAccount.setQuoteStyle(QuoteStyle.valueOf(mQuoteStyle.getValue())); mAccount.setQuoteStyle(QuoteStyle.valueOf(mQuoteStyle.getValue()));
mAccount.setQuotePrefix(mAccountQuotePrefix.getText()); mAccount.setQuotePrefix(mAccountQuotePrefix.getText());
mAccount.setDefaultQuotedTextShown(mAccountDefaultQuotedTextShown.isChecked());
mAccount.setReplyAfterQuote(mReplyAfterQuote.isChecked()); mAccount.setReplyAfterQuote(mReplyAfterQuote.isChecked());
mAccount.setCryptoApp(mCryptoApp.getValue()); mAccount.setCryptoApp(mCryptoApp.getValue());
mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked()); mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked());