adapt backup dialog to allow to select to export all accounts

This commit is contained in:
adbenitez
2023-10-10 16:56:13 +02:00
committed by bjoern
parent 48dee710ab
commit 53e228ca80
2 changed files with 16 additions and 2 deletions
+1
View File
@@ -677,6 +677,7 @@
<string name="pref_backup">Backup</string>
<string name="pref_backup_explain">Back Up Chats to External Storage</string>
<string name="pref_backup_export_explain">A backup helps you to set up a new installation on this or on another device.\n\nThe backup will contain all messages, contacts and chats and your end-to-end Autocrypt setup. Keep the backup file in a safe place or delete it as soon as possible.</string>
<string name="pref_backup_export_all">Backup all accounts</string>
<string name="pref_backup_export_start_button">Start Backup</string>
<string name="pref_backup_written_to_x">Backup written successfully to \"%1$s\".</string>
<string name="pref_managekeys_menu_title">Manage Keys</string>
@@ -265,6 +265,13 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
}
private void performBackup() {
View gl = View.inflate(getActivity(), R.layout.dialog_with_checkbox, null);
CheckBox confirmCheckbox = gl.findViewById(R.id.dialog_checkbox);
TextView msg = gl.findViewById(R.id.dialog_message);
msg.setText(getString(R.string.pref_backup_export_explain));
confirmCheckbox.setText(R.string.pref_backup_export_all);
Permissions.with(getActivity())
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE) // READ_EXTERNAL_STORAGE required to read folder contents and to generate backup names
.alwaysGrantOnSdk30()
@@ -273,9 +280,15 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
.onAllGranted(() -> {
new AlertDialog.Builder(getActivity())
.setTitle(R.string.pref_backup)
.setMessage(R.string.pref_backup_export_explain)
.setView(gl)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(R.string.pref_backup_export_start_button, (dialogInterface, i) -> startImex(DcContext.DC_IMEX_EXPORT_BACKUP))
.setPositiveButton(R.string.pref_backup_export_start_button, (dialogInterface, i) -> {
if (confirmCheckbox.isChecked()) {
// TODO: backup all accounts
} else {
startImex(DcContext.DC_IMEX_EXPORT_BACKUP);
}
})
.show();
})
.execute();