diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2015-04-06 00:44:28 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2015-04-06 00:44:28 +0200 |
commit | ef570af8d687e8e1221af3fa85217f974585fb14 (patch) | |
tree | 2b4c4d63fbe27998a0af55fad98fb8463d2eda04 | |
parent | ff5b6147e0c47599fc3b0c94671d4eb5f1c8b09b (diff) | |
download | android_packages_apps_UnifiedEmail-ef570af8d687e8e1221af3fa85217f974585fb14.tar.gz android_packages_apps_UnifiedEmail-ef570af8d687e8e1221af3fa85217f974585fb14.tar.bz2 android_packages_apps_UnifiedEmail-ef570af8d687e8e1221af3fa85217f974585fb14.zip |
unified-email: check notification support prior to create notification objects
Change-Id: I86513d397d75c3dc2f0dad1b3399c4ffeaabf173
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r-- | src/com/android/mail/utils/NotificationUtils.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/com/android/mail/utils/NotificationUtils.java b/src/com/android/mail/utils/NotificationUtils.java index 456d47adc..910870248 100644 --- a/src/com/android/mail/utils/NotificationUtils.java +++ b/src/com/android/mail/utils/NotificationUtils.java @@ -547,6 +547,26 @@ public class NotificationUtils { final Account account, boolean getAttention, boolean ignoreUnobtrusiveSetting, NotificationKey key, final ContactFetcher contactFetcher) { + // Check that the folder supports notifications, prior to create all the + // NotificationManager stuff + final boolean isInbox = folder.folderUri.equals(account.settings.defaultInbox); + final FolderPreferences folderPreferences = + new FolderPreferences(context, account.getAccountId(), folder, isInbox); + + if (isInbox) { + final AccountPreferences accountPreferences = + new AccountPreferences(context, account.getAccountId()); + moveNotificationSetting(accountPreferences, folderPreferences); + } + + if (!folderPreferences.areNotificationsEnabled()) { + LogUtils.i(LOG_TAG, "Notifications are disabled for this folder; not notifying"); + // Don't notify + return; + } + + + NotificationManagerCompat nm = NotificationManagerCompat.from(context); final NotificationMap notificationMap = getNotificationMap(context); @@ -675,22 +695,6 @@ public class NotificationUtils { boolean eventInfoConfigured = false; - final boolean isInbox = folder.folderUri.equals(account.settings.defaultInbox); - final FolderPreferences folderPreferences = - new FolderPreferences(context, account.getAccountId(), folder, isInbox); - - if (isInbox) { - final AccountPreferences accountPreferences = - new AccountPreferences(context, account.getAccountId()); - moveNotificationSetting(accountPreferences, folderPreferences); - } - - if (!folderPreferences.areNotificationsEnabled()) { - LogUtils.i(LOG_TAG, "Notifications are disabled for this folder; not notifying"); - // Don't notify - return; - } - if (unreadCount > 0) { // How can I order this properly? if (cursor.moveToNext()) { |