public static Intent createMarkAllAsReadIntent(Context context, String accountUuid, List<MessageReference> messageReferences) { Intent intent = new Intent(context, NotificationActionService.class); intent.setAction(ACTION_MARK_AS_READ); intent.putExtra(EXTRA_ACCOUNT_UUID, accountUuid); intent.putExtra(EXTRA_MESSAGE_REFERENCES, toMessageReferenceStringList(messageReferences)); return intent; }
private void extractExtras() { Intent intent = getIntent(); String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT_UUID); List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<MessageReference> messagesToDelete = toMessageReferenceList(messageReferenceStrings); if (accountUuid == null) { throw new IllegalArgumentException(EXTRA_ACCOUNT_UUID + " can't be null"); } if (messagesToDelete == null) { throw new IllegalArgumentException(EXTRA_MESSAGE_REFERENCES + " can't be null"); } if (messagesToDelete.isEmpty()) { throw new IllegalArgumentException(EXTRA_MESSAGE_REFERENCES + " can't be empty"); } Account account = getAccountFromUuid(accountUuid); if (account == null) { throw new IllegalStateException(EXTRA_ACCOUNT_UUID + " couldn't be resolved to an account"); } this.account = account; this.messagesToDelete = messagesToDelete; }
private void deleteMessages(Intent intent, MessagingController controller) { Timber.i("NotificationActionService deleting messages"); List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings); controller.deleteMessages(messageReferences, null); }
private void cancelNotifications(Intent intent, Account account, MessagingController controller) { if (intent.hasExtra(EXTRA_MESSAGE_REFERENCE)) { String messageReferenceString = intent.getStringExtra(EXTRA_MESSAGE_REFERENCE); MessageReference messageReference = MessageReference.parse(messageReferenceString); if (messageReference != null) { controller.cancelNotificationForMessage(account, messageReference); } else { Timber.w("Invalid message reference: %s", messageReferenceString); } } else if (intent.hasExtra(EXTRA_MESSAGE_REFERENCES)) { List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings); for (MessageReference messageReference : messageReferences) { controller.cancelNotificationForMessage(account, messageReference); } } else { controller.cancelNotificationsForAccount(account); } }
public static Intent createDeleteAllMessagesIntent(Context context, String accountUuid, List<MessageReference> messageReferences) { Intent intent = new Intent(context, NotificationActionService.class); intent.setAction(ACTION_DELETE); intent.putExtra(EXTRA_ACCOUNT_UUID, accountUuid); intent.putExtra(EXTRA_MESSAGE_REFERENCES, toMessageReferenceStringList(messageReferences)); return intent; }
private void markMessagesAsRead(Intent intent, Account account, MessagingController controller) { Timber.i("NotificationActionService marking messages as read"); List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings); for (MessageReference messageReference : messageReferences) { String folderServerId = messageReference.getFolderServerId(); String uid = messageReference.getUid(); controller.setFlag(account, folderServerId, uid, Flag.SEEN, true); } }
public static Intent createArchiveAllIntent(Context context, Account account, List<MessageReference> messageReferences) { Intent intent = new Intent(context, NotificationActionService.class); intent.setAction(ACTION_ARCHIVE); intent.putExtra(EXTRA_ACCOUNT_UUID, account.getUuid()); intent.putExtra(EXTRA_MESSAGE_REFERENCES, toMessageReferenceStringList(messageReferences)); return intent; }
private void archiveMessages(Intent intent, Account account, MessagingController controller) { Timber.i("NotificationActionService archiving messages"); String archiveFolderName = account.getArchiveFolder(); if (archiveFolderName == null || (archiveFolderName.equals(account.getSpamFolder()) && K9.confirmSpam()) || !isMovePossible(controller, account, archiveFolderName)) { Timber.w("Can not archive messages"); return; } List<String> messageReferenceStrings = intent.getStringArrayListExtra(EXTRA_MESSAGE_REFERENCES); List<MessageReference> messageReferences = toMessageReferenceList(messageReferenceStrings); for (MessageReference messageReference : messageReferences) { if (controller.isMoveCapable(messageReference)) { String sourceFolderName = messageReference.getFolderServerId(); controller.moveMessage(account, sourceFolderName, messageReference, archiveFolderName); } } }
public static Intent getIntent(Context context, List<MessageReference> messageReferences) { String accountUuid = messageReferences.get(0).getAccountUuid(); Intent intent = new Intent(context, NotificationDeleteConfirmation.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(EXTRA_ACCOUNT_UUID, accountUuid); intent.putExtra(EXTRA_MESSAGE_REFERENCES, toMessageReferenceStringList(messageReferences)); return intent; }