Fix manual backups with selected default location
This commit is contained in:
parent
356815d7e7
commit
1caa4a67f5
2 changed files with 39 additions and 8 deletions
|
@ -31,6 +31,8 @@ import android.content.IntentSender;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -317,15 +319,40 @@ public class BackupActivity extends BaseActivity {
|
|||
intent.putExtra(Intent.EXTRA_TITLE, BackupHelper.backupFilename(this, backupType));
|
||||
startActivityForResult(intent, intentId);
|
||||
} else {
|
||||
if (Tools.mkdir(settings.getBackupDir())) {
|
||||
if (intentId == Constants.INTENT_BACKUP_SAVE_DOCUMENT_PLAIN)
|
||||
doBackupPlain(Tools.buildUri(settings.getBackupDir(), BackupHelper.backupFilename(this, Constants.BackupType.PLAIN_TEXT)));
|
||||
else if (intentId == Constants.INTENT_BACKUP_SAVE_DOCUMENT_CRYPT)
|
||||
doBackupCrypt(Tools.buildUri(settings.getBackupDir(), BackupHelper.backupFilename(this, Constants.BackupType.ENCRYPTED)));
|
||||
else if (intentId == Constants.INTENT_BACKUP_SAVE_DOCUMENT_PGP)
|
||||
backupEncryptedWithPGP(Tools.buildUri(settings.getBackupDir(), BackupHelper.backupFilename(this, Constants.BackupType.OPEN_PGP)), null);
|
||||
if (settings.isBackupLocationSet()) {
|
||||
DocumentFile backupLocation = DocumentFile.fromTreeUri(this, settings.getBackupLocation());
|
||||
|
||||
if (backupLocation != null) {
|
||||
if (intentId == Constants.INTENT_BACKUP_SAVE_DOCUMENT_PLAIN) {
|
||||
DocumentFile plainBackupFile = backupLocation.createFile(Constants.BACKUP_MIMETYPE_PLAIN, BackupHelper.backupFilename(this, Constants.BackupType.PLAIN_TEXT));
|
||||
|
||||
if (plainBackupFile != null) {
|
||||
doBackupPlain(plainBackupFile.getUri());
|
||||
} else {
|
||||
Toast.makeText(this, R.string.backup_toast_file_creation_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (intentId == Constants.INTENT_BACKUP_SAVE_DOCUMENT_CRYPT) {
|
||||
DocumentFile cryptBackupFile = backupLocation.createFile(Constants.BACKUP_MIMETYPE_CRYPT, BackupHelper.backupFilename(this, Constants.BackupType.ENCRYPTED));
|
||||
|
||||
if (cryptBackupFile != null) {
|
||||
doBackupCrypt(cryptBackupFile.getUri());
|
||||
} else {
|
||||
Toast.makeText(this, R.string.backup_toast_file_creation_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (intentId == Constants.INTENT_BACKUP_SAVE_DOCUMENT_PGP) {
|
||||
DocumentFile pgpBackupFile = backupLocation.createFile(Constants.BACKUP_MIMETYPE_PGP, BackupHelper.backupFilename(this, Constants.BackupType.OPEN_PGP));
|
||||
|
||||
if (pgpBackupFile != null) {
|
||||
backupEncryptedWithPGP(pgpBackupFile.getUri(), null);
|
||||
} else {
|
||||
Toast.makeText(this, R.string.backup_toast_file_creation_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, R.string.backup_toast_location_access_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, R.string.backup_toast_mkdir_failed, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, R.string.backup_toast_no_location, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@
|
|||
automatic backup was successful</string>
|
||||
|
||||
<!-- Toast messages -->
|
||||
<string name="backup_toast_no_location">Please set a default backup location in the settings!</string>
|
||||
<string name="backup_toast_location_access_failed">Failed to access backup location!</string>
|
||||
<string name="backup_toast_file_creation_failed">Failed to create backup file!</string>
|
||||
|
||||
<string name="backup_toast_mkdir_failed">Failed to create backup directory</string>
|
||||
<string name="backup_toast_export_success">Export to external storage successful</string>
|
||||
<string name="backup_toast_export_failed">Export to external storage failed</string>%
|
||||
|
|
Loading…
Reference in a new issue