An open-source cross-platform alternative to AirDrop
feat: add apk installation permission to manifest
Tien Do Nam134494267cf2
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xmlindex f71b8903..e3094f26 100644--- a/android/app/src/main/AndroidManifest.xml+++ b/android/app/src/main/AndroidManifest.xml@@ -12,6 +12,7 @@<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /><uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />+ <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /><!-- Android TV --><uses-feature android:name="android.software.leanback" android:required="false" />diff --git a/assets/CHANGELOG.md b/assets/CHANGELOG.mdindex 503a6f54..4a06fec2 100644--- a/assets/CHANGELOG.md+++ b/assets/CHANGELOG.md@@ -2,7 +2,7 @@- feat: add troubleshoot page- feat: cleanup scan UI by hiding multiple network interfaces inside the scan button-- feat(android): share apk+- feat(android): share apk and install apk- feat(android): Android TV support- feat(windows): left click on tray icon opens app- feat(linux): add Control+Q shortcut to exit appdiff --git a/lib/pages/progress_page.dart b/lib/pages/progress_page.dartindex f6ce3b52..25c99351 100644--- a/lib/pages/progress_page.dart+++ b/lib/pages/progress_page.dart@@ -11,12 +11,12 @@ import 'package:localsend_app/provider/progress_provider.dart';import 'package:localsend_app/theme.dart';import 'package:localsend_app/util/file_size_helper.dart';import 'package:localsend_app/util/file_speed_helper.dart';+import 'package:localsend_app/util/native/open_file.dart';import 'package:localsend_app/util/platform_check.dart';import 'package:localsend_app/widget/custom_progress_bar.dart';import 'package:localsend_app/widget/dialogs/cancel_session_dialog.dart';import 'package:localsend_app/widget/dialogs/error_dialog.dart';import 'package:localsend_app/widget/file_thumbnail.dart';-import 'package:open_filex/open_filex.dart';import 'package:routerino/routerino.dart';import 'package:wakelock/wakelock.dart';@@ -184,7 +184,7 @@ class _ProgressPageState extends ConsumerState<ProgressPage> {splashFactory: NoSplash.splashFactory,highlightColor: Colors.transparent,hoverColor: Colors.transparent,- onTap: filePath != null && receiveSession != null ? () => OpenFilex.open(filePath) : null,+ onTap: filePath != null && receiveSession != null ? () => openFile(context, file.fileType, filePath!) : null,child: Row(crossAxisAlignment: CrossAxisAlignment.center,children: [diff --git a/lib/pages/receive_history_page.dart b/lib/pages/receive_history_page.dartindex a6ee0183..f299a8c5 100644--- a/lib/pages/receive_history_page.dart+++ b/lib/pages/receive_history_page.dart@@ -4,11 +4,10 @@ import 'package:localsend_app/gen/strings.g.dart';import 'package:localsend_app/model/receive_history_entry.dart';import 'package:localsend_app/provider/receive_history_provider.dart';import 'package:localsend_app/util/file_size_helper.dart';-import 'package:localsend_app/widget/dialogs/cannot_open_file_dialog.dart';+import 'package:localsend_app/util/native/open_file.dart';import 'package:localsend_app/widget/dialogs/file_info_dialog.dart';import 'package:localsend_app/widget/file_thumbnail.dart';import 'package:localsend_app/widget/responsive_list_view.dart';-import 'package:open_filex/open_filex.dart';enum _EntryOption {open,@@ -34,11 +33,8 @@ class ReceiveHistoryPage extends ConsumerWidget {const ReceiveHistoryPage({Key? key}) : super(key: key);Future<void> _openFile(BuildContext context, ReceiveHistoryEntry entry) async {- final result = await OpenFilex.open(entry.path);- if (result.type != ResultType.done) {- // TODO: use context.mounted when migrated to Flutter 3.7- // ignore: use_build_context_synchronously- CannotOpenFileDialog.open(context, entry.path!);+ if (entry.path != null) {+ openFile(context, entry.fileType, entry.path!);}}diff --git a/lib/pages/selected_files_page.dart b/lib/pages/selected_files_page.dartindex e7a9a2f5..e8cd1bed 100644--- a/lib/pages/selected_files_page.dart+++ b/lib/pages/selected_files_page.dart@@ -8,9 +8,9 @@ import 'package:localsend_app/model/file_type.dart';import 'package:localsend_app/provider/selection/selected_sending_files_provider.dart';import 'package:localsend_app/util/cache_helper.dart';import 'package:localsend_app/util/file_size_helper.dart';+import 'package:localsend_app/util/native/open_file.dart';import 'package:localsend_app/widget/file_thumbnail.dart';import 'package:localsend_app/widget/responsive_list_view.dart';-import 'package:open_filex/open_filex.dart';import 'package:routerino/routerino.dart';class SelectedFilesPage extends ConsumerWidget {@@ -59,7 +59,7 @@ class SelectedFilesPage extends ConsumerWidget {splashFactory: NoSplash.splashFactory,highlightColor: Colors.transparent,hoverColor: Colors.transparent,- onTap: file.path != null ? () => OpenFilex.open(file.path) : null,+ onTap: file.path != null ? () => openFile(context, file.fileType, file.path!) : null,child: Card(child: Padding(padding: const EdgeInsets.all(10),diff --git a/lib/util/native/open_file.dart b/lib/util/native/open_file.dartnew file mode 100644index 00000000..135c9e79--- /dev/null+++ b/lib/util/native/open_file.dart@@ -0,0 +1,17 @@+import 'package:flutter/material.dart';+import 'package:localsend_app/model/file_type.dart';+import 'package:localsend_app/util/platform_check.dart';+import 'package:localsend_app/widget/dialogs/cannot_open_file_dialog.dart';+import 'package:open_filex/open_filex.dart';+import 'package:permission_handler/permission_handler.dart';++/// Opens the selected file which is stored on the device.+Future<void> openFile(BuildContext context, FileType fileType, String filePath) async {+ if ((fileType == FileType.apk || filePath.toLowerCase().endsWith('.apk')) && checkPlatform([TargetPlatform.android])) {+ await Permission.requestInstallPackages.request();+ }+ final fileOpenResult = await OpenFilex.open(filePath);+ if (fileOpenResult.type != ResultType.done && context.mounted) {+ CannotOpenFileDialog.open(context, filePath);+ }+}\ No newline at end of file