mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
Make flag operations work on all messages in a thread
This commit is contained in:
parent
7a266dcbdf
commit
02aeccdedc
@ -2569,7 +2569,28 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void setFlagForThreads(final Message[] messages, final Flag flag,
|
||||
final boolean newState) {
|
||||
|
||||
actOnMessages(messages, new MessageActor() {
|
||||
@Override
|
||||
public void act(final Account account, final Folder folder,
|
||||
final List<Message> accountMessages) {
|
||||
|
||||
try {
|
||||
List<Message> messagesInThreads = collectMessagesInThreads(account,
|
||||
accountMessages);
|
||||
|
||||
setFlag(account, folder.getName(),
|
||||
messagesInThreads.toArray(EMPTY_MESSAGE_ARRAY), flag, newState);
|
||||
|
||||
} catch (MessagingException e) {
|
||||
addErrorMessage(account, "Something went wrong in setFlagForThreads()", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3585,16 +3606,7 @@ public class MessagingController implements Runnable {
|
||||
List<Message> messages) {
|
||||
|
||||
try {
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
|
||||
List<Message> messagesToDelete = new ArrayList<Message>();
|
||||
for (Message message : messages) {
|
||||
long rootId = ((LocalMessage) message).getRootId();
|
||||
long threadId = (rootId == -1) ? message.getId() : rootId;
|
||||
|
||||
Message[] messagesInThread = localStore.getMessagesInThread(threadId);
|
||||
Collections.addAll(messagesToDelete, messagesInThread);
|
||||
}
|
||||
List<Message> messagesToDelete = collectMessagesInThreads(account, messages);
|
||||
|
||||
deleteMessagesSynchronous(account, folderName,
|
||||
messagesToDelete.toArray(EMPTY_MESSAGE_ARRAY), null);
|
||||
@ -3603,6 +3615,23 @@ public class MessagingController implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Message> collectMessagesInThreads(Account account, List<Message> messages)
|
||||
throws MessagingException {
|
||||
|
||||
LocalStore localStore = account.getLocalStore();
|
||||
|
||||
List<Message> messagesInThreads = new ArrayList<Message>();
|
||||
for (Message message : messages) {
|
||||
long rootId = ((LocalMessage) message).getRootId();
|
||||
long threadId = (rootId == -1) ? message.getId() : rootId;
|
||||
|
||||
Message[] messagesInThread = localStore.getMessagesInThread(threadId);
|
||||
Collections.addAll(messagesInThreads, messagesInThread);
|
||||
}
|
||||
|
||||
return messagesInThreads;
|
||||
}
|
||||
|
||||
public void deleteMessages(final Message[] messages, final MessagingListener listener) {
|
||||
actOnMessages(messages, new MessageActor() {
|
||||
|
||||
|
@ -1943,7 +1943,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
return;
|
||||
}
|
||||
|
||||
mController.setFlag(messages, flag, newState);
|
||||
if (mThreadedList) {
|
||||
mController.setFlagForThreads(messages, flag, newState);
|
||||
} else {
|
||||
mController.setFlag(messages, flag, newState);
|
||||
}
|
||||
|
||||
computeBatchDirection();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user