1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 03:55:04 -05:00

Added option to specify the message quote prefix character/string (default ">"). Applied patch provided by fiouzy (Thanks!) with some small modifications.

Fixes issue 1830
This commit is contained in:
cketti 2010-06-20 14:07:03 +00:00
parent 7f625b5ef4
commit 648e3bd829
5 changed files with 49 additions and 2 deletions

View File

@ -491,6 +491,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_settings_folders">Folders</string> <string name="account_settings_folders">Folders</string>
<string name="account_settings_message_lists">Listing messages</string> <string name="account_settings_message_lists">Listing messages</string>
<string name="account_settings_message_view">Viewing messages</string> <string name="account_settings_message_view">Viewing messages</string>
<string name="account_settings_quote_prefix_label">Quote prefix</string>
<string name="account_settings_mail_check_frequency_label">Folder poll check frequency</string> <string name="account_settings_mail_check_frequency_label">Folder poll check frequency</string>
<string name="account_settings_second_class_check_frequency_label">2nd class check frequency</string> <string name="account_settings_second_class_check_frequency_label">2nd class check frequency</string>

View File

@ -171,6 +171,13 @@
/> />
<EditTextPreference
android:key="account_quote_prefix"
android:singleLine="true"
android:title="@string/account_settings_quote_prefix_label"
android:summary=""
android:dialogTitle="@string/account_settings_quote_prefix_label" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_notifications"> <PreferenceCategory android:title="@string/account_settings_notifications">

View File

@ -44,6 +44,7 @@ public class Account implements BaseAccount
public static final String TYPE_OTHER = "OTHER"; public static final String TYPE_OTHER = "OTHER";
private static String[] networkTypes = { TYPE_WIFI, TYPE_MOBILE, TYPE_OTHER }; private static String[] networkTypes = { TYPE_WIFI, TYPE_MOBILE, TYPE_OTHER };
private static final String DEFAULT_QUOTE_PREFIX = ">";
/** /**
* <pre> * <pre>
@ -97,6 +98,7 @@ public class Account implements BaseAccount
// Tracks if we have sent a notification for this account for // Tracks if we have sent a notification for this account for
// current set of fetched messages // current set of fetched messages
private boolean mRingNotified; private boolean mRingNotified;
private String mQuotePrefix;
private List<Identity> identities; private List<Identity> identities;
@ -146,6 +148,7 @@ public class Account implements BaseAccount
goToUnreadMessageSearch = false; goToUnreadMessageSearch = false;
subscribedFoldersOnly = false; subscribedFoldersOnly = false;
maximumPolledMessageAge = 10; maximumPolledMessageAge = 10;
mQuotePrefix = DEFAULT_QUOTE_PREFIX;
searchableFolders = Searchable.ALL; searchableFolders = Searchable.ALL;
@ -215,6 +218,7 @@ public class Account implements BaseAccount
false); false);
maximumPolledMessageAge = preferences.getPreferences().getInt(mUuid maximumPolledMessageAge = preferences.getPreferences().getInt(mUuid
+ ".maximumPolledMessageAge", -1); + ".maximumPolledMessageAge", -1);
mQuotePrefix = preferences.getPreferences().getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
for (String type : networkTypes) for (String type : networkTypes)
{ {
Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type, Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type,
@ -386,6 +390,7 @@ public class Account implements BaseAccount
editor.remove(mUuid + ".goToUnreadMessageSearch"); editor.remove(mUuid + ".goToUnreadMessageSearch");
editor.remove(mUuid + ".subscribedFoldersOnly"); editor.remove(mUuid + ".subscribedFoldersOnly");
editor.remove(mUuid + ".maximumPolledMessageAge"); editor.remove(mUuid + ".maximumPolledMessageAge");
editor.remove(mUuid + ".quotePrefix");
for (String type : networkTypes) for (String type : networkTypes)
{ {
editor.remove(mUuid + ".useCompression." + type); editor.remove(mUuid + ".useCompression." + type);
@ -471,6 +476,7 @@ public class Account implements BaseAccount
editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch); editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch);
editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly); editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly);
editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge); editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge);
editor.putString(mUuid + ".quotePrefix", mQuotePrefix);
for (String type : networkTypes) for (String type : networkTypes)
{ {
@ -1242,6 +1248,7 @@ public class Account implements BaseAccount
{ {
this.maximumPolledMessageAge = maximumPolledMessageAge; this.maximumPolledMessageAge = maximumPolledMessageAge;
} }
public Date getEarliestPollDate() public Date getEarliestPollDate()
{ {
int age = getMaximumPolledMessageAge(); int age = getMaximumPolledMessageAge();
@ -1282,4 +1289,14 @@ public class Account implements BaseAccount
return null; return null;
} }
} }
public String getQuotePrefix()
{
return mQuotePrefix;
}
public void setQuotePrefix(String quotePrefix)
{
mQuotePrefix = quotePrefix;
}
} }

View File

@ -1343,7 +1343,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
getString(R.string.message_compose_reply_header_fmt), getString(R.string.message_compose_reply_header_fmt),
Address.toString(mSourceMessage.getFrom())); Address.toString(mSourceMessage.getFrom()));
quotedText += MimeUtility.getTextFromPart(part).replaceAll("(?m)^", ">"); final String prefix = mAccount.getQuotePrefix();
// "$" and "\" in the quote prefix have to be escaped for
// the replaceAll() invocation.
final String escapedPrefix = prefix.replaceAll("(\\\\|\\$)", "\\\\$1");
quotedText += MimeUtility.getTextFromPart(part).replaceAll(
"(?m)^", escapedPrefix);
quotedText = quotedText.replaceAll("\\\r", ""); quotedText = quotedText.replaceAll("\\\r", "");
mQuotedText.setText(quotedText); mQuotedText.setText(quotedText);

View File

@ -53,7 +53,7 @@ public class AccountSettings extends K9PreferenceActivity
private static final String PREFERENCE_LED_COLOR = "led_color"; private static final String PREFERENCE_LED_COLOR = "led_color";
private static final String PREFERENCE_NOTIFICATION_OPENS_UNREAD = "notification_opens_unread"; private static final String PREFERENCE_NOTIFICATION_OPENS_UNREAD = "notification_opens_unread";
private static final String PREFERENCE_MESSAGE_AGE = "account_message_age"; private static final String PREFERENCE_MESSAGE_AGE = "account_message_age";
private static final String PREFERENCE_QUOTE_PREFIX = "account_quote_prefix";
private Account mAccount; private Account mAccount;
@ -81,6 +81,7 @@ public class AccountSettings extends K9PreferenceActivity
private Preference mLedColor; private Preference mLedColor;
private boolean mIncomingChanged = false; private boolean mIncomingChanged = false;
private CheckBoxPreference mNotificationOpensUnread; private CheckBoxPreference mNotificationOpensUnread;
private EditTextPreference mAccountQuotePrefix;
public static void actionSettings(Context context, Account account) public static void actionSettings(Context context, Account account)
@ -131,6 +132,20 @@ public class AccountSettings extends K9PreferenceActivity
} }
}); });
mAccountQuotePrefix = (EditTextPreference) findPreference(PREFERENCE_QUOTE_PREFIX);
mAccountQuotePrefix.setSummary(mAccount.getQuotePrefix());
mAccountQuotePrefix.setText(mAccount.getQuotePrefix());
mAccountQuotePrefix.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
final String value = newValue.toString();
mAccountQuotePrefix.setSummary(value);
mAccountQuotePrefix.setText(value);
return false;
}
});
mCheckFrequency = (ListPreference) findPreference(PREFERENCE_FREQUENCY); mCheckFrequency = (ListPreference) findPreference(PREFERENCE_FREQUENCY);
mCheckFrequency.setValue(String.valueOf(mAccount.getAutomaticCheckIntervalMinutes())); mCheckFrequency.setValue(String.valueOf(mAccount.getAutomaticCheckIntervalMinutes()));
@ -441,6 +456,7 @@ public class AccountSettings extends K9PreferenceActivity
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue())); mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
mAccount.setExpungePolicy(mExpungePolicy.getValue()); mAccount.setExpungePolicy(mExpungePolicy.getValue());
mAccount.setSearchableFolders(Account.Searchable.valueOf(mSearchableFolders.getValue())); mAccount.setSearchableFolders(Account.Searchable.valueOf(mSearchableFolders.getValue()));
mAccount.setQuotePrefix(mAccountQuotePrefix.getText());
boolean needsRefresh = mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue())); boolean needsRefresh = mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue()));
needsRefresh |= mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue())); needsRefresh |= mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue()));