1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-17 21:32:26 -05:00

Reset list of unseen messages when the user clears the notification.

This commit is contained in:
Danny Baumann 2013-01-07 09:12:07 +01:00
parent aaa65a457e
commit 7e1e38189d
2 changed files with 17 additions and 3 deletions

View File

@ -4730,6 +4730,7 @@ public class MessagingController implements Runnable {
PendingIntent pi = PendingIntent.getActivity(context, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pi);
builder.setDeleteIntent(NotificationActionService.getAcknowledgeIntent(context, account));
// Only ring or vibrate if we have not done so already on this account and fetch
boolean ringAndVibrate = false;

View File

@ -22,6 +22,7 @@ public class NotificationActionService extends CoreService {
private final static String REPLY_ACTION = "com.fsck.k9.service.NotificationActionService.REPLY_ACTION";
private final static String READ_ALL_ACTION = "com.fsck.k9.service.NotificationActionService.READ_ALL_ACTION";
private final static String DELETE_ALL_ACTION = "com.fsck.k9.service.NotificationActionService.DELETE_ALL_ACTION";
private final static String ACKNOWLEDGE_ACTION = "com.fsck.k9.service.NotificationActionService.ACKNOWLEDGE_ACTION";
private final static String EXTRA_ACCOUNT = "account";
private final static String EXTRA_MESSAGE = "message";
@ -46,6 +47,14 @@ public class NotificationActionService extends CoreService {
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
}
public static PendingIntent getAcknowledgeIntent(Context context, final Account account) {
Intent i = new Intent(context, NotificationActionService.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
i.setAction(ACKNOWLEDGE_ACTION);
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
}
public static Intent getDeleteAllMessagesIntent(Context context, final Account account,
final ArrayList<MessageReference> refs) {
Intent i = new Intent(context, NotificationActionService.class);
@ -63,9 +72,10 @@ public class NotificationActionService extends CoreService {
final Preferences preferences = Preferences.getPreferences(this);
final MessagingController controller = MessagingController.getInstance(getApplication());
final Account account = preferences.getAccount(intent.getStringExtra(EXTRA_ACCOUNT));
final String action = intent.getAction();
if (account != null) {
if (READ_ALL_ACTION.equals(intent.getAction())) {
if (READ_ALL_ACTION.equals(action)) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "NotificationActionService marking messages as read");
@ -74,7 +84,7 @@ public class NotificationActionService extends CoreService {
for (MessageReference ref : refs) {
controller.setFlag(account, ref.folderName, ref.uid, Flag.SEEN, true);
}
} else if (DELETE_ALL_ACTION.equals(intent.getAction())) {
} else if (DELETE_ALL_ACTION.equals(action)) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "NotificationActionService deleting messages");
@ -90,7 +100,7 @@ public class NotificationActionService extends CoreService {
}
controller.deleteMessages(messages, null);
} else if (REPLY_ACTION.equals(intent.getAction())) {
} else if (REPLY_ACTION.equals(action)) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "NotificationActionService initiating reply");
@ -103,6 +113,9 @@ public class NotificationActionService extends CoreService {
} else {
Log.i(K9.LOG_TAG, "Could not execute reply action.");
}
} else if (ACKNOWLEDGE_ACTION.equals(action)) {
// nothing to do here, we just want to cancel the notification so the list
// of unseen messages is reset
}
/* there's no point in keeping the notification after the user clicked on it */