diff --git a/res/values/strings.xml b/res/values/strings.xml index 847eabed5..7964fd861 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -539,6 +539,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Show a notification for messages I sent Notification opens unread messages Searches for unread messages when Notification is opened + Show unread count + Show the number of unread messages in the notification bar. Scroll navigation buttons Never diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index 389e362bf..57f62b9af 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -424,6 +424,13 @@ android:defaultValue="true" android:summary="@string/account_settings_notification_opens_unread_summary" /> + + compressionMap = new ConcurrentHashMap(); private Searchable searchableFolders; private boolean subscribedFoldersOnly; @@ -186,6 +187,7 @@ public class Account implements BaseAccount mMaxPushFolders = 10; mChipColor = (new Random()).nextInt(0xffffff) + 0xff000000; goToUnreadMessageSearch = false; + mNotificationShowsUnreadCount = true; subscribedFoldersOnly = false; maximumPolledMessageAge = -1; maximumAutoDownloadMessageSize = 32768; @@ -275,7 +277,8 @@ public class Account implements BaseAccount mMaxPushFolders = prefs.getInt(mUuid + ".maxPushFolders", 10); goToUnreadMessageSearch = prefs.getBoolean(mUuid + ".goToUnreadMessageSearch", - false); + false); + mNotificationShowsUnreadCount = prefs.getBoolean(mUuid + ".notificationUnreadCount", true); subscribedFoldersOnly = prefs.getBoolean(mUuid + ".subscribedFoldersOnly", false); maximumPolledMessageAge = prefs.getInt(mUuid @@ -466,6 +469,7 @@ public class Account implements BaseAccount editor.remove(mUuid + ".led"); editor.remove(mUuid + ".ledColor"); editor.remove(mUuid + ".goToUnreadMessageSearch"); + editor.remove(mUuid + ".notificationUnreadCount"); editor.remove(mUuid + ".subscribedFoldersOnly"); editor.remove(mUuid + ".maximumPolledMessageAge"); editor.remove(mUuid + ".maximumAutoDownloadMessageSize"); @@ -559,9 +563,10 @@ public class Account implements BaseAccount editor.putString(mUuid + ".expungePolicy", mExpungePolicy); editor.putBoolean(mUuid + ".syncRemoteDeletions", mSyncRemoteDeletions); editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders); - editor.putString(mUuid + ".searchableFolders", searchableFolders.name()); + editor.putString(mUuid + ".searchableFolders", searchableFolders.name()); editor.putInt(mUuid + ".chipColor", mChipColor); editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch); + editor.putBoolean(mUuid + ".notificationUnreadCount", mNotificationShowsUnreadCount); editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly); editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge); editor.putInt(mUuid + ".maximumAutoDownloadMessageSize", maximumAutoDownloadMessageSize); @@ -1404,6 +1409,16 @@ public class Account implements BaseAccount this.goToUnreadMessageSearch = goToUnreadMessageSearch; } + public boolean isNotificationShowsUnreadCount() + { + return mNotificationShowsUnreadCount; + } + + public void setNotificationShowsUnreadCount(boolean notificationShowsUnreadCount) + { + this.mNotificationShowsUnreadCount = notificationShowsUnreadCount; + } + public synchronized boolean subscribedFoldersOnly() { return subscribedFoldersOnly; diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 4a3da6115..a2a2ee429 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -82,6 +82,7 @@ public class AccountSettings extends K9PreferenceActivity private static final String PREFERENCE_CHIP_COLOR = "chip_color"; private static final String PREFERENCE_LED_COLOR = "led_color"; private static final String PREFERENCE_NOTIFICATION_OPENS_UNREAD = "notification_opens_unread"; + private static final String PREFERENCE_NOTIFICATION_UNREAD_COUNT = "notification_unread_count"; private static final String PREFERENCE_MESSAGE_AGE = "account_message_age"; private static final String PREFERENCE_MESSAGE_SIZE = "account_autodownload_size"; private static final String PREFERENCE_SAVE_ALL_HEADERS = "account_save_all_headers"; @@ -140,6 +141,7 @@ public class AccountSettings extends K9PreferenceActivity private Preference mLedColor; private boolean mIncomingChanged = false; private CheckBoxPreference mNotificationOpensUnread; + private CheckBoxPreference mNotificationUnreadCount; private ListPreference mQuoteStyle; private EditTextPreference mAccountQuotePrefix; private CheckBoxPreference mReplyAfterQuote; @@ -608,6 +610,9 @@ public class AccountSettings extends K9PreferenceActivity mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD); mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch()); + mNotificationUnreadCount = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_UNREAD_COUNT); + mNotificationUnreadCount.setChecked(mAccount.isNotificationShowsUnreadCount()); + new PopulateFolderPrefsTask().execute(); mChipColor = findPreference(PREFERENCE_CHIP_COLOR); @@ -744,6 +749,7 @@ public class AccountSettings extends K9PreferenceActivity mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue())); mAccount.getNotificationSetting().setLed(mAccountLed.isChecked()); mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked()); + mAccount.setNotificationShowsUnreadCount(mNotificationUnreadCount.isChecked()); mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue())); mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue())); mAccount.setExpungePolicy(mExpungePolicy.getValue()); diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 7b35be8d1..ee8ba3ffd 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -4767,12 +4767,16 @@ public class MessagingController implements Runnable NotificationManager notifMgr = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notif = new Notification(R.drawable.stat_notify_email_generic, messageNotice, System.currentTimeMillis()); - notif.number = previousUnreadMessageCount + newMessageCount.get(); + final int unreadCount = previousUnreadMessageCount + newMessageCount.get(); + if (account.isNotificationShowsUnreadCount()) + { + notif.number = unreadCount; + } Intent i = FolderList.actionHandleNotification(context, account, message.getFolder().getName()); PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0); - String accountNotice = context.getString(R.string.notification_new_one_account_fmt, notif.number, account.getDescription()); + String accountNotice = context.getString(R.string.notification_new_one_account_fmt, unreadCount, account.getDescription()); notif.setLatestEventInfo(context, accountNotice, messageNotice, pi); // Only ring or vibrate if we have not done so already on this