From 8ae0016e253d38f10150ca091061be71db44952d Mon Sep 17 00:00:00 2001 From: Alex Gorichev Date: Mon, 22 May 2023 16:37:44 +0100 Subject: [PATCH] Improve save location setting --- lib/path.dart | 9 ++++++++- lib/screens/settings.dart | 10 ++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/path.dart b/lib/path.dart index 14b89ad..fa040ef 100644 --- a/lib/path.dart +++ b/lib/path.dart @@ -17,7 +17,14 @@ class SavePath { bool get isScopedStorage => path == null; - String get string => isScopedStorage ? uri!.toString() : path!; + String get string { + if (isScopedStorage) { + String fullString = Uri.decodeFull(uri!.path); + return fullString.split(':').last; + } else { + return path!.replaceFirst('/storage/emulated/0/', ''); + } + } Future getScopedFile(String filename) async { final file = await getChildFile(filename); diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 0133425..29b41f0 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -409,12 +409,10 @@ class _SavePathSettingState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Visibility( - visible: Platform.isAndroid, - child: Text( - 'Changing this setting will only work properly if the device is rooted:', - style: TextStyle(color: Theme.of(context).colorScheme.primary), - )), + Text( + 'Save Location:', + style: Theme.of(context).textTheme.titleMedium, + ), ConstrainedBox( constraints: const BoxConstraints(maxWidth: 400), child: TextField(