Fix assigning account number when Account is first saved (fixes #3787)
This commit is contained in:
parent
05d9315d79
commit
62411ace05
3 changed files with 13 additions and 8 deletions
|
@ -102,6 +102,7 @@ public class Account implements BaseAccount, StoreConfig {
|
||||||
public static final SortType DEFAULT_SORT_TYPE = SortType.SORT_DATE;
|
public static final SortType DEFAULT_SORT_TYPE = SortType.SORT_DATE;
|
||||||
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
||||||
public static final long NO_OPENPGP_KEY = 0;
|
public static final long NO_OPENPGP_KEY = 0;
|
||||||
|
public static final int UNASSIGNED_ACCOUNT_NUMBER = -1;
|
||||||
|
|
||||||
private DeletePolicy deletePolicy = DeletePolicy.NEVER;
|
private DeletePolicy deletePolicy = DeletePolicy.NEVER;
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ class AccountPreferenceSerializer(
|
||||||
|
|
||||||
autoExpandFolder = storage.getString("$accountUuid.autoExpandFolderName", INBOX)
|
autoExpandFolder = storage.getString("$accountUuid.autoExpandFolderName", INBOX)
|
||||||
|
|
||||||
accountNumber = storage.getInt("$accountUuid.accountNumber", 0)
|
accountNumber = storage.getInt("$accountUuid.accountNumber", UNASSIGNED_ACCOUNT_NUMBER)
|
||||||
|
|
||||||
chipColor = storage.getInt("$accountUuid.chipColor", FALLBACK_ACCOUNT_COLOR)
|
chipColor = storage.getInt("$accountUuid.chipColor", FALLBACK_ACCOUNT_COLOR)
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ class AccountPreferenceSerializer(
|
||||||
idleRefreshMinutes = 24
|
idleRefreshMinutes = 24
|
||||||
isPushPollOnConnect = true
|
isPushPollOnConnect = true
|
||||||
displayCount = K9.DEFAULT_VISIBLE_LIMIT
|
displayCount = K9.DEFAULT_VISIBLE_LIMIT
|
||||||
accountNumber = -1
|
accountNumber = UNASSIGNED_ACCOUNT_NUMBER
|
||||||
isNotifyNewMail = true
|
isNotifyNewMail = true
|
||||||
folderNotifyNewMailMode = FolderMode.ALL
|
folderNotifyNewMailMode = FolderMode.ALL
|
||||||
isNotifySync = true
|
isNotifySync = true
|
||||||
|
|
|
@ -203,14 +203,18 @@ public class Preferences {
|
||||||
public void saveAccount(Account account) {
|
public void saveAccount(Account account) {
|
||||||
StorageEditor editor = storage.edit();
|
StorageEditor editor = storage.edit();
|
||||||
|
|
||||||
if (!accounts.containsKey(account.getUuid())) {
|
ensureAssignedAccountNumber(account);
|
||||||
int accountNumber = generateAccountNumber();
|
processChangedValues(account);
|
||||||
account.setAccountNumber(accountNumber);
|
accountPreferenceSerializer.save(storage, editor, account);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureAssignedAccountNumber(Account account) {
|
||||||
|
if (account.getAccountNumber() != Account.UNASSIGNED_ACCOUNT_NUMBER) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
processChangedValues(account);
|
int accountNumber = generateAccountNumber();
|
||||||
|
account.setAccountNumber(accountNumber);
|
||||||
accountPreferenceSerializer.save(storage, editor, account);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processChangedValues(Account account) {
|
private void processChangedValues(Account account) {
|
||||||
|
|
Loading…
Reference in a new issue