From 77f75011ca5d62c6d9f3e093eb46fbff0af6befc Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 13 Nov 2023 15:34:43 +0100 Subject: [PATCH] Simplification --- .../eu/faircode/email/FragmentMessages.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index a0fdaa199d..a0aa26ea67 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -218,7 +218,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -1695,13 +1694,13 @@ public class FragmentMessages extends FragmentBase if (result == null) return; - if (result.account != null) - onActionMoveSelectionAccount(result.account.id, false, result.folders); + if (result.imapAccounts.size() > 0) + onActionMoveSelectionAccount(result.imapAccounts.get(0).id, false, result.folders); else { PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(v.getContext(), getViewLifecycleOwner(), ibMove); int order = 0; - for (EntityAccount account : result.accounts.keySet()) { + for (EntityAccount account : result.imapAccounts) { order++; popupMenu.getMenu().add(Menu.NONE, order, order, account.name) .setIntent(new Intent().putExtra("account", account.id)); @@ -4165,7 +4164,7 @@ public class FragmentMessages extends FragmentBase .setIcon(R.drawable.twotone_delete_forever_24); if (!result.read_only) { - for (EntityAccount account : result.accounts.keySet()) { + for (EntityAccount account : result.imapAccounts) { String title = getString(R.string.title_move_to_account, account.name); SpannableString ssb = new SpannableString(title); if (account.name != null && account.color != null) { @@ -10676,8 +10675,7 @@ public class FragmentMessages extends FragmentBase Boolean leave_deleted; boolean read_only; List folders; - EntityAccount account; - Map accounts; + List imapAccounts; EntityAccount copyto; boolean canInbox() { @@ -10716,7 +10714,7 @@ public class FragmentMessages extends FragmentBase boolean canMove() { if (read_only) return false; - return (accounts.size() > 0); + return (imapAccounts.size() > 0); } static MoreResult get(Context context, long[] ids, boolean threading, boolean all) { @@ -10863,23 +10861,18 @@ public class FragmentMessages extends FragmentBase if (result.hasTrash == null) result.hasTrash = false; if (result.hasJunk == null) result.hasJunk = false; - if (!result.hasPop && accounts.size() == 1) - result.account = accounts.values().iterator().next(); - - result.accounts = new LinkedHashMap<>(); + result.imapAccounts = new ArrayList<>(); if (!result.hasPop || (accounts.size() == 1 && result.isInbox && !result.isSent)) { List syncing = db.account().getSynchronizingAccounts(EntityAccount.TYPE_IMAP); if (syncing != null) - for (EntityAccount a : syncing) - result.accounts.put(a, accounts.containsKey(a.id)); + result.imapAccounts.addAll(syncing); } if (result.folders.size() > 1) result.folders = new ArrayList<>(); return result; - } }