am 9a1d9a7d: Merge "Reorder db update/notify and clean up warnings in EmailProvider" into jb-ub-mail-ur10

* commit '9a1d9a7dbb45f55627c15e83878821c3d20179d3':
  Reorder db update/notify and clean up warnings in EmailProvider
This commit is contained in:
Tony Mantler 2013-09-11 09:23:59 -07:00 committed by Android Git Automerger
commit 54a185c5de

View File

@ -718,8 +718,9 @@ public class EmailProvider extends ContentProvider {
Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uifolders"); Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uifolders");
private static final Uri UIPROVIDER_ACCOUNT_NOTIFIER = private static final Uri UIPROVIDER_ACCOUNT_NOTIFIER =
Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uiaccount"); Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uiaccount");
public static final Uri UIPROVIDER_SETTINGS_NOTIFIER = // Not currently used
Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uisettings"); /*public static final Uri UIPROVIDER_SETTINGS_NOTIFIER =
Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uisettings");*/
private static final Uri UIPROVIDER_ATTACHMENT_NOTIFIER = private static final Uri UIPROVIDER_ATTACHMENT_NOTIFIER =
Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uiattachment"); Uri.parse("content://" + UI_NOTIFICATION_AUTHORITY + "/uiattachment");
private static final Uri UIPROVIDER_ATTACHMENTS_NOTIFIER = private static final Uri UIPROVIDER_ATTACHMENTS_NOTIFIER =
@ -750,7 +751,7 @@ public class EmailProvider extends ContentProvider {
values.put(MailboxColumns.MESSAGE_COUNT, 0); values.put(MailboxColumns.MESSAGE_COUNT, 0);
} }
Uri resultUri = null; final Uri resultUri;
try { try {
switch (match) { switch (match) {
@ -783,7 +784,7 @@ public class EmailProvider extends ContentProvider {
// Notify the account when a new mailbox is added // Notify the account when a new mailbox is added
final Long accountId = final Long accountId =
values.getAsLong(MailboxColumns.ACCOUNT_KEY); values.getAsLong(MailboxColumns.ACCOUNT_KEY);
if (accountId != null && accountId.longValue() > 0) { if (accountId != null && accountId > 0) {
notifyUI(UIPROVIDER_ACCOUNT_NOTIFIER, accountId); notifyUI(UIPROVIDER_ACCOUNT_NOTIFIER, accountId);
notifyUI(UIPROVIDER_FOLDERLIST_NOTIFIER, accountId); notifyUI(UIPROVIDER_FOLDERLIST_NOTIFIER, accountId);
} }
@ -1033,10 +1034,6 @@ public class EmailProvider extends ContentProvider {
@Override @Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) { String sortOrder) {
long time = 0L;
if (MailActivityEmail.DEBUG) {
time = System.nanoTime();
}
Cursor c = null; Cursor c = null;
int match; int match;
try { try {
@ -1099,12 +1096,8 @@ public class EmailProvider extends ContentProvider {
} }
final String seenParam = uri.getQueryParameter(UIProvider.SEEN_QUERY_PARAMETER); final String seenParam = uri.getQueryParameter(UIProvider.SEEN_QUERY_PARAMETER);
final boolean unseenOnly; final boolean unseenOnly =
if (seenParam != null && Boolean.FALSE.toString().equals(seenParam)) { seenParam != null && Boolean.FALSE.toString().equals(seenParam);
unseenOnly = true;
} else {
unseenOnly = false;
}
c = uiQuery(match, uri, projection, unseenOnly); c = uiQuery(match, uri, projection, unseenOnly);
return c; return c;
@ -4039,10 +4032,10 @@ public class EmailProvider extends ContentProvider {
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
final ContentResolver resolver = context.getContentResolver(); final ContentResolver resolver = context.getContentResolver();
final ContentValues touchValues = new ContentValues(); final ContentValues touchValues = new ContentValues();
for (int i=0, size=folders.length; i < size; ++i) { for (final Uri folder : folders) {
touchValues.put(MailboxColumns.LAST_TOUCHED_TIME, now); touchValues.put(MailboxColumns.LAST_TOUCHED_TIME, now);
LogUtils.d(TAG, "updateStamp: %s updated", folders[i]); LogUtils.d(TAG, "updateStamp: %s updated", folder);
updated += resolver.update(folders[i], touchValues, null, null); updated += resolver.update(folder, touchValues, null, null);
} }
final Uri toNotify = final Uri toNotify =
UIPROVIDER_RECENT_FOLDERS_NOTIFIER.buildUpon().appendPath(id).build(); UIPROVIDER_RECENT_FOLDERS_NOTIFIER.buildUpon().appendPath(id).build();
@ -4054,7 +4047,7 @@ public class EmailProvider extends ContentProvider {
/** /**
* Updates the recent folders. The values to be updated are specified as ContentValues pairs * Updates the recent folders. The values to be updated are specified as ContentValues pairs
* of (Folder URI, access timestamp). Returns nonzero if successful, always. * of (Folder URI, access timestamp). Returns nonzero if successful, always.
* @param uri * @param uri provider query uri
* @param values uri, timestamp pairs * @param values uri, timestamp pairs
* @return nonzero value always. * @return nonzero value always.
*/ */
@ -4072,7 +4065,7 @@ public class EmailProvider extends ContentProvider {
/** /**
* Populates the recent folders according to the design. * Populates the recent folders according to the design.
* @param uri * @param uri provider query uri
* @return the number of recent folders were populated. * @return the number of recent folders were populated.
*/ */
private int uiPopulateRecentFolders(Uri uri) { private int uiPopulateRecentFolders(Uri uri) {
@ -4298,6 +4291,7 @@ public class EmailProvider extends ContentProvider {
// Notify box has changed so the deletion is reflected in the UI // Notify box has changed so the deletion is reflected in the UI
notifyUIConversationMailbox(mailbox.mId); notifyUIConversationMailbox(mailbox.mId);
} catch (RemoteException e) { } catch (RemoteException e) {
LogUtils.d(TAG, "Remote exception while sending meeting response");
} }
return 1; return 1;
} }
@ -4378,11 +4372,11 @@ public class EmailProvider extends ContentProvider {
} }
} }
public static final String PICKER_UI_ACCOUNT = "picker_ui_account"; /**
public static final String PICKER_MAILBOX_TYPE = "picker_mailbox_type"; * Perform a "Delete" operation
public static final String PICKER_MESSAGE_ID = "picker_message_id"; * @param uri message to delete
public static final String PICKER_HEADER_ID = "picker_header_id"; * @return number of rows affected
*/
private int uiDeleteMessage(Uri uri) { private int uiDeleteMessage(Uri uri) {
final Context context = getContext(); final Context context = getContext();
Message msg = getMessageFromLastSegment(uri); Message msg = getMessageFromLastSegment(uri);
@ -4392,9 +4386,10 @@ public class EmailProvider extends ContentProvider {
if (mailbox.mType == Mailbox.TYPE_TRASH || mailbox.mType == Mailbox.TYPE_DRAFTS) { if (mailbox.mType == Mailbox.TYPE_TRASH || mailbox.mType == Mailbox.TYPE_DRAFTS) {
// We actually delete these, including attachments // We actually delete these, including attachments
AttachmentUtilities.deleteAllAttachmentFiles(context, msg.mAccountKey, msg.mId); AttachmentUtilities.deleteAllAttachmentFiles(context, msg.mAccountKey, msg.mId);
notifyUIFolder(mailbox.mId, mailbox.mAccountKey); final int r = context.getContentResolver().delete(
return context.getContentResolver().delete(
ContentUris.withAppendedId(Message.SYNCED_CONTENT_URI, msg.mId), null, null); ContentUris.withAppendedId(Message.SYNCED_CONTENT_URI, msg.mId), null, null);
notifyUIFolder(mailbox.mId, mailbox.mAccountKey);
return r;
} }
Mailbox trashMailbox = Mailbox trashMailbox =
Mailbox.restoreMailboxOfType(context, msg.mAccountKey, Mailbox.TYPE_TRASH); Mailbox.restoreMailboxOfType(context, msg.mAccountKey, Mailbox.TYPE_TRASH);
@ -4403,10 +4398,17 @@ public class EmailProvider extends ContentProvider {
} }
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(MessageColumns.MAILBOX_KEY, trashMailbox.mId); values.put(MessageColumns.MAILBOX_KEY, trashMailbox.mId);
final int r = uiUpdateMessage(uri, values, true);
notifyUIFolder(mailbox.mId, mailbox.mAccountKey); notifyUIFolder(mailbox.mId, mailbox.mAccountKey);
return uiUpdateMessage(uri, values, true); return r;
} }
public static final String PICKER_UI_ACCOUNT = "picker_ui_account";
public static final String PICKER_MAILBOX_TYPE = "picker_mailbox_type";
// Currently unused
//public static final String PICKER_MESSAGE_ID = "picker_message_id";
public static final String PICKER_HEADER_ID = "picker_header_id";
private int pickFolder(Uri uri, int type, int headerId) { private int pickFolder(Uri uri, int type, int headerId) {
Context context = getContext(); Context context = getContext();
Long acctId = Long.parseLong(uri.getLastPathSegment()); Long acctId = Long.parseLong(uri.getLastPathSegment());