mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-30 14:50:14 -05:00
Add Notification setting to disable unread count in notification bar.
This commit is contained in:
parent
a17c21f0cd
commit
c07c7052dc
@ -539,6 +539,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="account_settings_notify_self_summary">Show a notification for messages I sent</string>
|
||||
<string name="account_settings_notification_opens_unread_label">Notification opens unread messages</string>
|
||||
<string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string>
|
||||
<string name="account_settings_notification_unread_count_label">Show unread count</string>
|
||||
<string name="account_settings_notification_unread_count_summary">Show the number of unread messages in the notification bar.</string>
|
||||
|
||||
<string name="account_settings_hide_buttons_label">Scroll navigation buttons</string>
|
||||
<string name="account_settings_hide_buttons_never">Never</string>
|
||||
|
@ -424,6 +424,13 @@
|
||||
android:defaultValue="true"
|
||||
android:summary="@string/account_settings_notification_opens_unread_summary" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:persistent="false"
|
||||
android:key="notification_unread_count"
|
||||
android:title="@string/account_settings_notification_unread_count_label"
|
||||
android:defaultValue="true"
|
||||
android:summary="@string/account_settings_notification_unread_count_summary" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
|
@ -105,6 +105,7 @@ public class Account implements BaseAccount
|
||||
private int mMaxPushFolders;
|
||||
private int mIdleRefreshMinutes;
|
||||
private boolean goToUnreadMessageSearch;
|
||||
private boolean mNotificationShowsUnreadCount;
|
||||
private final Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
|
||||
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;
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user