diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 5e1ff4956..e09453e9b 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -2410,7 +2410,7 @@ public class MessagingController implements Runnable { if (messages.isEmpty()) { return; } - remoteFolder.setFlags(messages, Collections.singletonList(flag), newState); + remoteFolder.setFlags(messages, Collections.singleton(flag), newState); } finally { closeFolder(remoteFolder); } @@ -2602,7 +2602,7 @@ public class MessagingController implements Runnable { return; } - remoteFolder.setFlags(Collections.singletonList(Flag.SEEN), true); + remoteFolder.setFlags(Collections.singleton(Flag.SEEN), true); remoteFolder.close(); } catch (UnsupportedOperationException uoe) { Log.w(K9.LOG_TAG, "Could not mark all server-side as read because store doesn't support operation", uoe); @@ -2878,7 +2878,7 @@ public class MessagingController implements Runnable { } // Update the messages in the local store - localFolder.setFlags(messages, Collections.singletonList(flag), newState); + localFolder.setFlags(messages, Collections.singleton(flag), newState); int unreadMessageCount = localFolder.getUnreadMessageCount(); for (MessagingListener l : getListeners()) { diff --git a/src/com/fsck/k9/mail/Folder.java b/src/com/fsck/k9/mail/Folder.java index 7d838ea43..88af1a31a 100644 --- a/src/com/fsck/k9/mail/Folder.java +++ b/src/com/fsck/k9/mail/Folder.java @@ -130,10 +130,10 @@ public abstract class Folder { } } - public abstract void setFlags(List messages, Collection flags, boolean value) + public abstract void setFlags(List messages, Set flags, boolean value) throws MessagingException; - public abstract void setFlags(Collection flags, boolean value) throws MessagingException; + public abstract void setFlags(Set flags, boolean value) throws MessagingException; public abstract String getUidFromMessageId(Message message) throws MessagingException; diff --git a/src/com/fsck/k9/mail/Message.java b/src/com/fsck/k9/mail/Message.java index d09c7b1a3..5a4d7a34a 100644 --- a/src/com/fsck/k9/mail/Message.java +++ b/src/com/fsck/k9/mail/Message.java @@ -210,8 +210,8 @@ public abstract class Message implements Part, CompositeBody { /* * TODO Refactor Flags at some point to be able to store user defined flags. */ - public Collection getFlags() { - return Collections.unmodifiableCollection(mFlags); + public Set getFlags() { + return Collections.unmodifiableSet(mFlags); } /** @@ -235,7 +235,7 @@ public abstract class Message implements Part, CompositeBody { * @param flags * @param set */ - public void setFlags(final Collection flags, boolean set) throws MessagingException { + public void setFlags(final Set flags, boolean set) throws MessagingException { for (Flag flag : flags) { setFlag(flag, set); } diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index acfe04aa2..9042f9d9b 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -2110,7 +2110,7 @@ public class ImapStore extends Store { @Override - public void setFlags(Collection flags, boolean value) + public void setFlags(Set flags, boolean value) throws MessagingException { open(OPEN_MODE_RW); checkOpen(); @@ -2145,7 +2145,7 @@ public class ImapStore extends Store { @Override - public void setFlags(List messages, final Collection flags, boolean value) + public void setFlags(List messages, final Set flags, boolean value) throws MessagingException { open(OPEN_MODE_RW); checkOpen(); @@ -2911,7 +2911,7 @@ public class ImapStore extends Store { @Override public void setFlag(Flag flag, boolean set) throws MessagingException { super.setFlag(flag, set); - mFolder.setFlags(Collections.singletonList(this), Collections.singletonList(flag), set); + mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set); } @Override diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 0a2ca179a..5e2ee632a 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -977,12 +977,12 @@ public class Pop3Store extends Store { } @Override - public void setFlags(final Collection flags, boolean value) throws MessagingException { - throw new UnsupportedOperationException("POP3: No setFlags(Collection,boolean)"); + public void setFlags(final Set flags, boolean value) throws MessagingException { + throw new UnsupportedOperationException("POP3: No setFlags(Set,boolean)"); } @Override - public void setFlags(List messages, final Collection flags, boolean value) + public void setFlags(List messages, final Set flags, boolean value) throws MessagingException { if (!value || !flags.contains(Flag.DELETED)) { /* @@ -1187,7 +1187,7 @@ public class Pop3Store extends Store { @Override public void setFlag(Flag flag, boolean set) throws MessagingException { super.setFlag(flag, set); - mFolder.setFlags(Collections.singletonList(this), Collections.singletonList(flag), set); + mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set); } @Override diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index a58a82779..27d0c7ccb 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -1781,7 +1781,7 @@ public class WebDavStore extends Store { } @Override - public void setFlags(List messages, final Collection flags, boolean value) + public void setFlags(List messages, final Set flags, boolean value) throws MessagingException { String[] uids = new String[messages.size()]; @@ -1929,9 +1929,9 @@ public class WebDavStore extends Store { } @Override - public void setFlags(final Collection flags, boolean value) throws MessagingException { + public void setFlags(final Set flags, boolean value) throws MessagingException { Log.e(K9.LOG_TAG, - "Unimplemented method setFlags(Collection, boolean) breaks markAllMessagesAsRead and EmptyTrash"); + "Unimplemented method setFlags(Set, boolean) breaks markAllMessagesAsRead and EmptyTrash"); // Try to make this efficient by not retrieving all of the messages } } @@ -2029,7 +2029,7 @@ public class WebDavStore extends Store { @Override public void setFlag(Flag flag, boolean set) throws MessagingException { super.setFlag(flag, set); - mFolder.setFlags(Collections.singletonList(this), Collections.singletonList(flag), set); + mFolder.setFlags(Collections.singletonList(this), Collections.singleton(flag), set); } } diff --git a/src/com/fsck/k9/mail/store/local/LocalFolder.java b/src/com/fsck/k9/mail/store/local/LocalFolder.java index 9a1058099..bc5895f04 100644 --- a/src/com/fsck/k9/mail/store/local/LocalFolder.java +++ b/src/com/fsck/k9/mail/store/local/LocalFolder.java @@ -1724,7 +1724,7 @@ public class LocalFolder extends Folder implements Serializable { } @Override - public void setFlags(final List messages, final Collection flags, final boolean value) + public void setFlags(final List messages, final Set flags, final boolean value) throws MessagingException { open(OPEN_MODE_RW); @@ -1752,7 +1752,7 @@ public class LocalFolder extends Folder implements Serializable { } @Override - public void setFlags(final Collection flags, boolean value) + public void setFlags(final Set flags, boolean value) throws MessagingException { open(OPEN_MODE_RW); for (Message message : getMessages(null)) {