mirror of
https://github.com/thunderbird/thunderbird-android.git
synced 2024-09-19 19:52:14 +02:00
[SettingsExporter] Move code to update notification settings
This commit is contained in:
parent
a933d17770
commit
ce1943e8cd
@ -30,8 +30,6 @@ class SettingsExporter(
|
||||
) {
|
||||
@Throws(SettingsImportExportException::class)
|
||||
fun exportToUri(includeGlobals: Boolean, accountUuids: Set<String>, 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<String>) {
|
||||
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<String>) {
|
||||
updateNotificationSettings(accountUuids)
|
||||
|
||||
try {
|
||||
val serializer = Xml.newSerializer()
|
||||
serializer.setOutput(outputStream, "UTF-8")
|
||||
@ -93,6 +83,16 @@ class SettingsExporter(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateNotificationSettings(accountUuids: Set<String>) {
|
||||
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<String, Any>) {
|
||||
for ((key, versions) in GeneralSettingsDescriptions.SETTINGS) {
|
||||
val valueString = prefs[key] as String?
|
||||
|
Loading…
Reference in New Issue
Block a user