mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Changed import code to set "defaultAccountUuid" if necessary
This commit is contained in:
parent
8240d7ff10
commit
237302cc2b
@ -1162,12 +1162,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
|
|
||||||
private class ImportAsyncTask extends AsyncTask<Void, Void, Boolean> {
|
private class ImportAsyncTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
private boolean mIncludeGlobals;
|
private boolean mIncludeGlobals;
|
||||||
private Set<String> mAccountUuids;
|
private List<String> mAccountUuids;
|
||||||
private boolean mOverwrite;
|
private boolean mOverwrite;
|
||||||
private String mEncryptionKey;
|
private String mEncryptionKey;
|
||||||
private InputStream mInputStream;
|
private InputStream mInputStream;
|
||||||
|
|
||||||
private ImportAsyncTask(boolean includeGlobals, Set<String> accountUuids,
|
private ImportAsyncTask(boolean includeGlobals, List<String> accountUuids,
|
||||||
boolean overwrite, String encryptionKey, InputStream is) {
|
boolean overwrite, String encryptionKey, InputStream is) {
|
||||||
mIncludeGlobals = includeGlobals;
|
mIncludeGlobals = includeGlobals;
|
||||||
mAccountUuids = accountUuids;
|
mAccountUuids = accountUuids;
|
||||||
@ -1290,7 +1290,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
SparseBooleanArray pos = importSelectionView.getCheckedItemPositions();
|
SparseBooleanArray pos = importSelectionView.getCheckedItemPositions();
|
||||||
|
|
||||||
boolean includeGlobals = mImportContents.globalSettings ? pos.get(0) : false;
|
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++) {
|
for (int i = 1; i < count; i++) {
|
||||||
if (pos.get(i)) {
|
if (pos.get(i)) {
|
||||||
accountUuids.add(mImportContents.accounts.get(i-1).uuid);
|
accountUuids.add(mImportContents.accounts.get(i-1).uuid);
|
||||||
|
@ -7,7 +7,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
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);
|
return new ImportContents(globalSettings, accounts);
|
||||||
|
|
||||||
} catch (StorageImportExportException e) {
|
} catch (StorageImportExportException e) {
|
||||||
@ -127,7 +128,7 @@ public class StorageImporter {
|
|||||||
* @throws StorageImportExportException
|
* @throws StorageImportExportException
|
||||||
*/
|
*/
|
||||||
public static void importSettings(Context context, InputStream inputStream, String encryptionKey,
|
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 {
|
throws StorageImportExportException {
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -160,6 +161,7 @@ public class StorageImporter {
|
|||||||
accountUuid + ". But this account wasn't found.");
|
accountUuid + ". But this account wasn't found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newUuids.size() > 0) {
|
if (newUuids.size() > 0) {
|
||||||
String oldAccountUuids = storage.getString("accountUuids", "");
|
String oldAccountUuids = storage.getString("accountUuids", "");
|
||||||
String appendUuids = Utility.combine(newUuids.toArray(new String[0]), ',');
|
String appendUuids = Utility.combine(newUuids.toArray(new String[0]), ',');
|
||||||
@ -169,6 +171,12 @@ public class StorageImporter {
|
|||||||
}
|
}
|
||||||
editor.putString("accountUuids", prefix + appendUuids);
|
editor.putString("accountUuids", prefix + appendUuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String defaultAccountUuid = storage.getString("defaultAccountUuid", null);
|
||||||
|
if (defaultAccountUuid == null) {
|
||||||
|
editor.putString("defaultAccountUuid", accountUuids.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.w(K9.LOG_TAG, "Was asked to import at least one account but none found.");
|
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,
|
private static Imported parseSettings(InputStream inputStream, boolean globalSettings,
|
||||||
Set<String> accountUuids, boolean overwrite, boolean overview)
|
List<String> accountUuids, boolean overwrite, boolean overview)
|
||||||
throws StorageImportExportException {
|
throws StorageImportExportException {
|
||||||
|
|
||||||
if (!overview && accountUuids == null) {
|
if (!overview && accountUuids == null) {
|
||||||
@ -427,7 +435,7 @@ public class StorageImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Imported parseRoot(XmlPullParser xpp, boolean globalSettings,
|
private static Imported parseRoot(XmlPullParser xpp, boolean globalSettings,
|
||||||
Set<String> accountUuids, boolean overview)
|
List<String> accountUuids, boolean overview)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
|
|
||||||
Imported result = new Imported();
|
Imported result = new Imported();
|
||||||
@ -507,7 +515,7 @@ public class StorageImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, ImportedAccount> parseAccounts(XmlPullParser xpp,
|
private static Map<String, ImportedAccount> parseAccounts(XmlPullParser xpp,
|
||||||
Set<String> accountUuids, boolean overview)
|
List<String> accountUuids, boolean overview)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
|
|
||||||
Map<String, ImportedAccount> accounts = null;
|
Map<String, ImportedAccount> accounts = null;
|
||||||
@ -541,7 +549,7 @@ public class StorageImporter {
|
|||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImportedAccount parseAccount(XmlPullParser xpp, Set<String> accountUuids,
|
private static ImportedAccount parseAccount(XmlPullParser xpp, List<String> accountUuids,
|
||||||
boolean overview)
|
boolean overview)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user