From 6cb1a608049d7aa4e2888e707dddf4f06e59a53d Mon Sep 17 00:00:00 2001 From: Moksh Jain Date: Mon, 1 Jan 2018 22:26:32 +0530 Subject: [PATCH] Fix: import/export maintains account order --- .../main/java/com/fsck/k9/preferences/SettingsExporter.java | 3 ++- .../main/java/com/fsck/k9/preferences/SettingsImporter.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/SettingsExporter.java b/k9mail/src/main/java/com/fsck/k9/preferences/SettingsExporter.java index af4593857..936ea19f7 100644 --- a/k9mail/src/main/java/com/fsck/k9/preferences/SettingsExporter.java +++ b/k9mail/src/main/java/com/fsck/k9/preferences/SettingsExporter.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -155,7 +156,7 @@ public class SettingsExporter { Set exportAccounts; if (accountUuids == null) { List accounts = preferences.getAccounts(); - exportAccounts = new HashSet<>(); + exportAccounts = new LinkedHashSet<>(); for (Account account : accounts) { exportAccounts.add(account.getUuid()); } diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java b/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java index 109a0ce06..cef79918e 100644 --- a/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java +++ b/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java @@ -7,6 +7,7 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -804,7 +805,7 @@ public class SettingsImporter { String element = xpp.getName(); if (SettingsExporter.ACCOUNT_ELEMENT.equals(element)) { if (accounts == null) { - accounts = new HashMap<>(); + accounts = new LinkedHashMap<>(); } ImportedAccount account = parseAccount(xpp, accountUuids, overview);