diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index c74492dae..f3d8717cc 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -1908,7 +1908,7 @@ public class MessagingController { closeFolder(localFolder); } } - private void queueMoveOrCopy(Account account, String srcFolder, String destFolder, boolean isCopy, String uids[]) { + private void queueMoveOrCopy(Account account, String srcFolder, String destFolder, boolean isCopy, List uids) { if (account.getErrorFolderName().equals(srcFolder)) { return; } @@ -1917,7 +1917,7 @@ public class MessagingController { } private void queueMoveOrCopy(Account account, String srcFolder, String destFolder, - boolean isCopy, String uids[], Map uidMap) { + boolean isCopy, List uids, Map uidMap) { if (uidMap == null || uidMap.isEmpty()) { queueMoveOrCopy(account, srcFolder, destFolder, isCopy, uids); } else { @@ -1948,7 +1948,7 @@ public class MessagingController { localDestFolder = (LocalFolder) localStore.getFolder(destFolder); List messages = new ArrayList<>(); - Collection uids = command.newUidMap != null ? command.newUidMap.keySet() : Arrays.asList(command.uids); + Collection uids = command.newUidMap != null ? command.newUidMap.keySet() : command.uids; for (String uid : uids) { if (!uid.startsWith(K9.LOCAL_UID_PREFIX)) { messages.add(remoteSrcFolder.getMessage(uid)); @@ -2024,7 +2024,7 @@ public class MessagingController { } private void queueSetFlag(final Account account, final String folderName, - final boolean newState, final Flag flag, final String[] uids) { + final boolean newState, final Flag flag, final List uids) { putBackground("queueSetFlag " + account.getDescription() + ":" + folderName, null, new Runnable() { @Override public void run() { @@ -2322,9 +2322,7 @@ public class MessagingController { } // Send flag change to server - List value = entry.getValue(); - String[] uids = value.toArray(new String[value.size()]); - queueSetFlag(account, folderName, newState, flag, uids); + queueSetFlag(account, folderName, newState, flag, entry.getValue()); processPendingCommands(account); } } @@ -2387,11 +2385,7 @@ public class MessagingController { return; } - String[] uids = new String[messages.size()]; - for (int i = 0, end = uids.length; i < end; i++) { - uids[i] = messages.get(i).getUid(); - } - + List uids = getUidsFromMessages(messages); queueSetFlag(account, folderName, newState, flag, uids); processPendingCommands(account); } catch (MessagingException me) { @@ -3234,8 +3228,8 @@ public class MessagingController { } } - Set origUidKeys = origUidMap.keySet(); - queueMoveOrCopy(account, srcFolder, destFolder, isCopy, origUidKeys.toArray(new String[origUidKeys.size()]), uidMap); + List origUidKeys = new ArrayList<>(origUidMap.keySet()); + queueMoveOrCopy(account, srcFolder, destFolder, isCopy, origUidKeys, uidMap); } processPendingCommands(account); @@ -3378,7 +3372,7 @@ public class MessagingController { MessagingListener listener) { Folder localFolder = null; Folder localTrashFolder = null; - String[] uids = getUidsFromMessages(messages); + List uids = getUidsFromMessages(messages); try { //We need to make these callbacks before moving the messages to the trash //as messages get a new UID after being moved @@ -3456,10 +3450,10 @@ public class MessagingController { } } - private static String[] getUidsFromMessages(List messages) { - String[] uids = new String[messages.size()]; + private static List getUidsFromMessages(List messages) { + List uids = new ArrayList<>(messages.size()); for (int i = 0; i < messages.size(); i++) { - uids[i] = messages.get(i).getUid(); + uids.add(messages.get(i).getUid()); } return uids; } diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingControllerCommands.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingControllerCommands.java index ef8c1bf55..b2d0fed66 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingControllerCommands.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingControllerCommands.java @@ -1,6 +1,7 @@ package com.fsck.k9.controller; +import java.util.List; import java.util.Map; import com.fsck.k9.mail.Flag; @@ -15,7 +16,7 @@ public class MessagingControllerCommands { static final String COMMAND_EMPTY_TRASH = "empty_trash"; - public static PendingSetFlag createSetFlag(String folder, boolean newState, Flag flag, String[] uids) { + public static PendingSetFlag createSetFlag(String folder, boolean newState, Flag flag, List uids) { return new PendingSetFlag(folder, newState, flag, uids); } @@ -39,7 +40,7 @@ public class MessagingControllerCommands { return new PendingMoveOrCopy(srcFolder, destFolder, isCopy, null, uidMap); } - public static PendingMoveOrCopy createMoveOrCopyBulk(String srcFolder, String destFolder, boolean isCopy, String[] uids) { + public static PendingMoveOrCopy createMoveOrCopyBulk(String srcFolder, String destFolder, boolean isCopy, List uids) { return new PendingMoveOrCopy(srcFolder, destFolder, isCopy, uids, null); } @@ -56,11 +57,11 @@ public class MessagingControllerCommands { public final String srcFolder; public final String destFolder; public final boolean isCopy; - public final String[] uids; + public final List uids; public final Map newUidMap; public PendingMoveOrCopy( - String srcFolder, String destFolder, boolean isCopy, String[] uids, Map newUidMap) { + String srcFolder, String destFolder, boolean isCopy, List uids, Map newUidMap) { this.srcFolder = srcFolder; this.destFolder = destFolder; this.isCopy = isCopy; @@ -83,9 +84,9 @@ public class MessagingControllerCommands { public final String folder; public final boolean newState; public final Flag flag; - public final String[] uids; + public final List uids; - public PendingSetFlag(String folder, boolean newState, Flag flag, String[] uids) { + public PendingSetFlag(String folder, boolean newState, Flag flag, List uids) { this.folder = folder; this.newState = newState; this.flag = flag;