Disable sync settings controls for drafts folders

b/11158759
Make the default sync setting for drafts folders 0
(never automatically sync), and disable the settings
control so that it cannot be changed.
Also add a db upgrade step to set any existing drafts
folders to not sync, and clean up any Exchange synced
draft messages.

Change-Id: I256bde231d722089ef2a623482f570a20eccf1de
This commit is contained in:
Martin Hibdon 2013-10-10 14:49:53 -07:00
parent 9e608aa5a1
commit cb30243fe1
3 changed files with 31 additions and 4 deletions

View File

@ -347,7 +347,9 @@ public class Mailbox extends EmailContent implements MailboxColumns, Parcelable
SYNCABLE_TYPES = new SparseBooleanArray(7);
SYNCABLE_TYPES.put(TYPE_INBOX, true);
SYNCABLE_TYPES.put(TYPE_MAIL, false);
SYNCABLE_TYPES.put(TYPE_DRAFTS, true);
// TODO: b/11158759
// For now, drafts folders are not syncable.
//SYNCABLE_TYPES.put(TYPE_DRAFTS, true);
SYNCABLE_TYPES.put(TYPE_SENT, true);
SYNCABLE_TYPES.put(TYPE_TRASH, false);
SYNCABLE_TYPES.put(TYPE_CALENDAR, true);

View File

@ -192,7 +192,9 @@ public class MailboxSettings extends PreferenceActivity {
mSyncEnabledPref.setChecked(mMailbox.mSyncInterval != 0);
mSyncLookbackPref.setValue(String.valueOf(mMailbox.mSyncLookback));
onDataLoaded();
enablePreferences(true);
if (mMailbox.mType != Mailbox.TYPE_DRAFTS) {
enablePreferences(true);
}
}
}

View File

@ -154,8 +154,8 @@ public final class DBHelper {
// Version 116: Add MessageMove & MessageStateChange tables.
// Version 117: Add trigger to delete duplicate messages on sync.
// Version 118: Set syncInterval to 0 for all IMAP mailboxes
public static final int DATABASE_VERSION = 118;
// Version 119: Disable syncing of DRAFTS type folders.
public static final int DATABASE_VERSION = 119;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@ -1211,6 +1211,29 @@ public final class DBHelper {
+ mContext.getString(R.string.protocol_imap) + "' or "
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + "='imap'));");
}
/**
* This statement changes the sync interval column to 0 for all DRAFTS type mailboxes,
* and deletes any messages that are:
* * synced from the server, and
* * in an exchange account draft folder
*
* This is primary for Exchange (b/11158759) but we don't sync draft folders for any
* other account type anyway.
* This will only affect people who used intermediate builds between email1 and email2,
* it should be a no-op for most users.
*/
if (oldVersion <= 118) {
db.execSQL("update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.SYNC_INTERVAL
+ "=0 where " + MailboxColumns.TYPE + "=" + Mailbox.TYPE_DRAFTS);
db.execSQL("delete from " + Message.TABLE_NAME + " where "
+ "(" + SyncColumns.SERVER_ID + " not null and "
+ SyncColumns.SERVER_ID + "!='') and "
+ MessageColumns.MAILBOX_KEY + " in (select "
+ MailboxColumns.ID + " from " + Mailbox.TABLE_NAME + " where "
+ MailboxColumns.TYPE + "=" + Mailbox.TYPE_DRAFTS + ")");
}
}
@Override