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:
parent
aaa65a457e
commit
7e1e38189d
@ -4730,6 +4730,7 @@ public class MessagingController implements Runnable {
|
|||||||
|
|
||||||
PendingIntent pi = PendingIntent.getActivity(context, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pi = PendingIntent.getActivity(context, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
builder.setContentIntent(pi);
|
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
|
// Only ring or vibrate if we have not done so already on this account and fetch
|
||||||
boolean ringAndVibrate = false;
|
boolean ringAndVibrate = false;
|
||||||
|
@ -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 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 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 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_ACCOUNT = "account";
|
||||||
private final static String EXTRA_MESSAGE = "message";
|
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);
|
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,
|
public static Intent getDeleteAllMessagesIntent(Context context, final Account account,
|
||||||
final ArrayList<MessageReference> refs) {
|
final ArrayList<MessageReference> refs) {
|
||||||
Intent i = new Intent(context, NotificationActionService.class);
|
Intent i = new Intent(context, NotificationActionService.class);
|
||||||
@ -63,9 +72,10 @@ public class NotificationActionService extends CoreService {
|
|||||||
final Preferences preferences = Preferences.getPreferences(this);
|
final Preferences preferences = Preferences.getPreferences(this);
|
||||||
final MessagingController controller = MessagingController.getInstance(getApplication());
|
final MessagingController controller = MessagingController.getInstance(getApplication());
|
||||||
final Account account = preferences.getAccount(intent.getStringExtra(EXTRA_ACCOUNT));
|
final Account account = preferences.getAccount(intent.getStringExtra(EXTRA_ACCOUNT));
|
||||||
|
final String action = intent.getAction();
|
||||||
|
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
if (READ_ALL_ACTION.equals(intent.getAction())) {
|
if (READ_ALL_ACTION.equals(action)) {
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
Log.i(K9.LOG_TAG, "NotificationActionService marking messages as read");
|
Log.i(K9.LOG_TAG, "NotificationActionService marking messages as read");
|
||||||
|
|
||||||
@ -74,7 +84,7 @@ public class NotificationActionService extends CoreService {
|
|||||||
for (MessageReference ref : refs) {
|
for (MessageReference ref : refs) {
|
||||||
controller.setFlag(account, ref.folderName, ref.uid, Flag.SEEN, true);
|
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)
|
if (K9.DEBUG)
|
||||||
Log.i(K9.LOG_TAG, "NotificationActionService deleting messages");
|
Log.i(K9.LOG_TAG, "NotificationActionService deleting messages");
|
||||||
|
|
||||||
@ -90,7 +100,7 @@ public class NotificationActionService extends CoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
controller.deleteMessages(messages, null);
|
controller.deleteMessages(messages, null);
|
||||||
} else if (REPLY_ACTION.equals(intent.getAction())) {
|
} else if (REPLY_ACTION.equals(action)) {
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
Log.i(K9.LOG_TAG, "NotificationActionService initiating reply");
|
Log.i(K9.LOG_TAG, "NotificationActionService initiating reply");
|
||||||
|
|
||||||
@ -103,6 +113,9 @@ public class NotificationActionService extends CoreService {
|
|||||||
} else {
|
} else {
|
||||||
Log.i(K9.LOG_TAG, "Could not execute reply action.");
|
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 */
|
/* there's no point in keeping the notification after the user clicked on it */
|
||||||
|
Loading…
Reference in New Issue
Block a user