mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 14:18:02 -05:00
Be more careful when deleting an account
Fixes issue 3954
This commit is contained in:
parent
d955482c13
commit
37b26ffe84
@ -18,6 +18,7 @@ import com.fsck.k9.mail.store.StorageManager;
|
|||||||
import com.fsck.k9.mail.store.StorageManager.StorageProvider;
|
import com.fsck.k9.mail.store.StorageManager.StorageProvider;
|
||||||
import com.fsck.k9.view.ColorChip;
|
import com.fsck.k9.view.ColorChip;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -401,18 +402,24 @@ public class Account implements BaseAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void delete(Preferences preferences) {
|
protected synchronized void delete(Preferences preferences) {
|
||||||
|
// Get the list of account UUIDs
|
||||||
String[] uuids = preferences.getPreferences().getString("accountUuids", "").split(",");
|
String[] uuids = preferences.getPreferences().getString("accountUuids", "").split(",");
|
||||||
String[] newUuids = new String[uuids.length - 1];
|
|
||||||
int i = 0;
|
// Create a list of all account UUIDs excluding this account
|
||||||
|
List<String> newUuids = new ArrayList<String>(uuids.length);
|
||||||
for (String uuid : uuids) {
|
for (String uuid : uuids) {
|
||||||
if (uuid.equals(mUuid) == false) {
|
if (!uuid.equals(mUuid)) {
|
||||||
newUuids[i++] = uuid;
|
newUuids.add(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String accountUuids = Utility.combine(newUuids, ',');
|
|
||||||
SharedPreferences.Editor editor = preferences.getPreferences().edit();
|
SharedPreferences.Editor editor = preferences.getPreferences().edit();
|
||||||
editor.putString("accountUuids", accountUuids);
|
|
||||||
|
// Only change the 'accountUuids' value if this account's UUID was listed before
|
||||||
|
if (newUuids.size() < uuids.length) {
|
||||||
|
String accountUuids = Utility.combine(newUuids.toArray(), ',');
|
||||||
|
editor.putString("accountUuids", accountUuids);
|
||||||
|
}
|
||||||
|
|
||||||
editor.remove(mUuid + ".storeUri");
|
editor.remove(mUuid + ".storeUri");
|
||||||
editor.remove(mUuid + ".localStoreUri");
|
editor.remove(mUuid + ".localStoreUri");
|
||||||
|
Loading…
Reference in New Issue
Block a user