From 6d67aa4ae7f4dcd8a4f33c9a7cf6287dfa444094 Mon Sep 17 00:00:00 2001 From: merkost Date: Sat, 15 Jul 2023 14:00:47 +1000 Subject: [PATCH] Dialog bug fixed --- .../pro/dialogs/ManageAutoBackupsDialog.kt | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageAutoBackupsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageAutoBackupsDialog.kt index 555370b7..cbddeff0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageAutoBackupsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageAutoBackupsDialog.kt @@ -12,7 +12,6 @@ import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.helpers.ContactsHelper import com.simplemobiletools.commons.helpers.ensureBackgroundThread -import com.simplemobiletools.commons.models.contacts.ContactSource import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.extensions.config @@ -26,21 +25,9 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: ( private val view = (activity.layoutInflater.inflate(R.layout.dialog_manage_automatic_backups, null) as ViewGroup) private val config = activity.config private var backupFolder = config.autoBackupFolder - private var selectedContactTypes = HashSet() - - private fun setContactTypes() { - ContactsHelper(activity).getContactSources { contactSources -> - val availableContactSources = contactSources.toSet() - if (config.autoBackupContactSources.isEmpty()) { - selectedContactTypes = contactSources.toHashSet() - } else { - selectedContactTypes = availableContactSources.filter { it.name in config.autoBackupContactSources }.toHashSet() - } - } - } + private var selectedContactSources = config.autoBackupContactSources init { - setContactTypes() view.apply { backup_events_folder.setText(activity.humanizePath(backupFolder)) val filename = config.autoBackupFilename.ifEmpty { @@ -63,8 +50,8 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: ( manage_event_types_holder.setOnClickListener { activity.runOnUiThread { - SelectContactTypesDialog(activity, selectedContactTypes.map { it.name }) { - selectedContactTypes = it + SelectContactTypesDialog(activity, selectedContactSources.toList()) { + selectedContactSources = it.map { it.name }.toSet() config.autoBackupContactSources = it.map { it.name }.toSet() } } @@ -86,7 +73,7 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: ( return@setOnClickListener } - if (selectedContactTypes.isEmpty()) { + if (selectedContactSources.isEmpty()) { activity.toast(R.string.no_entries_for_exporting) return@setOnClickListener } @@ -95,9 +82,6 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: ( config.apply { autoBackupFolder = backupFolder autoBackupFilename = filename - if (autoBackupContactSources != selectedContactTypes) { - autoBackupContactSources = selectedContactTypes.map { it.type }.toSet() - } } activity.runOnUiThread {