Skip to content

Commit 8243eb1

Browse files
committed
Don't ask android where to save
1 parent c803519 commit 8243eb1

File tree

7 files changed

+301
-227
lines changed

7 files changed

+301
-227
lines changed

lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,17 @@ class _DebugViewState extends ConsumerState<DebugView> {
303303
Logging.instance
304304
.log("$e\n$s", level: LogLevel.Error);
305305
}
306-
307-
final String? path =
308-
await FilePicker.platform.getDirectoryPath(
309-
dialogTitle: "Choose Backup location",
310-
initialDirectory: dir.path,
311-
lockParentWindow: true,
312-
);
306+
String? path;
307+
if (Platform.isAndroid) {
308+
path = dir.path;
309+
} else {
310+
path = await FilePicker.platform
311+
.getDirectoryPath(
312+
dialogTitle: "Choose Backup location",
313+
initialDirectory: dir.path,
314+
lockParentWindow: true,
315+
);
316+
}
313317

314318
if (path != null) {
315319
final eventBus = EventBus();
@@ -328,18 +332,34 @@ class _DebugViewState extends ConsumerState<DebugView> {
328332
),
329333
));
330334

331-
await ref
335+
final filename = await ref
332336
.read(debugServiceProvider)
333337
.exportToFile(path, eventBus);
334338

335339
shouldPop = true;
336340

337341
if (mounted) {
338342
Navigator.pop(context);
339-
unawaited(showFloatingFlushBar(
340-
type: FlushBarType.info,
341-
context: context,
342-
message: 'Logs file saved'));
343+
344+
if (Platform.isAndroid) {
345+
unawaited(
346+
showDialog(
347+
context: context,
348+
builder: (context) => StackOkDialog(
349+
title: "Logs saved to",
350+
message: "${path!}/$filename",
351+
),
352+
),
353+
);
354+
} else {
355+
unawaited(
356+
showFloatingFlushBar(
357+
type: FlushBarType.info,
358+
context: context,
359+
message: 'Logs file saved',
360+
),
361+
);
362+
}
343363
}
344364
}
345365
},

lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart

Lines changed: 78 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
8282
passwordFocusNode = FocusNode();
8383
passwordRepeatFocusNode = FocusNode();
8484

85+
if (Platform.isAndroid) {
86+
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
87+
final dir = await stackFileSystem.prepareStorage();
88+
if (mounted) {
89+
setState(() {
90+
fileLocationController.text = dir.path;
91+
});
92+
}
93+
});
94+
}
95+
8596
super.initState();
8697
}
8798

@@ -133,64 +144,70 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
133144
const SizedBox(
134145
height: 10,
135146
),
136-
TextField(
137-
onTap: () async {
138-
try {
139-
await stackFileSystem.prepareStorage();
147+
if (!Platform.isAndroid)
148+
TextField(
149+
onTap: Platform.isAndroid
150+
? null
151+
: () async {
152+
try {
153+
await stackFileSystem.prepareStorage();
140154

141-
if (mounted) {
142-
await stackFileSystem.pickDir(context);
143-
}
155+
if (mounted) {
156+
await stackFileSystem.pickDir(context);
157+
}
144158

145-
if (mounted) {
146-
setState(() {
147-
fileLocationController.text =
148-
stackFileSystem.dirPath ?? "";
149-
});
150-
}
151-
} catch (e, s) {
152-
Logging.instance.log("$e\n$s", level: LogLevel.Error);
153-
}
154-
},
155-
controller: fileLocationController,
156-
style: STextStyles.field(context),
157-
decoration: InputDecoration(
158-
hintText: "Save to...",
159-
suffixIcon: UnconstrainedBox(
160-
child: Row(
161-
children: [
162-
const SizedBox(
163-
width: 16,
164-
),
165-
SvgPicture.asset(
166-
Assets.svg.folder,
167-
color: Theme.of(context)
168-
.extension<StackColors>()!
169-
.textDark3,
170-
width: 16,
171-
height: 16,
172-
),
173-
const SizedBox(
174-
width: 12,
175-
),
176-
],
159+
if (mounted) {
160+
setState(() {
161+
fileLocationController.text =
162+
stackFileSystem.dirPath ?? "";
163+
});
164+
}
165+
} catch (e, s) {
166+
Logging.instance
167+
.log("$e\n$s", level: LogLevel.Error);
168+
}
169+
},
170+
controller: fileLocationController,
171+
style: STextStyles.field(context),
172+
decoration: InputDecoration(
173+
hintText: "Save to...",
174+
hintStyle: STextStyles.fieldLabel(context),
175+
suffixIcon: UnconstrainedBox(
176+
child: Row(
177+
children: [
178+
const SizedBox(
179+
width: 16,
180+
),
181+
SvgPicture.asset(
182+
Assets.svg.folder,
183+
color: Theme.of(context)
184+
.extension<StackColors>()!
185+
.textDark3,
186+
width: 16,
187+
height: 16,
188+
),
189+
const SizedBox(
190+
width: 12,
191+
),
192+
],
193+
),
177194
),
178195
),
196+
key: const Key(
197+
"createBackupSaveToFileLocationTextFieldKey"),
198+
readOnly: true,
199+
toolbarOptions: const ToolbarOptions(
200+
copy: true,
201+
cut: false,
202+
paste: false,
203+
selectAll: false,
204+
),
205+
onChanged: (newValue) {},
179206
),
180-
key: const Key(
181-
"createBackupSaveToFileLocationTextFieldKey"),
182-
readOnly: true,
183-
toolbarOptions: const ToolbarOptions(
184-
copy: true,
185-
cut: false,
186-
paste: false,
187-
selectAll: false,
207+
if (!Platform.isAndroid)
208+
const SizedBox(
209+
height: 10,
188210
),
189-
onChanged: (newValue) {},
190-
),
191-
const SizedBox(
192-
height: 10,
193-
),
194211
ClipRRect(
195212
borderRadius: BorderRadius.circular(
196213
Constants.size.circularBorderRadius,
@@ -593,8 +610,15 @@ class _EnableAutoBackupViewState extends ConsumerState<CreateAutoBackupView> {
593610
await showDialog<dynamic>(
594611
context: context,
595612
barrierDismissible: false,
596-
builder: (_) => const StackOkDialog(
597-
title: "Stack Auto Backup enabled!"),
613+
builder: (_) => Platform.isAndroid
614+
? StackOkDialog(
615+
title:
616+
"Stack Auto Backup enabled and saved to:",
617+
message: fileToSave,
618+
)
619+
: const StackOkDialog(
620+
title:
621+
"Stack Auto Backup enabled!"),
598622
);
599623
if (mounted) {
600624
passwordController.text = "";

0 commit comments

Comments
 (0)