diff --git a/email2/src/com/android/email/NotificationController.java b/email2/src/com/android/email/NotificationController.java index dac47056e..91773ae15 100644 --- a/email2/src/com/android/email/NotificationController.java +++ b/email2/src/com/android/email/NotificationController.java @@ -561,6 +561,13 @@ public class NotificationController { mNotificationManager.cancel(getLoginFailedNotificationId(accountId)); } + /** + * Cancels the new message notification for a given mailbox + */ + public void cancelNewMessageNotification(long mailboxId) { + mNotificationManager.cancel(getNewMessageNotificationId(mailboxId)); + } + /** * Show (or update) a notification that the user's password is expiring. The given account * is used to update the display text, but, all accounts share the same notification ID. diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index 0ae5f01eb..35f60d433 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -38,6 +38,7 @@ import android.text.TextUtils; import android.util.Log; import com.android.common.content.ProjectionMap; +import com.android.email.NotificationController; import com.android.email.Preferences; import com.android.email.R; import com.android.email.SecurityPolicy; @@ -2902,12 +2903,21 @@ outer: } private int uiUpdateRecentFolders(Uri uri, ContentValues values) { - ContentResolver resolver = getContext().getContentResolver(); + Context context = getContext(); + ContentResolver resolver = context.getContentResolver(); ContentValues touchValues = new ContentValues(); for (String uriString: values.keySet()) { Uri folderUri = Uri.parse(uriString); touchValues.put(MailboxColumns.LAST_TOUCHED_TIME, values.getAsLong(uriString)); resolver.update(folderUri, touchValues, null, null); + String mailboxIdString = folderUri.getLastPathSegment(); + long mailboxId; + try { + mailboxId = Long.parseLong(mailboxIdString); + NotificationController.getInstance(context).cancelNewMessageNotification(mailboxId); + } catch (NumberFormatException e) { + // Keep on going... + } } return 1; }