Skip to content

Commit

Permalink
Improve save location setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Voklen committed May 22, 2023
1 parent c963037 commit 8ae0016
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 8 additions & 1 deletion lib/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getScopedFile(String filename) async {
final file = await getChildFile(filename);
Expand Down
10 changes: 4 additions & 6 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,10 @@ class _SavePathSettingState extends State<SavePathSetting> {
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(
Expand Down

0 comments on commit 8ae0016

Please sign in to comment.