From ce1943e8cd8c1a030b4557057e3dcbc8b068f5a7 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 2 Sep 2024 16:30:09 +0200 Subject: [PATCH] [SettingsExporter] Move code to update notification settings --- .../fsck/k9/preferences/SettingsExporter.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt index ce11bb0cf4..5d4fbf50d1 100644 --- a/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt +++ b/legacy/core/src/main/java/com/fsck/k9/preferences/SettingsExporter.kt @@ -30,8 +30,6 @@ class SettingsExporter( ) { @Throws(SettingsImportExportException::class) fun exportToUri(includeGlobals: Boolean, accountUuids: Set, uri: Uri) { - updateNotificationSettings(accountUuids) - try { contentResolver.openOutputStream(uri, "wt")!!.use { outputStream -> exportPreferences(outputStream, includeGlobals, accountUuids) @@ -41,18 +39,10 @@ class SettingsExporter( } } - private fun updateNotificationSettings(accountUuids: Set) { - try { - notificationSettingsUpdater.updateNotificationSettings(accountUuids) - } catch (e: Exception) { - // An error here could mean we export notification settings that don't reflect the current configuration - // of the notification channels. But we prefer stale data over failing the export. - Timber.w(e, "Error while updating accounts with notification configuration from system") - } - } - @Throws(SettingsImportExportException::class) fun exportPreferences(outputStream: OutputStream, includeGlobals: Boolean, accountUuids: Set) { + updateNotificationSettings(accountUuids) + try { val serializer = Xml.newSerializer() serializer.setOutput(outputStream, "UTF-8") @@ -93,6 +83,16 @@ class SettingsExporter( } } + private fun updateNotificationSettings(accountUuids: Set) { + try { + notificationSettingsUpdater.updateNotificationSettings(accountUuids) + } catch (e: Exception) { + // An error here could mean we export notification settings that don't reflect the current configuration + // of the notification channels. But we prefer stale data over failing the export. + Timber.w(e, "Error while updating accounts with notification configuration from system") + } + } + private fun writeSettings(serializer: XmlSerializer, prefs: Map) { for ((key, versions) in GeneralSettingsDescriptions.SETTINGS) { val valueString = prefs[key] as String?