diff options
Diffstat (limited to 'src/com/android/mail/MailIntentService.java')
-rw-r--r-- | src/com/android/mail/MailIntentService.java | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/com/android/mail/MailIntentService.java b/src/com/android/mail/MailIntentService.java index 709587997..f30a12844 100644 --- a/src/com/android/mail/MailIntentService.java +++ b/src/com/android/mail/MailIntentService.java @@ -16,20 +16,32 @@ package com.android.mail; import android.app.IntentService; +import android.content.Context; import android.content.Intent; +import com.android.mail.providers.Account; +import com.android.mail.providers.Folder; +import com.android.mail.utils.LogTag; +import com.android.mail.utils.LogUtils; +import com.android.mail.utils.NotificationUtils; + /** * A service to handle various intents asynchronously. */ public class MailIntentService extends IntentService { + private static final String LOG_TAG = LogTag.getLogTag(); + public static final String ACTION_RESEND_NOTIFICATIONS = "com.android.mail.action.RESEND_NOTIFICATIONS"; public static final String ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS = "com.android.mail.action.CLEAR_NEW_MAIL_NOTIFICATIONS"; public static final String ACTION_MARK_SEEN = "com.android.mail.action.MARK_SEEN"; + public static final String ACTION_BACKUP_DATA_CHANGED = + "com.android.mail.action.BACKUP_DATA_CHANGED"; public static final String ACCOUNT_EXTRA = "account"; public static final String FOLDER_EXTRA = "folder"; + public static final String CONVERSATION_EXTRA = "conversation"; public MailIntentService() { super("MailIntentService"); @@ -41,6 +53,35 @@ public class MailIntentService extends IntentService { @Override protected void onHandleIntent(final Intent intent) { - // UnifiedEmail does not handle any of these at the moment + // UnifiedEmail does not handle all Intents + + LogUtils.v(LOG_TAG, "Handling intent %s", intent); + + final String action = intent.getAction(); + + if (Intent.ACTION_LOCALE_CHANGED.equals(action)) { + handleLocaleChanged(); + } else if (ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS.equals(action)) { + final Account account = intent.getParcelableExtra(ACCOUNT_EXTRA); + final Folder folder = intent.getParcelableExtra(FOLDER_EXTRA); + + NotificationUtils.clearFolderNotification(this, account, folder); + } else if (ACTION_RESEND_NOTIFICATIONS.equals(action)) { + NotificationUtils.resendNotifications(this, false); + } else if (ACTION_MARK_SEEN.equals(action)) { + final Folder folder = intent.getParcelableExtra(FOLDER_EXTRA); + + NotificationUtils.markSeen(this, folder); + } + } + + public static void broadcastBackupDataChanged(final Context context) { + final Intent intent = new Intent(ACTION_BACKUP_DATA_CHANGED); + context.startService(intent); + } + + private void handleLocaleChanged() { + // Cancel all notifications. The correct ones will be recreated when the app starts back up + NotificationUtils.cancelAndResendNotifications(this); } } |