From 83ca5551adff2f9c4e191079af352e4fbed868b4 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 4 Nov 2025 23:08:09 +0800 Subject: [PATCH] :recycle: Refactored the app protocol --- android/app/src/main/AndroidManifest.xml | 10 + ios/Runner/Info.plist | 213 +++++++++--------- lib/main.dart | 7 + lib/widgets/app_wrapper.dart | 84 +++---- linux/flutter/generated_plugin_registrant.cc | 4 - linux/flutter/generated_plugins.cmake | 1 - macos/Flutter/GeneratedPluginRegistrant.swift | 4 +- macos/Podfile.lock | 12 +- macos/Runner/Info.plist | 93 ++++---- pubspec.lock | 96 ++++---- pubspec.yaml | 4 +- .../flutter/generated_plugin_registrant.cc | 6 +- windows/flutter/generated_plugins.cmake | 2 +- windows/runner/main.cpp | 46 +--- 14 files changed, 299 insertions(+), 283 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 74bc08aa..3a885ba0 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -43,6 +43,16 @@ + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index e032683f..56957541 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -1,108 +1,111 @@ - - AppGroupId - $(CUSTOM_GROUP_ID) - BUNDLE_ID - dev.solsynth.solian - CADisableMinimumFrameDurationOnPhone - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Solian - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - solian - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleURLTypes - - - CFBundleTypeRole - Editor - CFBundleURLSchemes - - ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER) - - - - CFBundleTypeRole - Viewer - CFBundleURLSchemes - - solian - - - - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - CLIENT_ID - 961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com - ITSAppUsesNonExemptEncryption - - LSRequiresIPhoneOS - - NSCalendarsUsageDescription - Grant access to Calander help us to shows Solar Calander with your own events. - NSCameraUsageDescription - Grant access to Camera will allow Solian take photo or video for your post. - NSFaceIDUsageDescription - Allow the Solar Network verify your ownership of the logged in account and continue your action quickly. - NSMicrophoneUsageDescription - Grant access to Microphone will allow Solian record audio for your post. - NSPhotoLibraryAddUsageDescription - Grant access to Photo Library will allow Solian download photo to album for you. - NSPhotoLibraryUsageDescription - Grant access to Photo Library will allow Solian upload photo or video for your post. - NSUserActivityTypes - - INStartCallIntent - INSendMessageIntent - - PLIST_VERSION - 1 - REVERSED_CLIENT_ID - com.googleusercontent.apps.961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig - UIApplicationSupportsIndirectInputEvents - - UIBackgroundModes - - fetch - audio - remote-notification - voip - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIStatusBarHidden - - UISupportedInterfaceOrientations - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortrait - - WKCompanionAppBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - - - + + AppGroupId + $(CUSTOM_GROUP_ID) + BUNDLE_ID + dev.solsynth.solian + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Solian + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + solian + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER) + + + + CFBundleTypeRole + Editor + CFBundleURLName + + CFBundleURLSchemes + + solian + + + + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + CLIENT_ID + 961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig.apps.googleusercontent.com + ITSAppUsesNonExemptEncryption + + LSRequiresIPhoneOS + + NSCalendarsUsageDescription + Grant access to Calander help us to shows Solar Calander with your own events. + NSCameraUsageDescription + Grant access to Camera will allow Solian take photo or video for your post. + NSFaceIDUsageDescription + Allow the Solar Network verify your ownership of the logged in account and continue + your action quickly. + NSMicrophoneUsageDescription + Grant access to Microphone will allow Solian record audio for your post. + NSPhotoLibraryAddUsageDescription + Grant access to Photo Library will allow Solian download photo to album for you. + NSPhotoLibraryUsageDescription + Grant access to Photo Library will allow Solian upload photo or video for your post. + NSUserActivityTypes + + INStartCallIntent + INSendMessageIntent + + PLIST_VERSION + 1 + REVERSED_CLIENT_ID + com.googleusercontent.apps.961776991058-stt7et4qvn3cpscl4r61gl1hnlatqkig + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + fetch + audio + remote-notification + voip + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortrait + + WKCompanionAppBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + + + \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 95cc1100..fa7fd971 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -30,6 +30,7 @@ import 'package:talker_flutter/talker_flutter.dart'; import 'package:talker_riverpod_logger/talker_riverpod_logger.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:window_manager/window_manager.dart'; +import 'package:protocol_handler/protocol_handler.dart'; @pragma('vm:entry-point') Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { @@ -50,6 +51,12 @@ void main() async { GoRouter.optionURLReflectsImperativeAPIs = true; } + if (!kIsWeb && (Platform.isLinux || Platform.isMacOS || Platform.isWindows)) { + talker.info("[SplashScreen] Initializing desktop window manager..."); + await protocolHandler.register('myprotocol'); + talker.info("[SplashScreen] Desktop window manager is ready!"); + } + try { await EasyLocalization.ensureInitialized(); diff --git a/lib/widgets/app_wrapper.dart b/lib/widgets/app_wrapper.dart index 3607085b..0f92f814 100644 --- a/lib/widgets/app_wrapper.dart +++ b/lib/widgets/app_wrapper.dart @@ -1,8 +1,7 @@ import 'dart:async'; -import 'package:app_links/app_links.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:protocol_handler/protocol_handler.dart'; import 'package:island/pods/activity/activity_rpc.dart'; import 'package:island/pods/websocket.dart'; import 'package:island/route.dart'; @@ -15,57 +14,61 @@ import 'package:island/widgets/tour/tour.dart'; import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; -class AppWrapper extends HookConsumerWidget with TrayListener { +class AppWrapper extends ConsumerStatefulWidget { final Widget child; const AppWrapper({super.key, required this.child}); @override - Widget build(BuildContext context, WidgetRef ref) { - useEffect(() { - StreamSubscription? ntySubs; - StreamSubscription? appLinksSubs; - Future(() async { - final appLinks = AppLinks(); + ConsumerState createState() => _AppWrapperState(); +} - if (context.mounted) ntySubs = setupNotificationListener(context, ref); +class _AppWrapperState extends ConsumerState + with ProtocolListener, TrayListener { + StreamSubscription? ntySubs; + bool networkStateShowing = false; - final sharingService = SharingIntentService(); - if (context.mounted) sharingService.initialize(context); - if (context.mounted) UpdateService().checkForUpdates(context); + @override + void initState() { + super.initState(); + protocolHandler.addListener(this); + Future(() async { + if (mounted) ntySubs = setupNotificationListener(context, ref); - TrayService.instance.initialize(this); + final sharingService = SharingIntentService(); + if (mounted) sharingService.initialize(context); + if (mounted) UpdateService().checkForUpdates(context); - ref.read(rpcServerStateProvider.notifier).start(); + TrayService.instance.initialize(this); - final initialUri = await appLinks.getLatestLink(); - if (initialUri != null && context.mounted) { - WidgetsBinding.instance.addPostFrameCallback((_) { - _handleDeepLink(initialUri, ref); - }); - } + ref.read(rpcServerStateProvider.notifier).start(); - appLinksSubs = appLinks.uriLinkStream.listen((uri) { - _handleDeepLink(uri, ref); + final initialUrl = await protocolHandler.getInitialUrl(); + if (initialUrl != null && mounted) { + WidgetsBinding.instance.addPostFrameCallback((_) { + _handleDeepLink(Uri.parse(initialUrl), ref); }); - }); + } + }); + } - return () { - ref.read(rpcServerProvider).stop(); - TrayService.instance.dispose(this); - ntySubs?.cancel(); - appLinksSubs?.cancel(); - }; - }, const []); + @override + void dispose() { + protocolHandler.removeListener(this); + ref.read(rpcServerProvider).stop(); + TrayService.instance.dispose(this); + ntySubs?.cancel(); + super.dispose(); + } + @override + Widget build(BuildContext context) { final wsNotifier = ref.watch(websocketStateProvider.notifier); final websocketState = ref.watch(websocketStateProvider); - final networkStateShowing = useState(false); - if (websocketState == WebSocketState.duplicateDevice()) { - if (!networkStateShowing.value) { + if (!networkStateShowing) { WidgetsBinding.instance.addPostFrameCallback((_) { - networkStateShowing.value = true; + setState(() => networkStateShowing = true); showModalBottomSheet( context: context, isScrollControlled: true, @@ -73,12 +76,17 @@ class AppWrapper extends HookConsumerWidget with TrayListener { builder: (context) => NetworkStatusSheet(onReconnect: () => wsNotifier.connect()), - ).then((_) => networkStateShowing.value = false); + ).then((_) => setState(() => networkStateShowing = false)); }); } } - return TourTriggerWidget(key: UniqueKey(), child: child); + return TourTriggerWidget(key: UniqueKey(), child: widget.child); + } + + @override + void onProtocolUrlReceived(String url) { + _handleDeepLink(Uri.parse(url), ref); } void _trayIconPrimaryAction() { diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index d6aee932..92b32344 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -51,9 +50,6 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin"); flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar); - g_autoptr(FlPluginRegistrar) gtk_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); - gtk_plugin_register_with_registrar(gtk_registrar); g_autoptr(FlPluginRegistrar) irondash_engine_context_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "IrondashEngineContextPlugin"); irondash_engine_context_plugin_register_with_registrar(irondash_engine_context_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 6ff0e93a..ee7cd27f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -10,7 +10,6 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_timezone flutter_udid flutter_webrtc - gtk irondash_engine_context livekit_client media_kit_libs_linux diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 92655d2d..83553073 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,7 +5,6 @@ import FlutterMacOS import Foundation -import app_links import connectivity_plus import device_info_plus import file_picker @@ -31,6 +30,7 @@ import media_kit_video import package_info_plus import pasteboard import path_provider_foundation +import protocol_handler_macos import record_macos import screen_retriever_macos import share_plus @@ -47,7 +47,6 @@ import wakelock_plus import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin")) @@ -73,6 +72,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + ProtocolHandlerMacosPlugin.register(with: registry.registrar(forPlugin: "ProtocolHandlerMacosPlugin")) RecordMacOsPlugin.register(with: registry.registrar(forPlugin: "RecordMacOsPlugin")) ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) diff --git a/macos/Podfile.lock b/macos/Podfile.lock index a7d5a73d..fbd2b84a 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -1,6 +1,4 @@ PODS: - - app_links (6.4.1): - - FlutterMacOS - connectivity_plus (0.0.1): - FlutterMacOS - croppy (0.0.1): @@ -199,6 +197,8 @@ PODS: - PromisesObjC (2.4.0) - PromisesSwift (2.4.0): - PromisesObjC (= 2.4.0) + - protocol_handler_macos (0.0.1): + - FlutterMacOS - record_macos (1.1.0): - FlutterMacOS - SAMKeychain (1.5.3) @@ -256,7 +256,6 @@ PODS: - FlutterMacOS DEPENDENCIES: - - app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`) - connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`) - croppy (from `Flutter/ephemeral/.symlinks/plugins/croppy/macos`) - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) @@ -284,6 +283,7 @@ DEPENDENCIES: - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - pasteboard (from `Flutter/ephemeral/.symlinks/plugins/pasteboard/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - protocol_handler_macos (from `Flutter/ephemeral/.symlinks/plugins/protocol_handler_macos/macos`) - record_macos (from `Flutter/ephemeral/.symlinks/plugins/record_macos/macos`) - screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) @@ -323,8 +323,6 @@ SPEC REPOS: - WebRTC-SDK EXTERNAL SOURCES: - app_links: - :path: Flutter/ephemeral/.symlinks/plugins/app_links/macos connectivity_plus: :path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos croppy: @@ -379,6 +377,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/pasteboard/macos path_provider_foundation: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + protocol_handler_macos: + :path: Flutter/ephemeral/.symlinks/plugins/protocol_handler_macos/macos record_macos: :path: Flutter/ephemeral/.symlinks/plugins/record_macos/macos screen_retriever_macos: @@ -409,7 +409,6 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos SPEC CHECKSUMS: - app_links: 05a6ec2341985eb05e9f97dc63f5837c39895c3f connectivity_plus: 4adf20a405e25b42b9c9f87feff8f4b6fde18a4e croppy: d9bfc8c02f3cd1851f669a421df298a474b78f43 device_info_plus: 4fb280989f669696856f8b129e4a5e3cd6c48f76 @@ -454,6 +453,7 @@ SPEC CHECKSUMS: path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 + protocol_handler_macos: f9cd7b13bcaf6b0425f7410cbe52376cb843a936 record_macos: 43194b6c06ca6f8fa132e2acea72b202b92a0f5b SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c screen_retriever_macos: 452e51764a9e1cdb74b3c541238795849f21557f diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist index 23eb0c45..f26f1a43 100644 --- a/macos/Runner/Info.plist +++ b/macos/Runner/Info.plist @@ -1,45 +1,58 @@ - - ITSAppUsesNonExemptEncryption - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Solian - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSHumanReadableCopyright - $(PRODUCT_COPYRIGHT) - NSMainNibFile - MainMenu - LSApplicationCategoryType - public.app-category.social-networking - NSPrincipalClass - NSApplication - NSSupportsAutomaticTermination - - UIApplicationSceneManifest - UIApplicationSupportsMultipleScenes - - UISceneConfigurations - + ITSAppUsesNonExemptEncryption + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Solian + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + LSApplicationCategoryType + public.app-category.social-networking + NSPrincipalClass + NSApplication + NSSupportsAutomaticTermination + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + + CFBundleURLSchemes + + solian + + + - - + \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 42240f19..e7007670 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,38 +49,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" - app_links: - dependency: "direct main" - description: - name: app_links - sha256: "5f88447519add627fe1cbcab4fd1da3d4fed15b9baf29f28b22535c95ecee3e8" - url: "https://pub.dev" - source: hosted - version: "6.4.1" - app_links_linux: - dependency: transitive - description: - name: app_links_linux - sha256: f5f7173a78609f3dfd4c2ff2c95bd559ab43c80a87dc6a095921d96c05688c81 - url: "https://pub.dev" - source: hosted - version: "1.0.3" - app_links_platform_interface: - dependency: transitive - description: - name: app_links_platform_interface - sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f" - url: "https://pub.dev" - source: hosted - version: "2.0.2" - app_links_web: - dependency: transitive - description: - name: app_links_web - sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555 - url: "https://pub.dev" - source: hosted - version: "1.0.4" archive: dependency: "direct main" description: @@ -429,10 +397,10 @@ packages: dependency: "direct main" description: name: device_info_plus - sha256: "98f28b42168cc509abc92f88518882fd58061ea372d7999aecc424345c7bff6a" + sha256: "72d146c6d7098689ff5c5f66bcf593ac11efc530095385356e131070333e64da" url: "https://pub.dev" source: hosted - version: "11.5.0" + version: "11.3.0" device_info_plus_platform_interface: dependency: transitive description: @@ -1245,14 +1213,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.3.4" - gtk: - dependency: transitive - description: - name: gtk - sha256: e8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c - url: "https://pub.dev" - source: hosted - version: "2.1.0" highlight: dependency: transitive description: @@ -1957,6 +1917,54 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.0" + protocol_handler: + dependency: "direct main" + description: + name: protocol_handler + sha256: dc2e2dcb1e0e313c3f43827ec3fa6d98adee6e17edc0c3923ac67efee87479a9 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + protocol_handler_android: + dependency: transitive + description: + name: protocol_handler_android + sha256: "82eb860ca42149e400328f54b85140329a1766d982e94705b68271f6ca73895c" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + protocol_handler_ios: + dependency: transitive + description: + name: protocol_handler_ios + sha256: "0d3a56b8c1926002cb1e32b46b56874759f4dcc8183d389b670864ac041b6ec2" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + protocol_handler_macos: + dependency: transitive + description: + name: protocol_handler_macos + sha256: "6eb8687a84e7da3afbc5660ce046f29d7ecf7976db45a9dadeae6c87147dd710" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + protocol_handler_platform_interface: + dependency: transitive + description: + name: protocol_handler_platform_interface + sha256: "53776b10526fdc25efdf1abcf68baf57fdfdb75342f4101051db521c9e3f3e5b" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + protocol_handler_windows: + dependency: transitive + description: + name: protocol_handler_windows + sha256: d8f3a58938386aca2c76292757392f4d059d09f11439d6d896d876ebe997f2c4 + url: "https://pub.dev" + source: hosted + version: "0.2.0" provider: dependency: transitive description: @@ -2984,10 +2992,10 @@ packages: dependency: transitive description: name: win32_registry - sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae" + sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "1.1.5" window_manager: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 6ee1f323..b799afec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,7 +67,8 @@ dependencies: flutter_inappwebview: ^6.1.5 animations: ^2.1.0 package_info_plus: ^9.0.0 - device_info_plus: ^11.5.0 + device_info_plus: ^11.2.2 + protocol_handler: ^0.2.0 tus_client_dart: git: https://github.com/LittleSheep2Code/tus_client.git cross_file: ^0.3.5 @@ -158,7 +159,6 @@ dependencies: talker_logger: ^5.0.2 talker_dio_logger: ^5.0.2 talker_riverpod_logger: ^5.0.1 - app_links: ^6.4.1 syncfusion_flutter_pdfviewer: ^31.1.21 swipe_to: ^1.0.6 fl_heatmap: ^0.4.6 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 73c96506..25bc2bcd 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,6 @@ #include "generated_plugin_registrant.h" -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -38,8 +38,6 @@ #include void RegisterPlugins(flutter::PluginRegistry* registry) { - AppLinksPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("AppLinksPluginCApi")); ConnectivityPlusWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); DartIpcPluginCApiRegisterWithRegistrar( @@ -76,6 +74,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi")); PasteboardPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PasteboardPlugin")); + ProtocolHandlerWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ProtocolHandlerWindowsPluginCApi")); RecordWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("RecordWindowsPluginCApi")); ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index c6964180..4df5b4cd 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - app_links connectivity_plus dart_ipc file_saver @@ -22,6 +21,7 @@ list(APPEND FLUTTER_PLUGIN_LIST media_kit_libs_windows_video media_kit_video pasteboard + protocol_handler_windows record_windows screen_retriever_windows share_plus diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index 276c9d0b..11ccfc46 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -1,51 +1,23 @@ #include #include #include -#include "app_links/app_links_plugin_c_api.h" #include "flutter_window.h" #include "utils.h" -bool SendAppLinkToInstance(const std::wstring& title) { - // Find our exact window - HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", title.c_str()); - - if (hwnd) { - // Dispatch new link to current window - SendAppLink(hwnd); - - // (Optional) Restore our window to front in same state - WINDOWPLACEMENT place = { sizeof(WINDOWPLACEMENT) }; - GetWindowPlacement(hwnd, &place); - - switch(place.showCmd) { - case SW_SHOWMAXIMIZED: - ShowWindow(hwnd, SW_SHOWMAXIMIZED); - break; - case SW_SHOWMINIMIZED: - ShowWindow(hwnd, SW_RESTORE); - break; - default: - ShowWindow(hwnd, SW_NORMAL); - break; - } - - SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); - SetForegroundWindow(hwnd); - // END (Optional) Restore - - // Window has been found, don't create another one. - return true; - } - - return false; -} +#include int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, _In_ int show_command) { - if (SendAppLinkToInstance(L"solian")) { - return EXIT_SUCCESS; + HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"Solian"); + if (hwnd != NULL) + { + DispatchToProtocolHandler(hwnd); + + ::ShowWindow(hwnd, SW_NORMAL); + ::SetForegroundWindow(hwnd); + return EXIT_FAILURE; } // Attach to console when present (e.g., 'flutter run') or create a