Add support for properly importing/exporting "Auto-expand folder" = "None"
This commit is contained in:
parent
835eb6a7cc
commit
1fe6b454cd
4 changed files with 24 additions and 7 deletions
|
@ -25,9 +25,13 @@ class AutoExpandFolderBackendFoldersRefreshListener(
|
|||
}
|
||||
|
||||
private fun checkAutoExpandFolder() {
|
||||
val folderId = account.importedAutoExpandFolder?.let { folderRepository.getFolderId(account, it) }
|
||||
if (folderId != null) {
|
||||
account.autoExpandFolderId = folderId
|
||||
account.importedAutoExpandFolder?.let { folderName ->
|
||||
if (folderName.isEmpty()) {
|
||||
account.autoExpandFolderId = null
|
||||
} else {
|
||||
val folderId = folderRepository.getFolderId(account, folderName)
|
||||
account.autoExpandFolderId = folderId
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ public class AccountSettingsDescriptions {
|
|||
new V(53, new StringSetting(null))
|
||||
));
|
||||
s.put("autoExpandFolderName", Settings.versions(
|
||||
new V(1, new StringSetting("INBOX"))
|
||||
new V(1, new StringSetting("INBOX")),
|
||||
new V(78, new StringSetting(null))
|
||||
));
|
||||
s.put("automaticCheckIntervalMinutes", Settings.versions(
|
||||
new V(1, new IntegerResourceSetting(-1, R.array.check_frequency_values)),
|
||||
|
|
|
@ -36,7 +36,7 @@ public class Settings {
|
|||
*
|
||||
* @see SettingsExporter
|
||||
*/
|
||||
public static final int VERSION = 77;
|
||||
public static final int VERSION = 78;
|
||||
|
||||
static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription>> settings,
|
||||
Map<String, String> importedSettings, boolean useDefaultValues) {
|
||||
|
|
|
@ -268,17 +268,29 @@ class SettingsExporter(
|
|||
folderRepository: FolderRepository,
|
||||
serializer: XmlSerializer
|
||||
) {
|
||||
fun writeFolderNameSetting(key: String, folderId: Long?, importedFolderServerId: String?) {
|
||||
fun writeFolderNameSetting(
|
||||
key: String,
|
||||
folderId: Long?,
|
||||
importedFolderServerId: String?,
|
||||
writeEmptyValue: Boolean = false
|
||||
) {
|
||||
val folderServerId = folderId?.let {
|
||||
folderRepository.getFolderServerId(account, folderId)
|
||||
} ?: importedFolderServerId
|
||||
|
||||
if (folderServerId != null) {
|
||||
writeAccountSettingIfValid(serializer, key, folderServerId, account)
|
||||
} else if (writeEmptyValue) {
|
||||
writeAccountSettingIfValid(serializer, key, valueString = "", account)
|
||||
}
|
||||
}
|
||||
|
||||
writeFolderNameSetting("autoExpandFolderName", account.autoExpandFolderId, account.importedAutoExpandFolder)
|
||||
writeFolderNameSetting(
|
||||
"autoExpandFolderName",
|
||||
account.autoExpandFolderId,
|
||||
account.importedAutoExpandFolder,
|
||||
writeEmptyValue = true
|
||||
)
|
||||
writeFolderNameSetting("archiveFolderName", account.archiveFolderId, account.importedArchiveFolder)
|
||||
writeFolderNameSetting("draftsFolderName", account.draftsFolderId, account.importedDraftsFolder)
|
||||
writeFolderNameSetting("sentFolderName", account.sentFolderId, account.importedSentFolder)
|
||||
|
|
Loading…
Reference in a new issue