diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 4513c32f..43772989 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -3,7 +3,8 @@
-
+
+
-
-
-
-
-
Navigator.of(dialogContext).pop());
+ alertTitle: S.of(context).export_backup,
+ alertContent: S.of(context).save_backup_password,
+ rightButtonText: S.of(context).seed_alert_yes,
+ leftButtonText: S.of(context).seed_alert_back,
+ actionRightButton: () async {
+ Navigator.of(dialogContext).pop();
+ final backup = await backupViewModelBase.exportBackup();
+ await backupViewModelBase.saveToDownload(
+ backup.name, backup.content);
+
+ if (Platform.isAndroid) {
+ onExportAndroid(context, backup);
+ } else {
+ await Share.file(S.of(context).backup_file, backup.name,
+ backup.content, 'application/*');
+ }
+ },
+ actionLeftButton: () => Navigator.of(dialogContext).pop());
+ });
+ }
+
+ void onExportAndroid(BuildContext context, BackupExportFile backup) {
+ showPopUp(
+ context: context,
+ builder: (dialogContext) {
+ return AlertWithTwoActions(
+ alertTitle: S.of(context).export_backup,
+ alertContent: 'Please select destination for the backup file.',
+ rightButtonText: 'Save to Downloads',
+ leftButtonText: 'Share',
+ actionRightButton: () async {
+ Navigator.of(dialogContext).pop();
+ await backupViewModelBase.saveToDownload(
+ backup.name, backup.content);
+ },
+ actionLeftButton: () {
+ Navigator.of(dialogContext).pop();
+ Share.file(S.of(context).backup_file, backup.name,
+ backup.content, 'application/*');
+ });
});
}
}
diff --git a/lib/view_model/backup_view_model.dart b/lib/view_model/backup_view_model.dart
index b76c1916..660c576c 100644
--- a/lib/view_model/backup_view_model.dart
+++ b/lib/view_model/backup_view_model.dart
@@ -1,3 +1,5 @@
+import 'dart:io';
+
import 'package:cake_wallet/core/backup_service.dart';
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
@@ -66,4 +68,12 @@ abstract class BackupViewModelBase with Store {
@action
void showMasterPassword() => isBackupPasswordVisible = true;
+
+ @action
+ Future saveToDownload(String name, List content) async {
+ const downloadDirPath = '/storage/emulated/0/Download'; // For Android
+ final filePath = '$downloadDirPath/${name}';
+ final file = File(filePath);
+ await file.writeAsBytes(content);
+ }
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 32ab9962..e70c37c6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -11,7 +11,7 @@ description: Cake Wallet.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 4.1.0+34
+version: 4.1.0+37
environment:
sdk: ">=2.7.0 <3.0.0"