diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 0e11b11a6..690ec748e 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -1162,12 +1162,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC private class ImportAsyncTask extends AsyncTask { private boolean mIncludeGlobals; - private Set mAccountUuids; + private List mAccountUuids; private boolean mOverwrite; private String mEncryptionKey; private InputStream mInputStream; - private ImportAsyncTask(boolean includeGlobals, Set accountUuids, + private ImportAsyncTask(boolean includeGlobals, List accountUuids, boolean overwrite, String encryptionKey, InputStream is) { mIncludeGlobals = includeGlobals; mAccountUuids = accountUuids; @@ -1290,7 +1290,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC SparseBooleanArray pos = importSelectionView.getCheckedItemPositions(); boolean includeGlobals = mImportContents.globalSettings ? pos.get(0) : false; - Set accountUuids = new HashSet(); + List accountUuids = new ArrayList(); for (int i = 1; i < count; i++) { if (pos.get(i)) { accountUuids.add(mImportContents.accounts.get(i-1).uuid); diff --git a/src/com/fsck/k9/preferences/StorageImporter.java b/src/com/fsck/k9/preferences/StorageImporter.java index 8f7412cc1..bd9e37d36 100644 --- a/src/com/fsck/k9/preferences/StorageImporter.java +++ b/src/com/fsck/k9/preferences/StorageImporter.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import org.xmlpull.v1.XmlPullParser; @@ -105,6 +104,8 @@ public class StorageImporter { } } + //TODO: throw exception if neither global settings nor account settings could be found + return new ImportContents(globalSettings, accounts); } catch (StorageImportExportException e) { @@ -127,7 +128,7 @@ public class StorageImporter { * @throws StorageImportExportException */ public static void importSettings(Context context, InputStream inputStream, String encryptionKey, - boolean globalSettings, Set accountUuids, boolean overwrite) + boolean globalSettings, List accountUuids, boolean overwrite) throws StorageImportExportException { try @@ -160,6 +161,7 @@ public class StorageImporter { accountUuid + ". But this account wasn't found."); } } + if (newUuids.size() > 0) { String oldAccountUuids = storage.getString("accountUuids", ""); String appendUuids = Utility.combine(newUuids.toArray(new String[0]), ','); @@ -169,6 +171,12 @@ public class StorageImporter { } editor.putString("accountUuids", prefix + appendUuids); } + + String defaultAccountUuid = storage.getString("defaultAccountUuid", null); + if (defaultAccountUuid == null) { + editor.putString("defaultAccountUuid", accountUuids.get(0)); + } + } else { Log.w(K9.LOG_TAG, "Was asked to import at least one account but none found."); } @@ -364,7 +372,7 @@ public class StorageImporter { } private static Imported parseSettings(InputStream inputStream, boolean globalSettings, - Set accountUuids, boolean overwrite, boolean overview) + List accountUuids, boolean overwrite, boolean overview) throws StorageImportExportException { if (!overview && accountUuids == null) { @@ -427,7 +435,7 @@ public class StorageImporter { } private static Imported parseRoot(XmlPullParser xpp, boolean globalSettings, - Set accountUuids, boolean overview) + List accountUuids, boolean overview) throws XmlPullParserException, IOException { Imported result = new Imported(); @@ -507,7 +515,7 @@ public class StorageImporter { } private static Map parseAccounts(XmlPullParser xpp, - Set accountUuids, boolean overview) + List accountUuids, boolean overview) throws XmlPullParserException, IOException { Map accounts = null; @@ -541,7 +549,7 @@ public class StorageImporter { return accounts; } - private static ImportedAccount parseAccount(XmlPullParser xpp, Set accountUuids, + private static ImportedAccount parseAccount(XmlPullParser xpp, List accountUuids, boolean overview) throws XmlPullParserException, IOException {