diff --git a/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java b/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java index e4c7c38bf..c2688a641 100644 --- a/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java @@ -13,6 +13,7 @@ import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.preference.ListPreference; import androidx.preference.Preference; @@ -31,6 +32,7 @@ import com.google.common.primitives.Longs; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; +import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.ui.activity.SettingsActivity; import eu.siacs.conversations.utils.ChatBackgroundHelper; @@ -187,6 +189,23 @@ public class BackupSettingsFragment extends XmppPreferenceFragment { } private boolean onBackupPreferenceClicked(final Preference preference) { + new AlertDialog.Builder(requireActivity()) + .setTitle("Disable accounts") + .setMessage("Do you want to disable your accounts before making a backup (recommended)?") + .setPositiveButton(R.string.yes, (dialog, whichButton) -> { + for (final var account : requireService().getAccounts()) { + account.setOption(Account.OPTION_DISABLED, true); + if (!requireService().updateAccount(account)) { + Toast.makeText(requireActivity(), R.string.unable_to_update_account, Toast.LENGTH_SHORT).show(); + } + } + aboutToStartOneOffBackup(); + }) + .setNegativeButton(R.string.no, (dialog, whichButton) -> aboutToStartOneOffBackup()).show(); + return true; + } + + private void aboutToStartOneOffBackup() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { if (ContextCompat.checkSelfPermission( requireContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) @@ -198,7 +217,6 @@ public class BackupSettingsFragment extends XmppPreferenceFragment { } else { startOneOffBackup(); } - return true; } private void startOneOffBackup() { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 55e8ed3a0..dcfddefad 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1342,4 +1342,5 @@ Export Data (experimental) Export data useful for importing into another app. Not a full backup. Your request has been sent to the moderators + Full backups are meant for restore after a device loss, or for migrating to a new device. You cannot restore a backup to another app while still being connected with this one! \ No newline at end of file diff --git a/src/main/res/xml/preferences_backup.xml b/src/main/res/xml/preferences_backup.xml index ff497016d..1c50248e8 100644 --- a/src/main/res/xml/preferences_backup.xml +++ b/src/main/res/xml/preferences_backup.xml @@ -1,6 +1,10 @@ + +