use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationWithCreateNotification.
@Test
public void testRemoveNewMailNotificationWithCreateNotification() throws Exception {
MessageReference messageReference = createMessageReference(1);
int notificationIndex = 0;
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
LocalMessage message = createLocalMessage();
NotificationContent contentOne = createNotificationContent();
NotificationContent contentTwo = createNotificationContent();
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationIndex);
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationIndex);
addToNotificationContentCreator(message, contentOne);
whenAddingContentReturn(contentOne, AddNotificationResult.newNotification(holderOne));
Notification summaryNotification = createNotification();
addToDeviceNotifications(summaryNotification);
Notification wearNotificationOne = createNotification();
Notification wearNotificationTwo = createNotification();
addToWearNotifications(holderOne, wearNotificationOne);
addToWearNotifications(holderTwo, wearNotificationTwo);
newMailNotifications.addNewMailNotification(account, message, 23);
whenRemovingContentReturn(messageReference, RemoveNotificationResult.createNotification(holderTwo));
newMailNotifications.removeNewMailNotification(account, messageReference);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager).notify(notificationId, wearNotificationTwo);
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class MessageProvider method delete.
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
if (K9.app == null) {
return 0;
}
Timber.v("MessageProvider/delete: %s", uri);
// Note: can only delete a message
List<String> segments = uri.getPathSegments();
int accountId = Integer.parseInt(segments.get(1));
String folderName = segments.get(2);
String msgUid = segments.get(3);
// get account
Account myAccount = null;
for (Account account : Preferences.getPreferences(getContext()).getAccounts()) {
if (account.getAccountNumber() == accountId) {
myAccount = account;
if (!account.isAvailable(getContext())) {
Timber.w("not deleting messages because account is unavailable at the moment");
return 0;
}
}
}
if (myAccount == null) {
Timber.e("Could not find account with id %d", accountId);
}
if (myAccount != null) {
MessageReference messageReference = new MessageReference(myAccount.getUuid(), folderName, msgUid, null);
MessagingController controller = MessagingController.getInstance(getContext());
controller.deleteMessage(messageReference, null);
}
// FIXME return the actual number of deleted messages
return 0;
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class MessagingController method actOnMessageGroup.
private void actOnMessageGroup(Account account, long folderId, List<MessageReference> messageReferences, MessageActor actor) {
try {
LocalFolder messageFolder = localStoreProvider.getInstance(account).getFolder(folderId);
List<LocalMessage> localMessages = messageFolder.getMessagesByReference(messageReferences);
actor.act(account, messageFolder, localMessages);
} catch (MessagingException e) {
Timber.e(e, "Error loading account?!");
}
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class MessagingController method deleteDraft.
public void deleteDraft(final Account account, long id) {
try {
Long folderId = account.getDraftsFolderId();
if (folderId == null) {
Timber.w("No Drafts folder configured. Can't delete draft.");
return;
}
LocalStore localStore = localStoreProvider.getInstance(account);
LocalFolder localFolder = localStore.getFolder(folderId);
localFolder.open();
String uid = localFolder.getMessageUidById(id);
if (uid != null) {
MessageReference messageReference = new MessageReference(account.getUuid(), folderId, uid);
deleteMessage(messageReference);
}
} catch (MessagingException me) {
Timber.e(me, "Error deleting draft");
}
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class LocalMessage method makeMessageReference.
public MessageReference makeMessageReference() {
if (messageReference == null) {
String accountUuid = getFolder().getAccountUuid();
long folderId = getFolder().getDatabaseId();
messageReference = new MessageReference(accountUuid, folderId, mUid);
}
return messageReference;
}
Aggregations