1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Fix marking messages as read from notification.

MessagingController.setFlag(Account, List<Long>, Flag, boolean, boolean)
expects database IDs, while Message.getId() returns UIDs. Fix the
operation by using a variant that expects UIDs.
This commit is contained in:
Danny Baumann 2013-01-02 15:43:29 +01:00
parent 2159f1c9bd
commit c0e0ac9d34

View File

@ -25,7 +25,7 @@ public class NotificationActionService extends CoreService {
private final static String EXTRA_ACCOUNT = "account";
private final static String EXTRA_MESSAGE = "message";
private final static String EXTRA_MESSAGE_IDS = "message_ids";
private final static String EXTRA_MESSAGE_LIST = "messages";
public static PendingIntent getReplyIntent(Context context, final Account account, final Message message) {
Intent i = new Intent(context, NotificationActionService.class);
@ -37,15 +37,15 @@ public class NotificationActionService extends CoreService {
}
public static PendingIntent getReadAllMessagesIntent(Context context, final Account account, final Collection<Message> messages) {
ArrayList<Long> messageIds = new ArrayList<Long>();
ArrayList<MessageReference> refs = new ArrayList<MessageReference>();
for (Message m : messages) {
messageIds.add(m.getId());
refs.add(m.makeMessageReference());
}
Intent i = new Intent(context, NotificationActionService.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
i.putExtra(EXTRA_MESSAGE_IDS, messageIds);
i.putExtra(EXTRA_MESSAGE_LIST, refs);
i.setAction(READ_ALL_ACTION);
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
@ -64,9 +64,11 @@ public class NotificationActionService extends CoreService {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "NotificationActionService marking messages as read");
ArrayList<Long> messageIds = (ArrayList<Long>) intent.getSerializableExtra(EXTRA_MESSAGE_IDS);
controller.setFlag(account, messageIds, Flag.SEEN, true, false);
ArrayList<MessageReference> refs = (ArrayList<MessageReference>)
intent.getSerializableExtra(EXTRA_MESSAGE_LIST);
for (MessageReference ref : refs) {
controller.setFlag(account, ref.folderName, ref.uid, Flag.SEEN, true);
}
} else if (REPLY_ACTION.equals(intent.getAction())) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "NotificationActionService initiating reply");