diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index dc3c149..9a98d29 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,51 +1,62 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart
index cf3e8c6..2232e90 100644
--- a/lib/pages/home_page.dart
+++ b/lib/pages/home_page.dart
@@ -15,6 +15,7 @@ import 'package:odin/services/locator.dart';
import 'package:odin/services/preferences_service.dart';
import 'package:odin/services/toast_service.dart';
import 'package:odin/widgets/window_top_bar.dart';
+import 'package:open_file/open_file.dart';
import 'package:provider/provider.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -474,8 +475,10 @@ class _HomePageState extends State
margin:
const EdgeInsets.fromLTRB(16, 16, 8, 16),
child: SizedBox(
- width:
- MediaQuery.of(context).size.width * 0.2,
+ width: (Platform.isWindows ||
+ Platform.isMacOS)
+ ? MediaQuery.of(context).size.width * 0.2
+ : MediaQuery.of(context).size.width * 0.4,
height: 44,
child: TextField(
controller: _tokenController,
@@ -504,9 +507,14 @@ class _HomePageState extends State
? () async {
final _filePath = await _fileNotifier
.getFileFromToken(
- _tokenController.text);
+ _tokenController.text.trim());
_tokenController.clear();
- launch(_filePath);
+ if (Platform.isWindows ||
+ Platform.isMacOS) {
+ launch(_filePath);
+ } else {
+ await OpenFile.open(_filePath);
+ }
}
: null,
child: Container(
diff --git a/lib/services/download_service.dart b/lib/services/download_service.dart
index 15ed45a..67d2dae 100644
--- a/lib/services/download_service.dart
+++ b/lib/services/download_service.dart
@@ -1,11 +1,13 @@
import 'dart:io';
+import 'package:android_path_provider/android_path_provider.dart';
import 'package:dio/dio.dart';
import 'package:odin/services/locator.dart';
import 'package:odin/services/logger.dart';
import 'package:odin/services/random_service.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
+import 'package:permission_handler/permission_handler.dart';
class DownloadService {
final RandomService _randomService = locator();
@@ -17,7 +19,11 @@ class DownloadService {
final fileName = _randomService.getRandomString(10);
Directory? dir;
if (Platform.isAndroid) {
- dir = await getExternalStorageDirectory();
+ var status = await Permission.storage.status;
+ if (!status.isGranted) {
+ await Permission.storage.request();
+ }
+ dir = Directory(await AndroidPathProvider.downloadsPath);
} else if (Platform.isIOS) {
dir = await getTemporaryDirectory();
} else {
diff --git a/pubspec.lock b/pubspec.lock
index 3fb17e2..a4d3da4 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -22,6 +22,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.7.0"
+ android_path_provider:
+ dependency: "direct main"
+ description:
+ name: android_path_provider
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.3.0"
archive:
dependency: "direct main"
description:
@@ -506,6 +513,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
+ open_file:
+ dependency: "direct main"
+ description:
+ name: open_file
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.2.1"
package_config:
dependency: transitive
description:
@@ -569,6 +583,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
+ permission_handler:
+ dependency: "direct main"
+ description:
+ name: permission_handler
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "8.3.0"
+ permission_handler_platform_interface:
+ dependency: transitive
+ description:
+ name: permission_handler_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.7.0"
petitparser:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 2a64630..9a2ddb3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -28,6 +28,7 @@ environment:
# versions available, run `flutter pub outdated`.
dependencies:
aes_crypt_null_safe: ^2.0.1
+ android_path_provider: ^0.3.0
archive: ^3.1.6
bitsdojo_window: ^0.1.1+1
clipboard: ^0.1.3
@@ -46,8 +47,10 @@ dependencies:
intl: ^0.17.0
json_annotation: ^4.3.0
logger: ^1.1.0
+ open_file: ^3.2.1
path: ^1.8.0
path_provider: ^2.0.6
+ permission_handler: ^8.3.0
provider: ^6.0.1
qr_flutter: ^4.0.0
shared_preferences: ^2.0.8