1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-17 21:32:26 -05:00

Changed import code to set "defaultAccountUuid" if necessary

This commit is contained in:
cketti 2011-04-19 23:04:43 +02:00
parent 8240d7ff10
commit 237302cc2b
2 changed files with 17 additions and 9 deletions

View File

@ -1162,12 +1162,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
private class ImportAsyncTask extends AsyncTask<Void, Void, Boolean> {
private boolean mIncludeGlobals;
private Set<String> mAccountUuids;
private List<String> mAccountUuids;
private boolean mOverwrite;
private String mEncryptionKey;
private InputStream mInputStream;
private ImportAsyncTask(boolean includeGlobals, Set<String> accountUuids,
private ImportAsyncTask(boolean includeGlobals, List<String> 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<String> accountUuids = new HashSet<String>();
List<String> accountUuids = new ArrayList<String>();
for (int i = 1; i < count; i++) {
if (pos.get(i)) {
accountUuids.add(mImportContents.accounts.get(i-1).uuid);

View File

@ -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<String> accountUuids, boolean overwrite)
boolean globalSettings, List<String> 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<String> accountUuids, boolean overwrite, boolean overview)
List<String> 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<String> accountUuids, boolean overview)
List<String> accountUuids, boolean overview)
throws XmlPullParserException, IOException {
Imported result = new Imported();
@ -507,7 +515,7 @@ public class StorageImporter {
}
private static Map<String, ImportedAccount> parseAccounts(XmlPullParser xpp,
Set<String> accountUuids, boolean overview)
List<String> accountUuids, boolean overview)
throws XmlPullParserException, IOException {
Map<String, ImportedAccount> accounts = null;
@ -541,7 +549,7 @@ public class StorageImporter {
return accounts;
}
private static ImportedAccount parseAccount(XmlPullParser xpp, Set<String> accountUuids,
private static ImportedAccount parseAccount(XmlPullParser xpp, List<String> accountUuids,
boolean overview)
throws XmlPullParserException, IOException {