mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
Enums instead of int/String constants (#547)
simplify and add logging simplify use == for enum comparison to avoid type mistakes enum name needs to match previous constant simplify Address review comments - formatting, and remove superfluous comment Shorten DeletePolicy values since not used in settings strings; import enums to reduce clutter fix whitespace remove comment per review address review comment review comments remove another superfluous qualification Last changes
This commit is contained in:
parent
24e6b39dc0
commit
ffb4507776
@ -47,6 +47,8 @@ import com.fsck.k9.mail.ssl.LocalKeyStore;
|
|||||||
import com.fsck.k9.view.ColorChip;
|
import com.fsck.k9.view.ColorChip;
|
||||||
import com.larswerkman.colorpicker.ColorPicker;
|
import com.larswerkman.colorpicker.ColorPicker;
|
||||||
|
|
||||||
|
import static com.fsck.k9.Preferences.getEnumStringPref;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account stores all of the settings for a single account defined by the user. It is able to save
|
* Account stores all of the settings for a single account defined by the user. It is able to save
|
||||||
* and delete itself given a Preferences to work with. Each account is defined by a UUID.
|
* and delete itself given a Preferences to work with. Each account is defined by a UUID.
|
||||||
@ -62,19 +64,43 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
*/
|
*/
|
||||||
public static final String OUTBOX = "K9MAIL_INTERNAL_OUTBOX";
|
public static final String OUTBOX = "K9MAIL_INTERNAL_OUTBOX";
|
||||||
|
|
||||||
public static final String EXPUNGE_IMMEDIATELY = "EXPUNGE_IMMEDIATELY";
|
public enum Expunge {
|
||||||
public static final String EXPUNGE_MANUALLY = "EXPUNGE_MANUALLY";
|
EXPUNGE_IMMEDIATELY,
|
||||||
public static final String EXPUNGE_ON_POLL = "EXPUNGE_ON_POLL";
|
EXPUNGE_MANUALLY,
|
||||||
|
EXPUNGE_ON_POLL
|
||||||
|
}
|
||||||
|
|
||||||
public static final int DELETE_POLICY_NEVER = 0;
|
public enum DeletePolicy {
|
||||||
public static final int DELETE_POLICY_7DAYS = 1;
|
NEVER(0),
|
||||||
public static final int DELETE_POLICY_ON_DELETE = 2;
|
SEVEN_DAYS(1),
|
||||||
public static final int DELETE_POLICY_MARK_AS_READ = 3;
|
ON_DELETE(2),
|
||||||
|
MARK_AS_READ(3);
|
||||||
|
|
||||||
public static final String TYPE_WIFI = "WIFI";
|
public final int setting;
|
||||||
public static final String TYPE_MOBILE = "MOBILE";
|
|
||||||
public static final String TYPE_OTHER = "OTHER";
|
DeletePolicy(int setting) {
|
||||||
private static final String[] networkTypes = { TYPE_WIFI, TYPE_MOBILE, TYPE_OTHER };
|
this.setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String preferenceString() {
|
||||||
|
return Integer.toString(setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeletePolicy fromInt(int initialSetting) {
|
||||||
|
for (DeletePolicy policy: values()) {
|
||||||
|
if (policy.setting == initialSetting) {
|
||||||
|
return policy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("DeletePolicy " + initialSetting + " unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum NetworkType {
|
||||||
|
WIFI,
|
||||||
|
MOBILE,
|
||||||
|
OTHER
|
||||||
|
}
|
||||||
|
|
||||||
public static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
|
public static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
|
||||||
public static final boolean DEFAULT_MESSAGE_FORMAT_AUTO = false;
|
public static final boolean DEFAULT_MESSAGE_FORMAT_AUTO = false;
|
||||||
@ -138,16 +164,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
||||||
public static final String NO_OPENPGP_PROVIDER = "";
|
public static final String NO_OPENPGP_PROVIDER = "";
|
||||||
|
|
||||||
|
private DeletePolicy mDeletePolicy = DeletePolicy.NEVER;
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 0 - Never (DELETE_POLICY_NEVER)
|
|
||||||
* 1 - After 7 days (DELETE_POLICY_7DAYS)
|
|
||||||
* 2 - When I delete from inbox (DELETE_POLICY_ON_DELETE)
|
|
||||||
* 3 - Mark as read (DELETE_POLICY_MARK_AS_READ)
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
private int mDeletePolicy;
|
|
||||||
|
|
||||||
private final String mUuid;
|
private final String mUuid;
|
||||||
private String mStoreUri;
|
private String mStoreUri;
|
||||||
@ -186,11 +203,11 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
private Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
|
private Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
|
||||||
private ShowPictures mShowPictures;
|
private ShowPictures mShowPictures;
|
||||||
private boolean mIsSignatureBeforeQuotedText;
|
private boolean mIsSignatureBeforeQuotedText;
|
||||||
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
private Expunge mExpungePolicy = Expunge.EXPUNGE_IMMEDIATELY;
|
||||||
private int mMaxPushFolders;
|
private int mMaxPushFolders;
|
||||||
private int mIdleRefreshMinutes;
|
private int mIdleRefreshMinutes;
|
||||||
private boolean goToUnreadMessageSearch;
|
private boolean goToUnreadMessageSearch;
|
||||||
private final Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
|
private final Map<NetworkType, Boolean> compressionMap = new ConcurrentHashMap<NetworkType, Boolean>();
|
||||||
private Searchable searchableFolders;
|
private Searchable searchableFolders;
|
||||||
private boolean subscribedFoldersOnly;
|
private boolean subscribedFoldersOnly;
|
||||||
private int maximumPolledMessageAge;
|
private int maximumPolledMessageAge;
|
||||||
@ -283,7 +300,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
mSortAscending.put(DEFAULT_SORT_TYPE, DEFAULT_SORT_ASCENDING);
|
mSortAscending.put(DEFAULT_SORT_TYPE, DEFAULT_SORT_ASCENDING);
|
||||||
mShowPictures = ShowPictures.NEVER;
|
mShowPictures = ShowPictures.NEVER;
|
||||||
mIsSignatureBeforeQuotedText = false;
|
mIsSignatureBeforeQuotedText = false;
|
||||||
mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
mExpungePolicy = Expunge.EXPUNGE_IMMEDIATELY;
|
||||||
mAutoExpandFolderName = INBOX;
|
mAutoExpandFolderName = INBOX;
|
||||||
mInboxFolderName = INBOX;
|
mInboxFolderName = INBOX;
|
||||||
mMaxPushFolders = 10;
|
mMaxPushFolders = 10;
|
||||||
@ -379,22 +396,18 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
mLastAutomaticCheckTime = prefs.getLong(mUuid + ".lastAutomaticCheckTime", 0);
|
mLastAutomaticCheckTime = prefs.getLong(mUuid + ".lastAutomaticCheckTime", 0);
|
||||||
mLatestOldMessageSeenTime = prefs.getLong(mUuid + ".latestOldMessageSeenTime", 0);
|
mLatestOldMessageSeenTime = prefs.getLong(mUuid + ".latestOldMessageSeenTime", 0);
|
||||||
mNotifyNewMail = prefs.getBoolean(mUuid + ".notifyNewMail", false);
|
mNotifyNewMail = prefs.getBoolean(mUuid + ".notifyNewMail", false);
|
||||||
try {
|
|
||||||
mFolderNotifyNewMailMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderNotifyNewMailMode",
|
mFolderNotifyNewMailMode = getEnumStringPref(prefs, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
|
||||||
FolderMode.ALL.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mFolderNotifyNewMailMode = FolderMode.ALL;
|
|
||||||
}
|
|
||||||
mNotifySelfNewMail = prefs.getBoolean(mUuid + ".notifySelfNewMail", true);
|
mNotifySelfNewMail = prefs.getBoolean(mUuid + ".notifySelfNewMail", true);
|
||||||
mNotifySync = prefs.getBoolean(mUuid + ".notifyMailCheck", false);
|
mNotifySync = prefs.getBoolean(mUuid + ".notifyMailCheck", false);
|
||||||
mDeletePolicy = prefs.getInt(mUuid + ".deletePolicy", 0);
|
mDeletePolicy = DeletePolicy.fromInt(prefs.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting));
|
||||||
mInboxFolderName = prefs.getString(mUuid + ".inboxFolderName", INBOX);
|
mInboxFolderName = prefs.getString(mUuid + ".inboxFolderName", INBOX);
|
||||||
mDraftsFolderName = prefs.getString(mUuid + ".draftsFolderName", "Drafts");
|
mDraftsFolderName = prefs.getString(mUuid + ".draftsFolderName", "Drafts");
|
||||||
mSentFolderName = prefs.getString(mUuid + ".sentFolderName", "Sent");
|
mSentFolderName = prefs.getString(mUuid + ".sentFolderName", "Sent");
|
||||||
mTrashFolderName = prefs.getString(mUuid + ".trashFolderName", "Trash");
|
mTrashFolderName = prefs.getString(mUuid + ".trashFolderName", "Trash");
|
||||||
mArchiveFolderName = prefs.getString(mUuid + ".archiveFolderName", "Archive");
|
mArchiveFolderName = prefs.getString(mUuid + ".archiveFolderName", "Archive");
|
||||||
mSpamFolderName = prefs.getString(mUuid + ".spamFolderName", "Spam");
|
mSpamFolderName = prefs.getString(mUuid + ".spamFolderName", "Spam");
|
||||||
mExpungePolicy = prefs.getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY);
|
mExpungePolicy = getEnumStringPref(prefs, mUuid + ".expungePolicy", Expunge.EXPUNGE_IMMEDIATELY);
|
||||||
mSyncRemoteDeletions = prefs.getBoolean(mUuid + ".syncRemoteDeletions", true);
|
mSyncRemoteDeletions = prefs.getBoolean(mUuid + ".syncRemoteDeletions", true);
|
||||||
|
|
||||||
mMaxPushFolders = prefs.getInt(mUuid + ".maxPushFolders", 10);
|
mMaxPushFolders = prefs.getInt(mUuid + ".maxPushFolders", 10);
|
||||||
@ -402,18 +415,18 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
subscribedFoldersOnly = prefs.getBoolean(mUuid + ".subscribedFoldersOnly", false);
|
subscribedFoldersOnly = prefs.getBoolean(mUuid + ".subscribedFoldersOnly", false);
|
||||||
maximumPolledMessageAge = prefs.getInt(mUuid + ".maximumPolledMessageAge", -1);
|
maximumPolledMessageAge = prefs.getInt(mUuid + ".maximumPolledMessageAge", -1);
|
||||||
maximumAutoDownloadMessageSize = prefs.getInt(mUuid + ".maximumAutoDownloadMessageSize", 32768);
|
maximumAutoDownloadMessageSize = prefs.getInt(mUuid + ".maximumAutoDownloadMessageSize", 32768);
|
||||||
mMessageFormat = MessageFormat.valueOf(prefs.getString(mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT.name()));
|
mMessageFormat = getEnumStringPref(prefs, mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT);
|
||||||
mMessageFormatAuto = prefs.getBoolean(mUuid + ".messageFormatAuto", DEFAULT_MESSAGE_FORMAT_AUTO);
|
mMessageFormatAuto = prefs.getBoolean(mUuid + ".messageFormatAuto", DEFAULT_MESSAGE_FORMAT_AUTO);
|
||||||
if (mMessageFormatAuto && mMessageFormat == MessageFormat.TEXT) {
|
if (mMessageFormatAuto && mMessageFormat == MessageFormat.TEXT) {
|
||||||
mMessageFormat = MessageFormat.AUTO;
|
mMessageFormat = MessageFormat.AUTO;
|
||||||
}
|
}
|
||||||
mMessageReadReceipt = prefs.getBoolean(mUuid + ".messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT);
|
mMessageReadReceipt = prefs.getBoolean(mUuid + ".messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT);
|
||||||
mQuoteStyle = QuoteStyle.valueOf(prefs.getString(mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE.name()));
|
mQuoteStyle = getEnumStringPref(prefs, mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE);
|
||||||
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);
|
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);
|
||||||
mStripSignature = prefs.getBoolean(mUuid + ".stripSignature", DEFAULT_STRIP_SIGNATURE);
|
mStripSignature = prefs.getBoolean(mUuid + ".stripSignature", DEFAULT_STRIP_SIGNATURE);
|
||||||
for (String type : networkTypes) {
|
for (NetworkType type : NetworkType.values()) {
|
||||||
Boolean useCompression = prefs.getBoolean(mUuid + ".useCompression." + type,
|
Boolean useCompression = prefs.getBoolean(mUuid + ".useCompression." + type,
|
||||||
true);
|
true);
|
||||||
compressionMap.put(type, useCompression);
|
compressionMap.put(type, useCompression);
|
||||||
@ -425,21 +438,11 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
|
|
||||||
mChipColor = prefs.getInt(mUuid + ".chipColor", ColorPicker.getRandomColor());
|
mChipColor = prefs.getInt(mUuid + ".chipColor", ColorPicker.getRandomColor());
|
||||||
|
|
||||||
try {
|
mSortType = getEnumStringPref(prefs, mUuid + ".sortTypeEnum", SortType.SORT_DATE);
|
||||||
mSortType = SortType.valueOf(prefs.getString(mUuid + ".sortTypeEnum",
|
|
||||||
SortType.SORT_DATE.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mSortType = SortType.SORT_DATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
mSortAscending.put(mSortType, prefs.getBoolean(mUuid + ".sortAscending", false));
|
mSortAscending.put(mSortType, prefs.getBoolean(mUuid + ".sortAscending", false));
|
||||||
|
|
||||||
try {
|
mShowPictures = getEnumStringPref(prefs, mUuid + ".showPicturesEnum", ShowPictures.NEVER);
|
||||||
mShowPictures = ShowPictures.valueOf(prefs.getString(mUuid + ".showPicturesEnum",
|
|
||||||
ShowPictures.NEVER.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mShowPictures = ShowPictures.NEVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
mNotificationSetting.setVibrate(prefs.getBoolean(mUuid + ".vibrate", false));
|
mNotificationSetting.setVibrate(prefs.getBoolean(mUuid + ".vibrate", false));
|
||||||
mNotificationSetting.setVibratePattern(prefs.getInt(mUuid + ".vibratePattern", 0));
|
mNotificationSetting.setVibratePattern(prefs.getInt(mUuid + ".vibratePattern", 0));
|
||||||
@ -450,40 +453,15 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
mNotificationSetting.setLed(prefs.getBoolean(mUuid + ".led", true));
|
mNotificationSetting.setLed(prefs.getBoolean(mUuid + ".led", true));
|
||||||
mNotificationSetting.setLedColor(prefs.getInt(mUuid + ".ledColor", mChipColor));
|
mNotificationSetting.setLedColor(prefs.getInt(mUuid + ".ledColor", mChipColor));
|
||||||
|
|
||||||
try {
|
mFolderDisplayMode = getEnumStringPref(prefs, mUuid + ".folderDisplayMode", FolderMode.NOT_SECOND_CLASS);
|
||||||
mFolderDisplayMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderDisplayMode",
|
|
||||||
FolderMode.NOT_SECOND_CLASS.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
mFolderSyncMode = getEnumStringPref(prefs, mUuid + ".folderSyncMode", FolderMode.FIRST_CLASS);
|
||||||
mFolderSyncMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderSyncMode",
|
|
||||||
FolderMode.FIRST_CLASS.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
mFolderPushMode = getEnumStringPref(prefs, mUuid + ".folderPushMode", FolderMode.FIRST_CLASS);
|
||||||
mFolderPushMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderPushMode",
|
|
||||||
FolderMode.FIRST_CLASS.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mFolderPushMode = FolderMode.FIRST_CLASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
mFolderTargetMode = getEnumStringPref(prefs, mUuid + ".folderTargetMode", FolderMode.NOT_SECOND_CLASS);
|
||||||
mFolderTargetMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderTargetMode",
|
|
||||||
FolderMode.NOT_SECOND_CLASS.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
searchableFolders = getEnumStringPref(prefs, mUuid + ".searchableFolders", Searchable.ALL);
|
||||||
searchableFolders = Searchable.valueOf(prefs.getString(mUuid + ".searchableFolders",
|
|
||||||
Searchable.ALL.name()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
searchableFolders = Searchable.ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
mIsSignatureBeforeQuotedText = prefs.getBoolean(mUuid + ".signatureBeforeQuotedText", false);
|
mIsSignatureBeforeQuotedText = prefs.getBoolean(mUuid + ".signatureBeforeQuotedText", false);
|
||||||
identities = loadIdentities(prefs);
|
identities = loadIdentities(prefs);
|
||||||
@ -591,8 +569,8 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
editor.remove(mUuid + ".messageFormat");
|
editor.remove(mUuid + ".messageFormat");
|
||||||
editor.remove(mUuid + ".messageReadReceipt");
|
editor.remove(mUuid + ".messageReadReceipt");
|
||||||
editor.remove(mUuid + ".notifyMailCheck");
|
editor.remove(mUuid + ".notifyMailCheck");
|
||||||
for (String type : networkTypes) {
|
for (NetworkType type : NetworkType.values()) {
|
||||||
editor.remove(mUuid + ".useCompression." + type);
|
editor.remove(mUuid + ".useCompression." + type.name());
|
||||||
}
|
}
|
||||||
deleteIdentities(preferences.getPreferences(), editor);
|
deleteIdentities(preferences.getPreferences(), editor);
|
||||||
// TODO: Remove preference settings that may exist for individual
|
// TODO: Remove preference settings that may exist for individual
|
||||||
@ -707,7 +685,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name());
|
editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name());
|
||||||
editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail);
|
editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail);
|
||||||
editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync);
|
editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync);
|
||||||
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy);
|
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy.setting);
|
||||||
editor.putString(mUuid + ".inboxFolderName", mInboxFolderName);
|
editor.putString(mUuid + ".inboxFolderName", mInboxFolderName);
|
||||||
editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
|
editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
|
||||||
editor.putString(mUuid + ".sentFolderName", mSentFolderName);
|
editor.putString(mUuid + ".sentFolderName", mSentFolderName);
|
||||||
@ -724,7 +702,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
editor.putString(mUuid + ".folderPushMode", mFolderPushMode.name());
|
editor.putString(mUuid + ".folderPushMode", mFolderPushMode.name());
|
||||||
editor.putString(mUuid + ".folderTargetMode", mFolderTargetMode.name());
|
editor.putString(mUuid + ".folderTargetMode", mFolderTargetMode.name());
|
||||||
editor.putBoolean(mUuid + ".signatureBeforeQuotedText", this.mIsSignatureBeforeQuotedText);
|
editor.putBoolean(mUuid + ".signatureBeforeQuotedText", this.mIsSignatureBeforeQuotedText);
|
||||||
editor.putString(mUuid + ".expungePolicy", mExpungePolicy);
|
editor.putString(mUuid + ".expungePolicy", mExpungePolicy.name());
|
||||||
editor.putBoolean(mUuid + ".syncRemoteDeletions", mSyncRemoteDeletions);
|
editor.putBoolean(mUuid + ".syncRemoteDeletions", mSyncRemoteDeletions);
|
||||||
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
|
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
|
||||||
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
|
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
|
||||||
@ -765,7 +743,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
editor.putBoolean(mUuid + ".led", mNotificationSetting.isLed());
|
editor.putBoolean(mUuid + ".led", mNotificationSetting.isLed());
|
||||||
editor.putInt(mUuid + ".ledColor", mNotificationSetting.getLedColor());
|
editor.putInt(mUuid + ".ledColor", mNotificationSetting.getLedColor());
|
||||||
|
|
||||||
for (String type : networkTypes) {
|
for (NetworkType type : NetworkType.values()) {
|
||||||
Boolean useCompression = compressionMap.get(type);
|
Boolean useCompression = compressionMap.get(type);
|
||||||
if (useCompression != null) {
|
if (useCompression != null) {
|
||||||
editor.putBoolean(mUuid + ".useCompression." + type, useCompression);
|
editor.putBoolean(mUuid + ".useCompression." + type, useCompression);
|
||||||
@ -1056,11 +1034,11 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
this.mFolderNotifyNewMailMode = folderNotifyNewMailMode;
|
this.mFolderNotifyNewMailMode = folderNotifyNewMailMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getDeletePolicy() {
|
public synchronized DeletePolicy getDeletePolicy() {
|
||||||
return mDeletePolicy;
|
return mDeletePolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setDeletePolicy(int deletePolicy) {
|
public synchronized void setDeletePolicy(DeletePolicy deletePolicy) {
|
||||||
this.mDeletePolicy = deletePolicy;
|
this.mDeletePolicy = deletePolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1273,11 +1251,11 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
mNotifySelfNewMail = notifySelfNewMail;
|
mNotifySelfNewMail = notifySelfNewMail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String getExpungePolicy() {
|
public synchronized Expunge getExpungePolicy() {
|
||||||
return mExpungePolicy;
|
return mExpungePolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setExpungePolicy(String expungePolicy) {
|
public synchronized void setExpungePolicy(Expunge expungePolicy) {
|
||||||
mExpungePolicy = expungePolicy;
|
mExpungePolicy = expungePolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1312,11 +1290,11 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
return mDescription;
|
return mDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setCompression(String networkType, boolean useCompression) {
|
public synchronized void setCompression(NetworkType networkType, boolean useCompression) {
|
||||||
compressionMap.put(networkType, useCompression);
|
compressionMap.put(networkType, useCompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean useCompression(String networkType) {
|
public synchronized boolean useCompression(NetworkType networkType) {
|
||||||
Boolean useCompression = compressionMap.get(networkType);
|
Boolean useCompression = compressionMap.get(networkType);
|
||||||
if (useCompression == null) {
|
if (useCompression == null) {
|
||||||
return true;
|
return true;
|
||||||
@ -1326,13 +1304,13 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean useCompression(int type) {
|
public boolean useCompression(int type) {
|
||||||
String networkType = TYPE_OTHER;
|
NetworkType networkType = NetworkType.OTHER;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ConnectivityManager.TYPE_MOBILE:
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
networkType = TYPE_MOBILE;
|
networkType = NetworkType.MOBILE;
|
||||||
break;
|
break;
|
||||||
case ConnectivityManager.TYPE_WIFI:
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
networkType = TYPE_WIFI;
|
networkType = NetworkType.WIFI;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return useCompression(networkType);
|
return useCompression(networkType);
|
||||||
|
@ -70,6 +70,7 @@ public class Preferences {
|
|||||||
/**
|
/**
|
||||||
* Returns an array of the accounts on the system. If no accounts are
|
* Returns an array of the accounts on the system. If no accounts are
|
||||||
* registered the method returns an empty array.
|
* registered the method returns an empty array.
|
||||||
|
*
|
||||||
* @return all accounts
|
* @return all accounts
|
||||||
*/
|
*/
|
||||||
public synchronized List<Account> getAccounts() {
|
public synchronized List<Account> getAccounts() {
|
||||||
@ -83,6 +84,7 @@ public class Preferences {
|
|||||||
/**
|
/**
|
||||||
* Returns an array of the accounts on the system. If no accounts are
|
* Returns an array of the accounts on the system. If no accounts are
|
||||||
* registered the method returns an empty array.
|
* registered the method returns an empty array.
|
||||||
|
*
|
||||||
* @return all accounts with {@link Account#isAvailable(Context)}
|
* @return all accounts with {@link Account#isAvailable(Context)}
|
||||||
*/
|
*/
|
||||||
public synchronized Collection<Account> getAvailableAccounts() {
|
public synchronized Collection<Account> getAvailableAccounts() {
|
||||||
@ -164,4 +166,21 @@ public class Preferences {
|
|||||||
public SharedPreferences getPreferences() {
|
public SharedPreferences getPreferences() {
|
||||||
return mStorage;
|
return mStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends Enum<T>> T getEnumStringPref(SharedPreferences prefs, String key, T defaultEnum) {
|
||||||
|
String stringPref = prefs.getString(key, null);
|
||||||
|
|
||||||
|
if (stringPref == null) {
|
||||||
|
return defaultEnum;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return Enum.valueOf(defaultEnum.getDeclaringClass(), stringPref);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
Log.w(K9.LOG_TAG, "Unable to convert preference key [" + key +
|
||||||
|
"] value [" + stringPref + "] to enum of type " + defaultEnum.getDeclaringClass(), ex);
|
||||||
|
|
||||||
|
return defaultEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,13 @@ import android.preference.RingtonePreference;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
|
import com.fsck.k9.Account.DeletePolicy;
|
||||||
|
import com.fsck.k9.Account.Expunge;
|
||||||
import com.fsck.k9.Account.FolderMode;
|
import com.fsck.k9.Account.FolderMode;
|
||||||
|
import com.fsck.k9.Account.MessageFormat;
|
||||||
import com.fsck.k9.Account.QuoteStyle;
|
import com.fsck.k9.Account.QuoteStyle;
|
||||||
|
import com.fsck.k9.Account.Searchable;
|
||||||
|
import com.fsck.k9.Account.ShowPictures;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.NotificationSetting;
|
import com.fsck.k9.NotificationSetting;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
@ -353,9 +358,9 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
|
|
||||||
mDeletePolicy = (ListPreference) findPreference(PREFERENCE_DELETE_POLICY);
|
mDeletePolicy = (ListPreference) findPreference(PREFERENCE_DELETE_POLICY);
|
||||||
if (!mIsSeenFlagSupported) {
|
if (!mIsSeenFlagSupported) {
|
||||||
removeListEntry(mDeletePolicy, Integer.toString(Account.DELETE_POLICY_MARK_AS_READ));
|
removeListEntry(mDeletePolicy, DeletePolicy.MARK_AS_READ.preferenceString());
|
||||||
}
|
}
|
||||||
mDeletePolicy.setValue(Integer.toString(mAccount.getDeletePolicy()));
|
mDeletePolicy.setValue(mAccount.getDeletePolicy().preferenceString());
|
||||||
mDeletePolicy.setSummary(mDeletePolicy.getEntry());
|
mDeletePolicy.setSummary(mDeletePolicy.getEntry());
|
||||||
mDeletePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mDeletePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
@ -370,7 +375,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
|
|
||||||
mExpungePolicy = (ListPreference) findPreference(PREFERENCE_EXPUNGE_POLICY);
|
mExpungePolicy = (ListPreference) findPreference(PREFERENCE_EXPUNGE_POLICY);
|
||||||
if (mIsExpungeCapable) {
|
if (mIsExpungeCapable) {
|
||||||
mExpungePolicy.setValue(mAccount.getExpungePolicy());
|
mExpungePolicy.setValue(mAccount.getExpungePolicy().name());
|
||||||
mExpungePolicy.setSummary(mExpungePolicy.getEntry());
|
mExpungePolicy.setSummary(mExpungePolicy.getEntry());
|
||||||
mExpungePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mExpungePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
@ -729,7 +734,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
mAccount.setDescription(mAccountDescription.getText());
|
mAccount.setDescription(mAccountDescription.getText());
|
||||||
mAccount.setMarkMessageAsReadOnView(mMarkMessageAsReadOnView.isChecked());
|
mAccount.setMarkMessageAsReadOnView(mMarkMessageAsReadOnView.isChecked());
|
||||||
mAccount.setNotifyNewMail(mAccountNotify.isChecked());
|
mAccount.setNotifyNewMail(mAccountNotify.isChecked());
|
||||||
mAccount.setFolderNotifyNewMailMode(Account.FolderMode.valueOf(mAccountNotifyNewMailMode.getValue()));
|
mAccount.setFolderNotifyNewMailMode(FolderMode.valueOf(mAccountNotifyNewMailMode.getValue()));
|
||||||
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
|
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
|
||||||
mAccount.setShowOngoing(mAccountNotifySync.isChecked());
|
mAccount.setShowOngoing(mAccountNotifySync.isChecked());
|
||||||
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
||||||
@ -742,14 +747,14 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue()));
|
mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue()));
|
||||||
mAccount.getNotificationSetting().setLed(mAccountLed.isChecked());
|
mAccount.getNotificationSetting().setLed(mAccountLed.isChecked());
|
||||||
mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
|
mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
|
||||||
mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue()));
|
mAccount.setFolderTargetMode(FolderMode.valueOf(mTargetMode.getValue()));
|
||||||
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
|
mAccount.setDeletePolicy(DeletePolicy.fromInt(Integer.parseInt(mDeletePolicy.getValue())));
|
||||||
if (mIsExpungeCapable) {
|
if (mIsExpungeCapable) {
|
||||||
mAccount.setExpungePolicy(mExpungePolicy.getValue());
|
mAccount.setExpungePolicy(Expunge.valueOf(mExpungePolicy.getValue()));
|
||||||
}
|
}
|
||||||
mAccount.setSyncRemoteDeletions(mSyncRemoteDeletions.isChecked());
|
mAccount.setSyncRemoteDeletions(mSyncRemoteDeletions.isChecked());
|
||||||
mAccount.setSearchableFolders(Account.Searchable.valueOf(mSearchableFolders.getValue()));
|
mAccount.setSearchableFolders(Searchable.valueOf(mSearchableFolders.getValue()));
|
||||||
mAccount.setMessageFormat(Account.MessageFormat.valueOf(mMessageFormat.getValue()));
|
mAccount.setMessageFormat(MessageFormat.valueOf(mMessageFormat.getValue()));
|
||||||
mAccount.setAlwaysShowCcBcc(mAlwaysShowCcBcc.isChecked());
|
mAccount.setAlwaysShowCcBcc(mAlwaysShowCcBcc.isChecked());
|
||||||
mAccount.setMessageReadReceipt(mMessageReadReceipt.isChecked());
|
mAccount.setMessageReadReceipt(mMessageReadReceipt.isChecked());
|
||||||
mAccount.setQuoteStyle(QuoteStyle.valueOf(mQuoteStyle.getValue()));
|
mAccount.setQuoteStyle(QuoteStyle.valueOf(mQuoteStyle.getValue()));
|
||||||
@ -788,9 +793,9 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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(FolderMode.valueOf(mSyncMode.getValue()));
|
||||||
|
|
||||||
boolean displayModeChanged = mAccount.setFolderDisplayMode(Account.FolderMode.valueOf(mDisplayMode.getValue()));
|
boolean displayModeChanged = mAccount.setFolderDisplayMode(FolderMode.valueOf(mDisplayMode.getValue()));
|
||||||
|
|
||||||
SharedPreferences prefs = mAccountRingtone.getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = mAccountRingtone.getPreferenceManager().getSharedPreferences();
|
||||||
String newRingtone = prefs.getString(PREFERENCE_RINGTONE, null);
|
String newRingtone = prefs.getString(PREFERENCE_RINGTONE, null);
|
||||||
@ -803,11 +808,11 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mAccount.setShowPictures(Account.ShowPictures.valueOf(mAccountShowPictures.getValue()));
|
mAccount.setShowPictures(ShowPictures.valueOf(mAccountShowPictures.getValue()));
|
||||||
|
|
||||||
//IMAP specific stuff
|
//IMAP specific stuff
|
||||||
if (mIsPushCapable) {
|
if (mIsPushCapable) {
|
||||||
boolean needsPushRestart = mAccount.setFolderPushMode(Account.FolderMode.valueOf(mPushMode.getValue()));
|
boolean needsPushRestart = mAccount.setFolderPushMode(FolderMode.valueOf(mPushMode.getValue()));
|
||||||
if (mAccount.getFolderPushMode() != FolderMode.NONE) {
|
if (mAccount.getFolderPushMode() != FolderMode.NONE) {
|
||||||
needsPushRestart |= displayModeChanged;
|
needsPushRestart |= displayModeChanged;
|
||||||
needsPushRestart |= mIncomingChanged;
|
needsPushRestart |= mIncomingChanged;
|
||||||
|
@ -27,6 +27,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
|
import com.fsck.k9.Account.DeletePolicy;
|
||||||
import com.fsck.k9.EmailAddressValidator;
|
import com.fsck.k9.EmailAddressValidator;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
@ -331,9 +332,9 @@ public class AccountSetupBasics extends K9Activity
|
|||||||
}
|
}
|
||||||
mAccount.setSentFolderName(getString(R.string.special_mailbox_name_sent));
|
mAccount.setSentFolderName(getString(R.string.special_mailbox_name_sent));
|
||||||
if (incomingUri.toString().startsWith("imap")) {
|
if (incomingUri.toString().startsWith("imap")) {
|
||||||
mAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE);
|
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
|
||||||
} else if (incomingUri.toString().startsWith("pop3")) {
|
} else if (incomingUri.toString().startsWith("pop3")) {
|
||||||
mAccount.setDeletePolicy(Account.DELETE_POLICY_NEVER);
|
mAccount.setDeletePolicy(DeletePolicy.NEVER);
|
||||||
}
|
}
|
||||||
// Check incoming here. Then check outgoing in onActivityResult()
|
// Check incoming here. Then check outgoing in onActivityResult()
|
||||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
|
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
|
||||||
|
@ -16,7 +16,9 @@ import android.widget.AdapterView.OnItemSelectedListener;
|
|||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
|
||||||
import com.fsck.k9.*;
|
import com.fsck.k9.*;
|
||||||
|
import com.fsck.k9.Account.DeletePolicy;
|
||||||
import com.fsck.k9.Account.FolderMode;
|
import com.fsck.k9.Account.FolderMode;
|
||||||
|
import com.fsck.k9.Account.NetworkType;
|
||||||
import com.fsck.k9.activity.K9Activity;
|
import com.fsck.k9.activity.K9Activity;
|
||||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
@ -200,7 +202,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||||||
findViewById(R.id.compression_section).setVisibility(View.GONE);
|
findViewById(R.id.compression_section).setVisibility(View.GONE);
|
||||||
findViewById(R.id.compression_label).setVisibility(View.GONE);
|
findViewById(R.id.compression_label).setVisibility(View.GONE);
|
||||||
mSubscribedFoldersOnly.setVisibility(View.GONE);
|
mSubscribedFoldersOnly.setVisibility(View.GONE);
|
||||||
mAccount.setDeletePolicy(Account.DELETE_POLICY_NEVER);
|
mAccount.setDeletePolicy(DeletePolicy.NEVER);
|
||||||
} else if (ImapStore.STORE_TYPE.equals(settings.type)) {
|
} else if (ImapStore.STORE_TYPE.equals(settings.type)) {
|
||||||
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
|
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
|
||||||
mDefaultPort = IMAP_PORT;
|
mDefaultPort = IMAP_PORT;
|
||||||
@ -217,7 +219,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||||||
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
|
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
|
||||||
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
|
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
|
||||||
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
|
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
|
||||||
mAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE);
|
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
|
||||||
|
|
||||||
if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
|
||||||
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
|
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
|
||||||
@ -251,7 +253,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||||||
if (webDavSettings.mailboxPath != null) {
|
if (webDavSettings.mailboxPath != null) {
|
||||||
mWebdavMailboxPathView.setText(webDavSettings.mailboxPath);
|
mWebdavMailboxPathView.setText(webDavSettings.mailboxPath);
|
||||||
}
|
}
|
||||||
mAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE);
|
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown account type: " + mAccount.getStoreUri());
|
throw new Exception("Unknown account type: " + mAccount.getStoreUri());
|
||||||
}
|
}
|
||||||
@ -280,9 +282,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
updateAuthPlainTextFromSecurityType(settings.connectionSecurity);
|
updateAuthPlainTextFromSecurityType(settings.connectionSecurity);
|
||||||
|
|
||||||
mCompressionMobile.setChecked(mAccount.useCompression(Account.TYPE_MOBILE));
|
mCompressionMobile.setChecked(mAccount.useCompression(NetworkType.MOBILE));
|
||||||
mCompressionWifi.setChecked(mAccount.useCompression(Account.TYPE_WIFI));
|
mCompressionWifi.setChecked(mAccount.useCompression(NetworkType.WIFI));
|
||||||
mCompressionOther.setChecked(mAccount.useCompression(Account.TYPE_OTHER));
|
mCompressionOther.setChecked(mAccount.useCompression(NetworkType.OTHER));
|
||||||
|
|
||||||
if (settings.host != null) {
|
if (settings.host != null) {
|
||||||
mServerView.setText(settings.host);
|
mServerView.setText(settings.host);
|
||||||
@ -607,9 +609,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
mAccount.setStoreUri(RemoteStore.createStoreUri(settings));
|
mAccount.setStoreUri(RemoteStore.createStoreUri(settings));
|
||||||
|
|
||||||
mAccount.setCompression(Account.TYPE_MOBILE, mCompressionMobile.isChecked());
|
mAccount.setCompression(NetworkType.MOBILE, mCompressionMobile.isChecked());
|
||||||
mAccount.setCompression(Account.TYPE_WIFI, mCompressionWifi.isChecked());
|
mAccount.setCompression(NetworkType.WIFI, mCompressionWifi.isChecked());
|
||||||
mAccount.setCompression(Account.TYPE_OTHER, mCompressionOther.isChecked());
|
mAccount.setCompression(NetworkType.OTHER, mCompressionOther.isChecked());
|
||||||
mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());
|
mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());
|
||||||
|
|
||||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
|
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
|
||||||
|
@ -42,6 +42,8 @@ import android.text.style.TextAppearanceSpan;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
|
import com.fsck.k9.Account.DeletePolicy;
|
||||||
|
import com.fsck.k9.Account.Expunge;
|
||||||
import com.fsck.k9.AccountStats;
|
import com.fsck.k9.AccountStats;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.K9.NotificationHideSubject;
|
import com.fsck.k9.K9.NotificationHideSubject;
|
||||||
@ -1007,7 +1009,7 @@ public class MessagingController implements Runnable {
|
|||||||
Log.v(K9.LOG_TAG, "SYNC: About to open remote folder " + folder);
|
Log.v(K9.LOG_TAG, "SYNC: About to open remote folder " + folder);
|
||||||
|
|
||||||
remoteFolder.open(Folder.OPEN_MODE_RW);
|
remoteFolder.open(Folder.OPEN_MODE_RW);
|
||||||
if (Account.EXPUNGE_ON_POLL.equals(account.getExpungePolicy())) {
|
if (Expunge.EXPUNGE_ON_POLL == account.getExpungePolicy()) {
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
Log.d(K9.LOG_TAG, "SYNC: Expunging folder " + account.getDescription() + ":" + folder);
|
Log.d(K9.LOG_TAG, "SYNC: Expunging folder " + account.getDescription() + ":" + folder);
|
||||||
remoteFolder.expunge();
|
remoteFolder.expunge();
|
||||||
@ -2124,7 +2126,7 @@ public class MessagingController implements Runnable {
|
|||||||
}
|
}
|
||||||
if (remoteDate != null) {
|
if (remoteDate != null) {
|
||||||
remoteMessage.setFlag(Flag.DELETED, true);
|
remoteMessage.setFlag(Flag.DELETED, true);
|
||||||
if (Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
|
if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
|
||||||
remoteFolder.expunge();
|
remoteFolder.expunge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2301,7 +2303,7 @@ public class MessagingController implements Runnable {
|
|||||||
remoteUidMap = remoteSrcFolder.moveMessages(messages, remoteDestFolder);
|
remoteUidMap = remoteSrcFolder.moveMessages(messages, remoteDestFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isCopy && Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
|
if (!isCopy && Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
Log.i(K9.LOG_TAG, "processingPendingMoveOrCopy expunging folder " + account.getDescription() + ":" + srcFolder);
|
Log.i(K9.LOG_TAG, "processingPendingMoveOrCopy expunging folder " + account.getDescription() + ":" + srcFolder);
|
||||||
|
|
||||||
@ -4088,14 +4090,14 @@ public class MessagingController implements Runnable {
|
|||||||
queuePendingCommand(account, command);
|
queuePendingCommand(account, command);
|
||||||
}
|
}
|
||||||
processPendingCommands(account);
|
processPendingCommands(account);
|
||||||
} else if (account.getDeletePolicy() == Account.DELETE_POLICY_ON_DELETE) {
|
} else if (account.getDeletePolicy() == DeletePolicy.ON_DELETE) {
|
||||||
if (folder.equals(account.getTrashFolderName())) {
|
if (folder.equals(account.getTrashFolderName())) {
|
||||||
queueSetFlag(account, folder, Boolean.toString(true), Flag.DELETED.toString(), uids);
|
queueSetFlag(account, folder, Boolean.toString(true), Flag.DELETED.toString(), uids);
|
||||||
} else {
|
} else {
|
||||||
queueMoveOrCopy(account, folder, account.getTrashFolderName(), false, uids, uidMap);
|
queueMoveOrCopy(account, folder, account.getTrashFolderName(), false, uids, uidMap);
|
||||||
}
|
}
|
||||||
processPendingCommands(account);
|
processPendingCommands(account);
|
||||||
} else if (account.getDeletePolicy() == Account.DELETE_POLICY_MARK_AS_READ) {
|
} else if (account.getDeletePolicy() == DeletePolicy.MARK_AS_READ) {
|
||||||
queueSetFlag(account, folder, Boolean.toString(true), Flag.SEEN.toString(), uids);
|
queueSetFlag(account, folder, Boolean.toString(true), Flag.SEEN.toString(), uids);
|
||||||
processPendingCommands(account);
|
processPendingCommands(account);
|
||||||
} else {
|
} else {
|
||||||
@ -4133,7 +4135,7 @@ public class MessagingController implements Runnable {
|
|||||||
if (remoteFolder.exists()) {
|
if (remoteFolder.exists()) {
|
||||||
remoteFolder.open(Folder.OPEN_MODE_RW);
|
remoteFolder.open(Folder.OPEN_MODE_RW);
|
||||||
remoteFolder.setFlags(Collections.singleton(Flag.DELETED), true);
|
remoteFolder.setFlags(Collections.singleton(Flag.DELETED), true);
|
||||||
if (Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
|
if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
|
||||||
remoteFolder.expunge();
|
remoteFolder.expunge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,16 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
|
import com.fsck.k9.Account.DeletePolicy;
|
||||||
|
import com.fsck.k9.Account.Expunge;
|
||||||
|
import com.fsck.k9.Account.FolderMode;
|
||||||
|
import com.fsck.k9.Account.MessageFormat;
|
||||||
|
import com.fsck.k9.Account.QuoteStyle;
|
||||||
|
import com.fsck.k9.Account.Searchable;
|
||||||
|
import com.fsck.k9.Account.ShowPictures;
|
||||||
import com.fsck.k9.Account.SortType;
|
import com.fsck.k9.Account.SortType;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.Account.FolderMode;
|
|
||||||
import com.fsck.k9.mailstore.StorageManager;
|
import com.fsck.k9.mailstore.StorageManager;
|
||||||
import com.fsck.k9.preferences.Settings.*;
|
import com.fsck.k9.preferences.Settings.*;
|
||||||
|
|
||||||
@ -56,7 +62,7 @@ public class AccountSettings {
|
|||||||
new V(1, new BooleanSetting(Account.DEFAULT_QUOTED_TEXT_SHOWN))
|
new V(1, new BooleanSetting(Account.DEFAULT_QUOTED_TEXT_SHOWN))
|
||||||
));
|
));
|
||||||
s.put("deletePolicy", Settings.versions(
|
s.put("deletePolicy", Settings.versions(
|
||||||
new V(1, new DeletePolicySetting(Account.DELETE_POLICY_NEVER))
|
new V(1, new DeletePolicySetting(DeletePolicy.NEVER))
|
||||||
));
|
));
|
||||||
s.put("displayCount", Settings.versions(
|
s.put("displayCount", Settings.versions(
|
||||||
new V(1, new IntegerResourceSetting(K9.DEFAULT_VISIBLE_LIMIT,
|
new V(1, new IntegerResourceSetting(K9.DEFAULT_VISIBLE_LIMIT,
|
||||||
@ -66,7 +72,7 @@ public class AccountSettings {
|
|||||||
new V(1, new StringSetting("Drafts"))
|
new V(1, new StringSetting("Drafts"))
|
||||||
));
|
));
|
||||||
s.put("expungePolicy", Settings.versions(
|
s.put("expungePolicy", Settings.versions(
|
||||||
new V(1, new StringResourceSetting(Account.EXPUNGE_IMMEDIATELY,
|
new V(1, new StringResourceSetting(Expunge.EXPUNGE_IMMEDIATELY.name(),
|
||||||
R.array.account_setup_expunge_policy_values))
|
R.array.account_setup_expunge_policy_values))
|
||||||
));
|
));
|
||||||
s.put("folderDisplayMode", Settings.versions(
|
s.put("folderDisplayMode", Settings.versions(
|
||||||
@ -114,8 +120,8 @@ public class AccountSettings {
|
|||||||
R.array.account_settings_message_age_values))
|
R.array.account_settings_message_age_values))
|
||||||
));
|
));
|
||||||
s.put("messageFormat", Settings.versions(
|
s.put("messageFormat", Settings.versions(
|
||||||
new V(1, new EnumSetting<Account.MessageFormat>(
|
new V(1, new EnumSetting<MessageFormat>(
|
||||||
Account.MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
|
MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
|
||||||
));
|
));
|
||||||
s.put("messageFormatAuto", Settings.versions(
|
s.put("messageFormatAuto", Settings.versions(
|
||||||
new V(2, new BooleanSetting(Account.DEFAULT_MESSAGE_FORMAT_AUTO))
|
new V(2, new BooleanSetting(Account.DEFAULT_MESSAGE_FORMAT_AUTO))
|
||||||
@ -142,8 +148,8 @@ public class AccountSettings {
|
|||||||
new V(1, new StringSetting(Account.DEFAULT_QUOTE_PREFIX))
|
new V(1, new StringSetting(Account.DEFAULT_QUOTE_PREFIX))
|
||||||
));
|
));
|
||||||
s.put("quoteStyle", Settings.versions(
|
s.put("quoteStyle", Settings.versions(
|
||||||
new V(1, new EnumSetting<Account.QuoteStyle>(
|
new V(1, new EnumSetting<QuoteStyle>(
|
||||||
Account.QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
|
QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
|
||||||
));
|
));
|
||||||
s.put("replyAfterQuote", Settings.versions(
|
s.put("replyAfterQuote", Settings.versions(
|
||||||
new V(1, new BooleanSetting(Account.DEFAULT_REPLY_AFTER_QUOTE))
|
new V(1, new BooleanSetting(Account.DEFAULT_REPLY_AFTER_QUOTE))
|
||||||
@ -155,8 +161,8 @@ public class AccountSettings {
|
|||||||
new V(1, new RingtoneSetting("content://settings/system/notification_sound"))
|
new V(1, new RingtoneSetting("content://settings/system/notification_sound"))
|
||||||
));
|
));
|
||||||
s.put("searchableFolders", Settings.versions(
|
s.put("searchableFolders", Settings.versions(
|
||||||
new V(1, new EnumSetting<Account.Searchable>(
|
new V(1, new EnumSetting<Searchable>(
|
||||||
Account.Searchable.class, Account.Searchable.ALL))
|
Searchable.class, Searchable.ALL))
|
||||||
));
|
));
|
||||||
s.put("sentFolderName", Settings.versions(
|
s.put("sentFolderName", Settings.versions(
|
||||||
new V(1, new StringSetting("Sent"))
|
new V(1, new StringSetting("Sent"))
|
||||||
@ -168,8 +174,8 @@ public class AccountSettings {
|
|||||||
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
||||||
));
|
));
|
||||||
s.put("showPicturesEnum", Settings.versions(
|
s.put("showPicturesEnum", Settings.versions(
|
||||||
new V(1, new EnumSetting<Account.ShowPictures>(
|
new V(1, new EnumSetting<ShowPictures>(
|
||||||
Account.ShowPictures.class, Account.ShowPictures.NEVER))
|
ShowPictures.class, ShowPictures.NEVER))
|
||||||
));
|
));
|
||||||
s.put("signatureBeforeQuotedText", Settings.versions(
|
s.put("signatureBeforeQuotedText", Settings.versions(
|
||||||
new V(1, new BooleanSetting(false))
|
new V(1, new BooleanSetting(false))
|
||||||
@ -363,18 +369,15 @@ public class AccountSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The delete policy setting.
|
|
||||||
*/
|
|
||||||
public static class DeletePolicySetting extends PseudoEnumSetting<Integer> {
|
public static class DeletePolicySetting extends PseudoEnumSetting<Integer> {
|
||||||
private Map<Integer, String> mMapping;
|
private Map<Integer, String> mMapping;
|
||||||
|
|
||||||
public DeletePolicySetting(int defaultValue) {
|
public DeletePolicySetting(DeletePolicy defaultValue) {
|
||||||
super(defaultValue);
|
super(defaultValue);
|
||||||
Map<Integer, String> mapping = new HashMap<Integer, String>();
|
Map<Integer, String> mapping = new HashMap<Integer, String>();
|
||||||
mapping.put(Account.DELETE_POLICY_NEVER, "NEVER");
|
mapping.put(DeletePolicy.NEVER.setting, "NEVER");
|
||||||
mapping.put(Account.DELETE_POLICY_ON_DELETE, "DELETE");
|
mapping.put(DeletePolicy.ON_DELETE.setting, "DELETE");
|
||||||
mapping.put(Account.DELETE_POLICY_MARK_AS_READ, "MARK_AS_READ");
|
mapping.put(DeletePolicy.MARK_AS_READ.setting, "MARK_AS_READ");
|
||||||
mMapping = Collections.unmodifiableMap(mapping);
|
mMapping = Collections.unmodifiableMap(mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user