diff --git a/res/values/arrays.xml b/res/values/arrays.xml index dd31a54a1..f18a098e8 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -124,6 +124,26 @@ NONE + + @string/account_setup_push_limit_10 + @string/account_setup_push_limit_25 + @string/account_setup_push_limit_50 + @string/account_setup_push_limit_100 + @string/account_setup_push_limit_250 + @string/account_setup_push_limit_500 + @string/account_setup_push_limit_1000 + + + + 10 + 25 + 50 + 100 + 250 + 500 + 1000 + + @string/account_settings_folder_target_mode_all @string/account_settings_folder_target_mode_first_class diff --git a/res/values/strings.xml b/res/values/strings.xml index 1fa9ae0b2..c32b6a68d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -618,4 +618,13 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Select all Deselect all + Max folders to check with push + 10 folders + 25 folders + 50 folders + 100 folders + 250 folders + 500 folders + 1000 folders + diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index 50d4b3149..06ef2de07 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -79,7 +79,14 @@ android:entries="@array/account_settings_folder_push_mode_entries" android:entryValues="@array/account_settings_folder_push_mode_values" android:dialogTitle="@string/account_settings_folder_push_mode_label" /> - + + + identities; @@ -105,8 +106,9 @@ public class Account implements Serializable mHideMessageViewButtons = HideButtons.NEVER; mRingtoneUri = "content://settings/system/notification_sound"; mIsSignatureBeforeQuotedText = false; - + mExpungePolicy = EXPUNGE_IMMEDIATELY; mAutoExpandFolderName = "INBOX"; + mMaxPushFolders = 10; identities = new ArrayList(); @@ -201,6 +203,8 @@ public class Account implements Serializable "Outbox"); mExpungePolicy = preferences.getPreferences().getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY); + mMaxPushFolders = preferences.getPreferences().getInt(mUuid + ".maxPushFolders", 10); + // Between r418 and r431 (version 0.103), folder names were set empty if the Incoming settings were // opened for non-IMAP accounts. 0.103 was never a market release, so perhaps this code // should be deleted sometime soon @@ -536,6 +540,7 @@ public class Account implements Serializable editor.remove(mUuid + ".hideButtonsEnum"); editor.remove(mUuid + ".signatureBeforeQuotedText"); editor.remove(mUuid + ".expungePolicy"); + editor.remove(mUuid + ".maxPushFolders"); deleteIdentities(preferences.getPreferences(), editor); editor.commit(); } @@ -607,7 +612,7 @@ public class Account implements Serializable editor.putString(mUuid + ".folderTargetMode", mFolderTargetMode.name()); editor.putBoolean(mUuid + ".signatureBeforeQuotedText", this.mIsSignatureBeforeQuotedText); editor.putString(mUuid + ".expungePolicy", mExpungePolicy); - + editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders); saveIdentities(preferences.getPreferences(), editor); editor.commit(); @@ -951,4 +956,14 @@ public class Account implements Serializable mExpungePolicy = expungePolicy; } + public int getMaxPushFolders() + { + return mMaxPushFolders; + } + + public void setMaxPushFolders(int maxPushFolders) + { + mMaxPushFolders = maxPushFolders; + } + } diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java index 731b492e4..832e5f15e 100644 --- a/src/com/fsck/k9/MessagingController.java +++ b/src/com/fsck/k9/MessagingController.java @@ -1535,7 +1535,7 @@ public class MessagingController implements Runnable private void processPendingCommands(final Account account) { - put("processPendingCommands", null, new Runnable() + putBackground("processPendingCommands", null, new Runnable() { public void run() { @@ -1963,7 +1963,7 @@ public class MessagingController implements Runnable private void queueSetFlag(final Account account, final String folderName, final String newState, final String flag, final String[] uids) { - put("queueSetFlag " + account.getDescription() + ":" + folderName, null, new Runnable() + putBackground("queueSetFlag " + account.getDescription() + ":" + folderName, null, new Runnable() { public void run() { @@ -2086,7 +2086,7 @@ public class MessagingController implements Runnable } private void queueExpunge(final Account account, final String folderName) { - put("queueExpunge " + account.getDescription() + ":" + folderName, null, new Runnable() + putBackground("queueExpunge " + account.getDescription() + ":" + folderName, null, new Runnable() { public void run() { @@ -3278,7 +3278,7 @@ public class MessagingController implements Runnable if (!message.getUid().startsWith(K9.LOCAL_UID_PREFIX)) { suppressMessage(account, srcFolder, message); - put("moveMessage", null, new Runnable() + putBackground("moveMessage", null, new Runnable() { public void run() { @@ -3357,7 +3357,7 @@ public class MessagingController implements Runnable { if (!message.getUid().startsWith(K9.LOCAL_UID_PREFIX)) { - put("copyMessage", null, new Runnable() + putBackground("copyMessage", null, new Runnable() { public void run() { @@ -3429,7 +3429,7 @@ public class MessagingController implements Runnable public void expunge(final Account account, final String folder, final MessagingListener listener) { - put("expunge", null, new Runnable() + putBackground("expunge", null, new Runnable() { public void run() { @@ -3446,7 +3446,7 @@ public class MessagingController implements Runnable suppressMessage(account, folder, message); } - put("deleteMessages", null, new Runnable() + putBackground("deleteMessages", null, new Runnable() { public void run() { @@ -3613,7 +3613,7 @@ public class MessagingController implements Runnable public void emptyTrash(final Account account, MessagingListener listener) { - put("emptyTrash", listener, new Runnable() + putBackground("emptyTrash", listener, new Runnable() { public void run() { @@ -4277,6 +4277,14 @@ public class MessagingController implements Runnable if (names.size() > 0) { PushReceiver receiver = new MessagingControllerPushReceiver(mApplication, account, this); + int maxPushFolders = account.getMaxPushFolders(); + + if (names.size() > maxPushFolders) + { + Log.i(K9.LOG_TAG, "Count of folders to push for account " + account.getDescription() + " is " + names.size() + + ", greater than limit of " + maxPushFolders + ", truncating"); + names = names.subList(0, maxPushFolders); + } try { diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 53a6194c6..7bd5191d7 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -40,6 +40,7 @@ public class AccountSettings extends K9PreferenceActivity private static final String PREFERENCE_DISPLAY_MODE = "folder_display_mode"; private static final String PREFERENCE_SYNC_MODE = "folder_sync_mode"; private static final String PREFERENCE_PUSH_MODE = "folder_push_mode"; + private static final String PREFERENCE_PUSH_LIMIT = "folder_push_limit"; private static final String PREFERENCE_TARGET_MODE = "folder_target_mode"; private static final String PREFERENCE_DELETE_POLICY = "delete_policy"; private static final String PREFERENCE_EXPUNGE_POLICY = "expunge_policy"; @@ -62,6 +63,7 @@ public class AccountSettings extends K9PreferenceActivity private ListPreference mDisplayMode; private ListPreference mSyncMode; private ListPreference mPushMode; + private ListPreference mPushLimit; private ListPreference mTargetMode; private ListPreference mDeletePolicy; private ListPreference mExpungePolicy; @@ -178,6 +180,22 @@ public class AccountSettings extends K9PreferenceActivity return false; } }); + + mPushLimit = (ListPreference) findPreference(PREFERENCE_PUSH_LIMIT); + mPushLimit.setEnabled(isPushCapable); + mPushLimit.setValue(String.valueOf(mAccount.getMaxPushFolders())); + mPushLimit.setSummary(mPushLimit.getEntry()); + mPushLimit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() + { + public boolean onPreferenceChange(Preference preference, Object newValue) + { + final String summary = newValue.toString(); + int index = mPushLimit.findIndexOfValue(summary); + mPushLimit.setSummary(mPushLimit.getEntries()[index]); + mPushLimit.setValue(summary); + return false; + } + }); mTargetMode = (ListPreference) findPreference(PREFERENCE_TARGET_MODE); mTargetMode.setValue(mAccount.getFolderTargetMode().name()); @@ -361,6 +379,7 @@ public class AccountSettings extends K9PreferenceActivity mAccount.setFolderDisplayMode(Account.FolderMode.valueOf(mDisplayMode.getValue())); mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue())); mAccount.setFolderPushMode(Account.FolderMode.valueOf(mPushMode.getValue())); + mAccount.setMaxPushFolders(Integer.parseInt(mPushLimit.getValue())); mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue())); mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue())); mAccount.setExpungePolicy(mExpungePolicy.getValue());