mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Allow user to set a limit on the number of folders to be handled with
push technology. This provide a layer of safety in case of misconfiguration (accidentally setting too many folders to push using classes), which can bog down the device till it is unusable. On a G1, 25 folders is a very large load. Fixes Issue 871. Also, move some pending commands to the background to make way for more important user interface activity.
This commit is contained in:
parent
022b0241a1
commit
070fd635d4
@ -124,6 +124,26 @@
|
||||
<item>NONE</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="account_settings_push_limit_entries">
|
||||
<item>@string/account_setup_push_limit_10</item>
|
||||
<item>@string/account_setup_push_limit_25</item>
|
||||
<item>@string/account_setup_push_limit_50</item>
|
||||
<item>@string/account_setup_push_limit_100</item>
|
||||
<item>@string/account_setup_push_limit_250</item>
|
||||
<item>@string/account_setup_push_limit_500</item>
|
||||
<item>@string/account_setup_push_limit_1000</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="account_settings_push_limit_values">
|
||||
<item>10</item>
|
||||
<item>25</item>
|
||||
<item>50</item>
|
||||
<item>100</item>
|
||||
<item>250</item>
|
||||
<item>500</item>
|
||||
<item>1000</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="account_settings_folder_target_mode_entries">
|
||||
<item>@string/account_settings_folder_target_mode_all</item>
|
||||
<item>@string/account_settings_folder_target_mode_first_class</item>
|
||||
|
@ -618,4 +618,13 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="batch_select_all">Select all</string>
|
||||
<string name="batch_deselect_all">Deselect all</string>
|
||||
|
||||
<string name="account_setup_push_limit_label">Max folders to check with push</string>
|
||||
<string name="account_setup_push_limit_10">10 folders</string>
|
||||
<string name="account_setup_push_limit_25">25 folders</string>
|
||||
<string name="account_setup_push_limit_50">50 folders</string>
|
||||
<string name="account_setup_push_limit_100">100 folders</string>
|
||||
<string name="account_setup_push_limit_250">250 folders</string>
|
||||
<string name="account_setup_push_limit_500">500 folders</string>
|
||||
<string name="account_setup_push_limit_1000">1000 folders</string>
|
||||
|
||||
</resources>
|
||||
|
@ -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" />
|
||||
|
||||
|
||||
<ListPreference
|
||||
android:key="folder_push_limit"
|
||||
android:title="@string/account_setup_push_limit_label"
|
||||
android:entries="@array/account_settings_push_limit_entries"
|
||||
android:entryValues="@array/account_settings_push_limit_values"
|
||||
android:dialogTitle="@string/account_setup_push_limit_label" />
|
||||
|
||||
<ListPreference
|
||||
android:key="delete_policy"
|
||||
android:title="@string/account_setup_incoming_delete_policy_label"
|
||||
|
@ -58,7 +58,8 @@ public class Account implements Serializable
|
||||
HideButtons mHideMessageViewButtons;
|
||||
boolean mIsSignatureBeforeQuotedText;
|
||||
boolean mLeftHanded;
|
||||
public String mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
||||
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
||||
private int mMaxPushFolders;
|
||||
|
||||
List<Identity> 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<Identity>();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user