Bakup warnings
This commit is contained in:
parent
fb4f2099f3
commit
1b57462cdb
3 changed files with 24 additions and 1 deletions
|
@ -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() {
|
||||
|
|
|
@ -1342,4 +1342,5 @@
|
|||
<string name="pref_export">Export Data (experimental)</string>
|
||||
<string name="pref_export_summary">Export data useful for importing into another app. Not a full backup.</string>
|
||||
<string name="request_to_speak_send">Your request has been sent to the moderators</string>
|
||||
<string name="pref_create_backup_warning">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!</string>
|
||||
</resources>
|
|
@ -1,6 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="backup_warning"
|
||||
android:summary="@string/pref_create_backup_warning" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@integer/automatic_message_deletion"
|
||||
android:icon="@drawable/ic_calendar_month_24dp"
|
||||
|
|
Loading…
Reference in a new issue