File tree Expand file tree Collapse file tree 6 files changed +30
-17
lines changed
pages_desktop_specific/settings/settings_menu/backup_and_restore
pages/settings_views/global_settings_view/stack_backup_views Expand file tree Collapse file tree 6 files changed +30
-17
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,9 @@ class _AutoBackupViewState extends ConsumerState<AutoBackupView> {
101101 child: Text (
102102 "Back" ,
103103 style: STextStyles .button (context).copyWith (
104- color:
105- Theme .of (context).extension < StackColors > ()! .accentColorDark,
104+ color: Theme .of (
105+ context,
106+ ).extension < StackColors > ()! .accentColorDark,
106107 ),
107108 ),
108109 onPressed: () {
@@ -155,8 +156,9 @@ class _AutoBackupViewState extends ConsumerState<AutoBackupView> {
155156 child: Text (
156157 "Back" ,
157158 style: STextStyles .button (context).copyWith (
158- color:
159- Theme .of (context).extension < StackColors > ()! .accentColorDark,
159+ color: Theme .of (
160+ context,
161+ ).extension < StackColors > ()! .accentColorDark,
160162 ),
161163 ),
162164 onPressed: () {
@@ -313,14 +315,13 @@ class _AutoBackupViewState extends ConsumerState<AutoBackupView> {
313315 TextSpan (
314316 text: "stackwallet.com." ,
315317 style: STextStyles .richLink (context),
316- recognizer:
317- TapGestureRecognizer ()
318- ..onTap = () {
319- launchUrl (
320- Uri .parse ("https://stackwallet.com" ),
321- mode: LaunchMode .externalApplication,
322- );
323- },
318+ recognizer: TapGestureRecognizer ()
319+ ..onTap = () {
320+ launchUrl (
321+ Uri .parse ("https://stackwallet.com" ),
322+ mode: LaunchMode .externalApplication,
323+ );
324+ },
324325 ),
325326 ],
326327 ),
Original file line number Diff line number Diff line change @@ -261,7 +261,7 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
261261 await stackFileSystem.prepareStorage ();
262262 if (mounted) {
263263 final filePath = await stackFileSystem
264- .openFile ();
264+ .pickDir ();
265265
266266 if (mounted) {
267267 setState (() {
Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ class _RestoreFromFileViewState extends ConsumerState<CreateBackupView> {
310310 await stackFileSystem.prepareStorage ();
311311 if (mounted) {
312312 final filePath = await stackFileSystem
313- .openFile ();
313+ .pickDir ();
314314
315315 if (mounted) {
316316 setState (() {
Original file line number Diff line number Diff line change @@ -302,7 +302,7 @@ class _EditAutoBackupViewState extends ConsumerState<EditAutoBackupView> {
302302 try {
303303 await stackFileSystem.prepareStorage ();
304304 if (mounted) {
305- final filePath = await stackFileSystem.openFile ();
305+ final filePath = await stackFileSystem.pickDir ();
306306
307307 if (mounted) {
308308 setState (() {
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ class _CreateAutoBackup extends ConsumerState<CreateAutoBackup> {
321321 await stackFileSystem.prepareStorage ();
322322 if (mounted) {
323323 final filePath = await stackFileSystem
324- .openFile ();
324+ .pickDir ();
325325
326326 if (mounted) {
327327 setState (() {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import 'package:tuple/tuple.dart';
1717
1818import '../pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart' ;
1919import '../utilities/flutter_secure_storage_interface.dart' ;
20+ import '../utilities/fs.dart' ;
2021import '../utilities/logger.dart' ;
2122import '../utilities/prefs.dart' ;
2223
@@ -91,7 +92,11 @@ class AutoSWBService extends ChangeNotifier {
9192 adkVersion,
9293 );
9394
94- await File (fileToSave).writeAsString (content, flush: true );
95+ await FS .writeStringToFile (
96+ content,
97+ autoBackupDirectoryPath,
98+ fileToSave.split ("/" ).last,
99+ );
95100
96101 Prefs .instance.lastAutoBackup = now;
97102
@@ -121,6 +126,13 @@ class AutoSWBService extends ChangeNotifier {
121126
122127 /// Trim the number of auto backup files based on age
123128 void trimBackups (String dirPath, int numberToKeep) {
129+ if (Platform .isAndroid && dirPath.startsWith ("content://" )) {
130+ Logging .instance.w (
131+ "Android SAF lib doesn't provide a deletion API. Cannot trim/rotate out old backups" ,
132+ );
133+ return ;
134+ }
135+
124136 final dir = Directory (dirPath);
125137 final List <Tuple2 <DateTime , FileSystemEntity >> files = [];
126138
You can’t perform that action at this time.
0 commit comments