Skip to content

Commit

Permalink
fix: default download path on mobile (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie authored Jan 19, 2024
1 parent 74beea6 commit c26eb26
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
14 changes: 8 additions & 6 deletions ui/flutter/lib/app/modules/app/controllers/app_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:app_links/app_links.dart';
import 'package:flutter/material.dart';
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:get/get.dart';
import 'package:lecle_downloads_path_provider/lecle_downloads_path_provider.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tray_manager/tray_manager.dart';
Expand Down Expand Up @@ -416,12 +417,13 @@ class AppController extends GetxController with WindowListener, TrayListener {
if (config.downloadDir.isEmpty) {
if (Util.isDesktop()) {
config.downloadDir = (await getDownloadsDirectory())?.path ?? "./";
} else if (Util.isAndroid()) {
config.downloadDir = (await getExternalStorageDirectory())?.path ??
(await getApplicationDocumentsDirectory()).path;
return;
} else if (Util.isIOS()) {
config.downloadDir = (await getApplicationDocumentsDirectory()).path;
} else if (Util.isMobile()) {
final downloadDir = (await DownloadsPath.downloadsDirectory())?.path;
if (downloadDir != null) {
config.downloadDir = '$downloadDir/Gopeed';
} else {
config.downloadDir = (await getApplicationDocumentsDirectory()).path;
}
} else {
config.downloadDir = './';
}
Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/lib/app/views/directory_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _DirectorySelectorState extends State<DirectorySelector> {
return v!.trim().isNotEmpty ? null : 'downloadDirValid'.tr;
},
)),
!Util.isWeb() && !Util.isIOS()
!Util.isWeb() && !Util.isAndroid() && !Util.isIOS()
? IconButton(
icon: const Icon(Icons.folder_open),
onPressed: () async {
Expand Down
8 changes: 8 additions & 0 deletions ui/flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.7.1"
lecle_downloads_path_provider:
dependency: "direct main"
description:
name: lecle_downloads_path_provider
sha256: "111f6d6d21e18acddda515eba8fd445658aa14defcbd59513d6d1b02b9ed47a0"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.2+8"
lint:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions ui/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dependencies:
flutter_foreground_task: ^6.1.2
open_filex: ^4.3.4
tray_manager: ^0.2.1
lecle_downloads_path_provider: ^0.0.2+8
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit c26eb26

Please sign in to comment.