Merge "Fix up delete to handle trash/drafts deletions"
This commit is contained in:
commit
e1195f97d2
@ -188,6 +188,10 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
|
|||||||
// A mailbox that holds Messages that are attachments
|
// A mailbox that holds Messages that are attachments
|
||||||
public static final int TYPE_ATTACHMENT = 0x101;
|
public static final int TYPE_ATTACHMENT = 0x101;
|
||||||
|
|
||||||
|
// Default "touch" time for system mailboxes
|
||||||
|
public static final int DRAFTS_DEFAULT_TOUCH_TIME = 2;
|
||||||
|
public static final int SENT_DEFAULT_TOUCH_TIME = 1;
|
||||||
|
|
||||||
// Bit field flags; each is defined below
|
// Bit field flags; each is defined below
|
||||||
// Warning: Do not read these flags until POP/IMAP/EAS all populate them
|
// Warning: Do not read these flags until POP/IMAP/EAS all populate them
|
||||||
/** No flags set */
|
/** No flags set */
|
||||||
|
@ -63,6 +63,7 @@ import com.android.emailcommon.provider.Policy;
|
|||||||
import com.android.emailcommon.provider.QuickResponse;
|
import com.android.emailcommon.provider.QuickResponse;
|
||||||
import com.android.emailcommon.service.EmailServiceProxy;
|
import com.android.emailcommon.service.EmailServiceProxy;
|
||||||
import com.android.emailcommon.service.IEmailServiceCallback;
|
import com.android.emailcommon.service.IEmailServiceCallback;
|
||||||
|
import com.android.emailcommon.utility.AttachmentUtilities;
|
||||||
import com.android.mail.providers.UIProvider;
|
import com.android.mail.providers.UIProvider;
|
||||||
import com.android.mail.providers.UIProvider.AccountCapabilities;
|
import com.android.mail.providers.UIProvider.AccountCapabilities;
|
||||||
import com.android.mail.providers.UIProvider.ConversationPriority;
|
import com.android.mail.providers.UIProvider.ConversationPriority;
|
||||||
@ -2417,6 +2418,16 @@ outer:
|
|||||||
}
|
}
|
||||||
Log.d(TAG, "Creating mailbox of type " + mailboxType + " for account " + accountId);
|
Log.d(TAG, "Creating mailbox of type " + mailboxType + " for account " + accountId);
|
||||||
Mailbox box = Mailbox.newSystemMailbox(accountId, mailboxType, context.getString(resId));
|
Mailbox box = Mailbox.newSystemMailbox(accountId, mailboxType, context.getString(resId));
|
||||||
|
// Make sure drafts and save will show up in recents...
|
||||||
|
// If these already exist (from old Email app), they will have touch times
|
||||||
|
switch (mailboxType) {
|
||||||
|
case Mailbox.TYPE_DRAFTS:
|
||||||
|
box.mLastTouchedTime = Mailbox.DRAFTS_DEFAULT_TOUCH_TIME;
|
||||||
|
break;
|
||||||
|
case Mailbox.TYPE_SENT:
|
||||||
|
box.mLastTouchedTime = Mailbox.SENT_DEFAULT_TOUCH_TIME;
|
||||||
|
break;
|
||||||
|
}
|
||||||
box.save(context);
|
box.save(context);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
@ -2701,16 +2712,19 @@ outer:
|
|||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
Message msg = getMessageFromLastSegment(uri);
|
Message msg = getMessageFromLastSegment(uri);
|
||||||
if (msg == null) return 0;
|
if (msg == null) return 0;
|
||||||
Mailbox mailbox =
|
Mailbox mailbox = Mailbox.restoreMailboxWithId(context, msg.mMailboxKey);
|
||||||
Mailbox.restoreMailboxOfType(context, msg.mAccountKey, Mailbox.TYPE_TRASH);
|
|
||||||
if (mailbox == null) return 0;
|
if (mailbox == null) return 0;
|
||||||
ContentProviderOperation op =
|
if (mailbox.mType == Mailbox.TYPE_TRASH || mailbox.mType == Mailbox.TYPE_DRAFTS) {
|
||||||
ContentProviderOperation.newUpdate(convertToEmailProviderUri(uri, false))
|
// We actually delete these, including attachments
|
||||||
.withValue(Message.MAILBOX_KEY, msg.mMailboxKey)
|
AttachmentUtilities.deleteAllAttachmentFiles(context, msg.mAccountKey, msg.mId);
|
||||||
.build();
|
return context.getContentResolver().delete(
|
||||||
addToSequence(uri, op);
|
ContentUris.withAppendedId(Message.CONTENT_URI, msg.mId), null, null);
|
||||||
|
}
|
||||||
|
Mailbox trashMailbox =
|
||||||
|
Mailbox.restoreMailboxOfType(context, msg.mAccountKey, Mailbox.TYPE_TRASH);
|
||||||
|
if (trashMailbox == null) return 0;
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(Message.MAILBOX_KEY, mailbox.mId);
|
values.put(MessageColumns.MAILBOX_KEY, trashMailbox.mId);
|
||||||
return uiUpdateMessage(uri, values);
|
return uiUpdateMessage(uri, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user