An open-source cross-platform alternative to AirDrop
Linux: Use tray_manager instead of system_tray; remove system_tray (#1255)
ix5f45c5c9598f1
diff --git a/app/lib/util/native/tray_helper.dart b/app/lib/util/native/tray_helper.dartindex 52c468dd..269c6d5a 100644--- a/app/lib/util/native/tray_helper.dart+++ b/app/lib/util/native/tray_helper.dart@@ -1,4 +1,3 @@-import 'dart:io';import 'package:flutter/foundation.dart';import 'package:localsend_app/gen/assets.gen.dart';import 'package:localsend_app/gen/strings.g.dart';@@ -6,7 +5,6 @@ import 'package:localsend_app/provider/animation_provider.dart';import 'package:localsend_app/util/native/platform_check.dart';import 'package:logging/logging.dart';import 'package:refena_flutter/refena_flutter.dart';-import 'package:system_tray/system_tray.dart';import 'package:tray_manager/tray_manager.dart' as tm;import 'package:window_manager/window_manager.dart';@@ -21,63 +19,35 @@ Future<void> initTray() async {if (!checkPlatformHasTray()) {return;}- if (!checkPlatform([TargetPlatform.linux])) {- try {- if (checkPlatform([TargetPlatform.windows])) {- await tm.trayManager.setIcon(- Assets.img.logo,- );- } else if (checkPlatform([TargetPlatform.macOS])) {- await tm.trayManager.setIcon(Assets.img.logo32Black.path, isTemplate: true);- } else {- await tm.trayManager.setIcon(Assets.img.logo32.path);- }-- final items = [- tm.MenuItem(- key: TrayEntry.open.name,- label: t.tray.open,- ),- tm.MenuItem(- key: TrayEntry.close.name,- label: t.tray.close,- ),- ];- await tm.trayManager.setContextMenu(tm.Menu(items: items));- await tm.trayManager.setToolTip(t.appName);- } catch (e) {- _logger.warning('Failed to init tray', e);+ try {+ if (checkPlatform([TargetPlatform.windows])) {+ await tm.trayManager.setIcon(Assets.img.logo);+ } else if (checkPlatform([TargetPlatform.macOS])) {+ await tm.trayManager.setIcon(Assets.img.logo32Black.path, isTemplate: true);+ } else if (checkPlatform([TargetPlatform.linux])) {+ await tm.trayManager.setIcon(Assets.img.logo32White.path);+ } else {+ await tm.trayManager.setIcon(Assets.img.logo32.path);}- } else {- // The Linux tray display is handled by systemTray instead- final SystemTray systemTray = SystemTray();- await systemTray.initSystemTray(- title: t.appName,- iconPath: Assets.img.logo32White.path,- );-- final Menu menu = Menu();- await menu.buildFrom([- MenuItemLabel(+ final items = [+ tm.MenuItem(+ key: TrayEntry.open.name,label: t.tray.open,- onClicked: (menuItem) async {- await windowManager.show();- await windowManager.focus();- },),- MenuItemLabel(label: t.tray.close, onClicked: (menuItem) => exit(0)),- ]);-- await systemTray.setContextMenu(menu);-- systemTray.registerSystemTrayEventHandler((eventName) {- if (eventName == kSystemTrayEventClick) {- systemTray.popUpContextMenu();- } else if (eventName == kSystemTrayEventRightClick) {- WindowManager.instance.show();- }- });+ tm.MenuItem(+ key: TrayEntry.close.name,+ label: t.tray.close,+ ),+ ];+ await tm.trayManager.setContextMenu(tm.Menu(items: items));+ // No Linux implementation for setToolTip available as of tray_manager 0.2.2+ // https://pub.dev/packages/tray_manager#api+ if (!checkPlatform([TargetPlatform.linux])) {+ await tm.trayManager.setToolTip(t.appName);+ }+ } catch (e) {+ _logger.warning('Failed to init tray', e);}}diff --git a/app/linux/flutter/generated_plugin_registrant.cc b/app/linux/flutter/generated_plugin_registrant.ccindex 999deafd..a3c82ca8 100644--- a/app/linux/flutter/generated_plugin_registrant.cc+++ b/app/linux/flutter/generated_plugin_registrant.cc@@ -12,7 +12,7 @@#include <gtk/gtk_plugin.h>#include <pasteboard/pasteboard_plugin.h>#include <screen_retriever/screen_retriever_plugin.h>-#include <system_tray/system_tray_plugin.h>+#include <tray_manager/tray_manager_plugin.h>#include <url_launcher_linux/url_launcher_plugin.h>#include <window_manager/window_manager_plugin.h>@@ -35,9 +35,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {g_autoptr(FlPluginRegistrar) screen_retriever_registrar =fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);- g_autoptr(FlPluginRegistrar) system_tray_registrar =- fl_plugin_registry_get_registrar_for_plugin(registry, "SystemTrayPlugin");- system_tray_plugin_register_with_registrar(system_tray_registrar);+ g_autoptr(FlPluginRegistrar) tray_manager_registrar =+ fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");+ tray_manager_plugin_register_with_registrar(tray_manager_registrar);g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);diff --git a/app/linux/flutter/generated_plugins.cmake b/app/linux/flutter/generated_plugins.cmakeindex bf78cd7d..40adb2d3 100644--- a/app/linux/flutter/generated_plugins.cmake+++ b/app/linux/flutter/generated_plugins.cmake@@ -9,7 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LISTgtkpasteboardscreen_retriever- system_tray+ tray_managerurl_launcher_linuxwindow_manager)diff --git a/app/macos/Flutter/GeneratedPluginRegistrant.swift b/app/macos/Flutter/GeneratedPluginRegistrant.swiftindex 793aa288..0d3bb344 100644--- a/app/macos/Flutter/GeneratedPluginRegistrant.swift+++ b/app/macos/Flutter/GeneratedPluginRegistrant.swift@@ -12,6 +12,7 @@ import dynamic_colorimport file_selector_macosimport galimport in_app_purchase_storekit+import macos_dock_progressimport network_info_plusimport package_info_plusimport pasteboard@@ -19,7 +20,6 @@ import path_provider_foundationimport photo_managerimport screen_retrieverimport shared_preferences_foundation-import system_trayimport tray_managerimport url_launcher_macosimport video_player_avfoundation@@ -34,6 +34,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))GalPlugin.register(with: registry.registrar(forPlugin: "GalPlugin"))InAppPurchasePlugin.register(with: registry.registrar(forPlugin: "InAppPurchasePlugin"))+ MacosDockProgressPlugin.register(with: registry.registrar(forPlugin: "MacosDockProgressPlugin"))NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin"))FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))@@ -41,7 +42,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "PhotoManagerPlugin"))ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))- SystemTrayPlugin.register(with: registry.registrar(forPlugin: "SystemTrayPlugin"))TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))diff --git a/app/pubspec.lock b/app/pubspec.lockindex 83f8a733..636ddbe6 100644--- a/app/pubspec.lock+++ b/app/pubspec.lock@@ -812,6 +812,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.2.0"+ macos_dock_progress:+ dependency: "direct main"+ description:+ name: macos_dock_progress+ sha256: "4dfd32c3117903944d9069ec2b22054e5226180cea57ad94b5908436609eb884"+ url: "https://pub.dev"+ source: hosted+ version: "1.0.0"markdown:dependency: transitivedescription:@@ -1450,14 +1458,6 @@ packages:url: "https://pub.dev"source: hostedversion: "2.1.0"- system_tray:- dependency: "direct main"- description:- name: system_tray- sha256: "40444e5de8ed907822a98694fd031b8accc3cb3c0baa547634ce76189cf3d9cf"- url: "https://pub.dev"- source: hosted- version: "2.0.3"term_glyph:dependency: transitivedescription:@@ -1509,12 +1509,11 @@ packages:tray_manager:dependency: "direct main"description:- path: "."- ref: b37f5e088e0f02c45a684ae41e9d2da2d5c596db- resolved-ref: b37f5e088e0f02c45a684ae41e9d2da2d5c596db- url: "https://github.com/Tienisto/tray_manager.git"- source: git- version: "0.2.0"+ name: tray_manager+ sha256: e0ac9a88b2700f366b8629b97e8663b6ef450a2f169560a685dc167bfe9c9c29+ url: "https://pub.dev"+ source: hosted+ version: "0.2.2"type_plus:dependency: transitivedescription:@@ -1739,6 +1738,14 @@ packages:url: "https://pub.dev"source: hostedversion: "0.3.8"+ windows_taskbar:+ dependency: "direct main"+ description:+ name: windows_taskbar+ sha256: "204edfdb280a7053febdf50fc9b49b3c007255bd8a83c082d10c174ec6548f33"+ url: "https://pub.dev"+ source: hosted+ version: "1.1.2"xdg_directories:dependency: transitivedescription:diff --git a/app/pubspec.yaml b/app/pubspec.yamlindex 76df2999..10f12430 100644--- a/app/pubspec.yaml+++ b/app/pubspec.yaml@@ -61,13 +61,7 @@ dependencies:slang: 3.29.0slang_flutter: 3.29.0system_settings: 2.1.0- system_tray: 2.0.3- tray_manager:- # https://github.com/leanflutter/tray_manager/issues/30- # The Linux tray manager is disabled for now- git:- url: https://github.com/Tienisto/tray_manager.git- ref: b37f5e088e0f02c45a684ae41e9d2da2d5c596db+ tray_manager: 0.2.2url_launcher: 6.2.4uuid: 3.0.7wakelock_plus: 1.1.4diff --git a/app/windows/flutter/generated_plugin_registrant.cc b/app/windows/flutter/generated_plugin_registrant.ccindex b67ff36e..d9e22e49 100644--- a/app/windows/flutter/generated_plugin_registrant.cc+++ b/app/windows/flutter/generated_plugin_registrant.cc@@ -14,10 +14,10 @@#include <pasteboard/pasteboard_plugin.h>#include <permission_handler_windows/permission_handler_windows_plugin.h>#include <screen_retriever/screen_retriever_plugin.h>-#include <system_tray/system_tray_plugin.h>#include <tray_manager/tray_manager_plugin.h>#include <url_launcher_windows/url_launcher_windows.h>#include <window_manager/window_manager_plugin.h>+#include <windows_taskbar/windows_taskbar_plugin.h>void RegisterPlugins(flutter::PluginRegistry* registry) {ConnectivityPlusWindowsPluginRegisterWithRegistrar(@@ -36,12 +36,12 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));ScreenRetrieverPluginRegisterWithRegistrar(registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));- SystemTrayPluginRegisterWithRegistrar(- registry->GetRegistrarForPlugin("SystemTrayPlugin"));TrayManagerPluginRegisterWithRegistrar(registry->GetRegistrarForPlugin("TrayManagerPlugin"));UrlLauncherWindowsRegisterWithRegistrar(registry->GetRegistrarForPlugin("UrlLauncherWindows"));WindowManagerPluginRegisterWithRegistrar(registry->GetRegistrarForPlugin("WindowManagerPlugin"));+ WindowsTaskbarPluginRegisterWithRegistrar(+ registry->GetRegistrarForPlugin("WindowsTaskbarPlugin"));}diff --git a/app/windows/flutter/generated_plugins.cmake b/app/windows/flutter/generated_plugins.cmakeindex 170f9874..6b46f5ce 100644--- a/app/windows/flutter/generated_plugins.cmake+++ b/app/windows/flutter/generated_plugins.cmake@@ -11,10 +11,10 @@ list(APPEND FLUTTER_PLUGIN_LISTpasteboardpermission_handler_windowsscreen_retriever- system_traytray_managerurl_launcher_windowswindow_manager+ windows_taskbar)list(APPEND FLUTTER_FFI_PLUGIN_LIST