Remove new message notification if mailbox is touched

Change-Id: I63faeaddf6c5aee3f7d89c2fc19dce641e7ff5e5
This commit is contained in:
Marc Blank 2012-03-21 10:56:50 -07:00
parent 77cc6891ea
commit 9efec18428
2 changed files with 18 additions and 1 deletions

View File

@ -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.

View File

@ -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;
}