diff --git a/android/app/build.gradle b/android/app/build.gradle index 2670e8d..3f2ea17 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -23,6 +23,7 @@ if (flutterVersionName == null) { } android { + namespace "com.example.skyle_ik" compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion diff --git a/android/gradle.properties b/android/gradle.properties index 94adc3a..baa47a1 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true +android.ndk.suppressMinSdkVersionError=21 \ No newline at end of file diff --git a/lib/app.dart b/lib/app.dart index 90fede1..8aaa09d 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -12,6 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:gaze_interactive/api.dart'; +import 'package:millimeters/millimeters.dart'; import 'package:skyle_api/api.dart' as skyle; import 'package:skyle_ik/config/positioning_type_notifier.dart'; import 'package:universal_platform/universal_platform.dart'; @@ -25,7 +26,7 @@ import 'ui/main/theme.dart'; import 'util/windows_monitor.dart'; class SkyleApp extends ConsumerStatefulWidget { - const SkyleApp({Key? key}) : super(key: key); + const SkyleApp({super.key}); @override ConsumerState createState() => _SkyleAppState(); @@ -148,7 +149,9 @@ class _SkyleAppState extends ConsumerState with WidgetsBindingObserver skyle.IPadModel model; final deviceInfo = DeviceInfoPlugin(); final iosInfo = await deviceInfo.iosInfo; - final deviceModel = iosInfo.utsname.machine!; + final deviceModel = iosInfo.utsname.machine; + final size = Millimeters.of(context).physical; + model = skyle.IPadModel.values.firstWhere((element) => element.name == deviceModel.replaceAll(',', '_'), orElse: () { print('iPad $deviceModel is not compatible with Skyle'); return skyle.IPadModel.iPad13_11; @@ -159,6 +162,10 @@ class _SkyleAppState extends ConsumerState with WidgetsBindingObserver width: width, height: height, ), + dimensions: skyle.Size( + width: size.width, + height: size.height, + ), ), ); final zoomed = MediaQueryExtension.isZoomed(context); @@ -178,7 +185,7 @@ class _SkyleAppState extends ConsumerState with WidgetsBindingObserver changed = true; print('Reset because of iPadModel = $model'); } - final isOld = iosInfo.systemVersion!.compareTo('13.4') < 0; + final isOld = iosInfo.systemVersion.compareTo('13.4') < 0; if (iPadOS.isOld != isOld) { iPadOS = iPadOS.copyWith(isOld: isOld); changed = true; diff --git a/lib/config/routes/main_route_information_parser.dart b/lib/config/routes/main_route_information_parser.dart index c8d086e..2a9666c 100644 --- a/lib/config/routes/main_route_information_parser.dart +++ b/lib/config/routes/main_route_information_parser.dart @@ -10,13 +10,13 @@ import 'route_state.dart'; class MainRouteInformationParser extends RouteInformationParser { @override Future parseRouteInformation(RouteInformation routeInformation) async { - final uri = Uri.parse(routeInformation.location!); + final uri = Uri.parse(routeInformation.uri.path); String? id; return RouteState(route: uri.path, id: id); } @override RouteInformation restoreRouteInformation(RouteState configuration) { - return RouteInformation(location: configuration.route); + return RouteInformation(uri: Uri.parse(configuration.route)); } } diff --git a/lib/main.dart b/lib/main.dart index b7f259f..276a1f9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,12 +5,11 @@ // import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:gaze_interactive/api.dart'; +import 'package:millimeters/millimeters.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:skyle_api/api.dart' as skyle; -import 'package:universal_platform/universal_platform.dart'; -import 'package:window_size/window_size.dart'; +import 'package:window_manager/window_manager.dart'; import 'app.dart'; import 'config/app_state.dart'; @@ -24,11 +23,22 @@ Future main() async { AppState().sharedPreferences = await SharedPreferences.getInstance(); skyle.ET.logger = Logger(); - if (UniversalPlatform.isMacOS) { - final Screen screen = (await getCurrentScreen())!; - setWindowFrame(screen.frame); - setWindowMinSize(const Size(1024, 768)); - } + await windowManager.ensureInitialized(); + const windowOptions = WindowOptions(center: true, minimumSize: Size(1440, 900), titleBarStyle: TitleBarStyle.hidden); + await windowManager.waitUntilReadyToShow(windowOptions, () async { + await windowManager.show(); + await windowManager.focus(); + await windowManager.setSize(const Size(1440, 900)); + }); - runApp(GazeContext(sharedPreferences: AppState().sharedPreferences, child: const SkyleApp())); + print(windowManager.getDevicePixelRatio()); + + runApp( + Millimeters.fromView( + child: GazeContext( + sharedPreferences: AppState().sharedPreferences, + child: const SkyleApp(), + ), + ), + ); } diff --git a/lib/ui/calibration/calibration_view.dart b/lib/ui/calibration/calibration_view.dart index bbff5e2..92a5a2f 100644 --- a/lib/ui/calibration/calibration_view.dart +++ b/lib/ui/calibration/calibration_view.dart @@ -10,7 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:gaze_interactive/api.dart'; +import 'package:millimeters/millimeters.dart'; import 'package:skyle_api/api.dart' as skyle; +import 'package:window_manager/window_manager.dart'; import '../../config/routes/main_routes.dart'; import '../../config/routes/routes.dart'; @@ -20,7 +22,7 @@ import '../calibration/pointer_view.dart'; import '../calibration/reference_points_view.dart'; class CalibrationView extends ConsumerStatefulWidget { - const CalibrationView({Key? key}) : super(key: key); + const CalibrationView({super.key}); @override ConsumerState createState() => _CalibrationViewState(); @@ -59,6 +61,7 @@ class _CalibrationViewState extends ConsumerState with SingleTi SchedulerBinding.instance.addPostFrameCallback((_) async { await Future.delayed(const Duration(milliseconds: 1000)); + if (mounted) { calibrationProvider = StreamProvider.autoDispose((ref) { ref.onDispose(() { @@ -66,7 +69,9 @@ class _CalibrationViewState extends ConsumerState with SingleTi }); final MediaQueryData mediaQuery = MediaQuery.of(context); final calibrationPoints = ref.read(AppState().calibrationPointsProvider); - + print("Starting calibration"); + final size = Millimeters.of(context).physical; + print(size); return AppState().et.calibration.calibrate( calibrationPoints, screenSizes: skyle.ScreenSizes( @@ -74,9 +79,9 @@ class _CalibrationViewState extends ConsumerState with SingleTi width: mediaQuery.size.width, height: mediaQuery.size.height, ), - dimensions: const skyle.Size( - width: 1920, - height: 1080, + dimensions: skyle.Size( + width: size.width, + height: size.height, ), ), stepped: true, @@ -92,6 +97,7 @@ class _CalibrationViewState extends ConsumerState with SingleTi Future _listener(skyle.Connection connection) async { if (connection == skyle.Connection.disconnected) { + Future.delayed(const Duration(milliseconds: 300), () async => windowManager.setFullScreen(false)); Routes.backAll(); } } @@ -180,6 +186,7 @@ class _CalibrationViewState extends ConsumerState with SingleTi await AppState().et.settings.disableMouse(); } }); + Future.delayed(const Duration(milliseconds: 300), () async => windowManager.setFullScreen(false)); Routes.backAll(); }, route: MainRoutes.capture.path, diff --git a/lib/ui/main/main_view.dart b/lib/ui/main/main_view.dart index d469479..f37ec6c 100644 --- a/lib/ui/main/main_view.dart +++ b/lib/ui/main/main_view.dart @@ -14,6 +14,7 @@ import 'package:gaze_interactive/api.dart'; import 'package:minimize_app/minimize_app.dart'; import 'package:skyle_api/api.dart'; import 'package:universal_platform/universal_platform.dart'; +import 'package:window_manager/window_manager.dart'; import '../../config/routes/main_routes.dart'; import '../../config/routes/routes.dart'; @@ -271,7 +272,9 @@ class _StartButton extends StatelessWidget { ), route: MainRoutes.home.path, ), - onTap: () { + onTap: () async { + windowManager.setFullScreen(true); + await Future.delayed(const Duration(milliseconds: 500)); Routes.route(MainRoutes.capture.path); }, ), diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 86bbf31..511f65c 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,13 +7,17 @@ #include "generated_plugin_registrant.h" #include -#include +#include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); - g_autoptr(FlPluginRegistrar) window_size_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin"); - window_size_plugin_register_with_registrar(window_size_registrar); + 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) window_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); + window_manager_plugin_register_with_registrar(window_manager_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 8e788ba..3c43c3f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,7 +4,8 @@ list(APPEND FLUTTER_PLUGIN_LIST audioplayers_linux - window_size + screen_retriever + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 7fde6c8..68fd101 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,16 +7,20 @@ import Foundation import audioplayers_darwin import device_info_plus +import millimeters import path_provider_foundation +import screen_retriever import shared_preferences_foundation import speech_to_text -import window_size +import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + MillimetersPlugin.register(with: registry.registrar(forPlugin: "MillimetersPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SpeechToTextPlugin.register(with: registry.registrar(forPlugin: "SpeechToTextPlugin")) - WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin")) + WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 36a711b..9f123c1 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -4,9 +4,13 @@ PODS: - device_info_plus (0.0.1): - FlutterMacOS - FlutterMacOS (1.0.0) + - millimeters (0.0.1): + - FlutterMacOS - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS + - screen_retriever (0.0.1): + - FlutterMacOS - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS @@ -15,17 +19,19 @@ PODS: - FlutterMacOS - Try - Try (2.1.1) - - window_size (0.0.2): + - window_manager (0.2.0): - FlutterMacOS DEPENDENCIES: - audioplayers_darwin (from `Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos`) - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) - FlutterMacOS (from `Flutter/ephemeral`) + - millimeters (from `Flutter/ephemeral/.symlinks/plugins/millimeters/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - speech_to_text (from `Flutter/ephemeral/.symlinks/plugins/speech_to_text/darwin`) - - window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`) + - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) SPEC REPOS: trunk: @@ -38,24 +44,30 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos FlutterMacOS: :path: Flutter/ephemeral + millimeters: + :path: Flutter/ephemeral/.symlinks/plugins/millimeters/macos path_provider_foundation: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + screen_retriever: + :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin speech_to_text: :path: Flutter/ephemeral/.symlinks/plugins/speech_to_text/darwin - window_size: - :path: Flutter/ephemeral/.symlinks/plugins/window_size/macos + window_manager: + :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos SPEC CHECKSUMS: audioplayers_darwin: dcad41de4fbd0099cb3749f7ab3b0cb8f70b810c device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + millimeters: 2ac76daaf7ecbfbee7f85f0c43845282af3fcff5 path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 + screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 speech_to_text: 627d3fd2194770b51abb324ba45c2d39398f24a8 Try: 5ef669ae832617b3cee58cb2c6f99fb767a4ff96 - window_size: 339dafa0b27a95a62a843042038fa6c3c48de195 + window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 diff --git a/pubspec.lock b/pubspec.lock index f3fd759..1f851a2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -513,6 +513,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.0" + millimeters: + dependency: "direct main" + description: + name: millimeters + sha256: bb79f045b7958b4faff406e911c058eec6c689e4784b4133d6a579d99664691f + url: "https://pub.dev" + source: hosted + version: "0.3.0" minimize_app: dependency: "direct main" description: @@ -682,6 +690,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.5" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90" + url: "https://pub.dev" + source: hosted + version: "0.1.9" shared_preferences: dependency: "direct main" description: @@ -952,15 +968,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.5" - window_size: + window_manager: dependency: "direct main" description: - path: "plugins/window_size" - ref: HEAD - resolved-ref: eb3964990cf19629c89ff8cb4a37640c7b3d5601 - url: "https://github.com/google/flutter-desktop-embedding.git" - source: git - version: "0.1.0" + name: window_manager + sha256: ab8b2a7f97543d3db2b506c9d875e637149d48ee0c6a5cb5f5fd6e0dac463792 + url: "https://pub.dev" + source: hosted + version: "0.4.2" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4074b20..e3ea609 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A simple example application to calibrate the Skyle eye-tracker. publish_to: 'none' -version: 2.0.0 +version: 2.1.0 environment: sdk: '>=2.18.0 <3.0.0' @@ -33,10 +33,11 @@ dependencies: logger: ^2.4.0 + millimeters: ^0.3.0 minimize_app: git: url: https://github.com/krjw-eyev/minimize_app_plugin.git - + shared_preferences: ^2.0.3 path: ^1.8.2 @@ -50,10 +51,7 @@ dependencies: win32: ^5.5.4 - window_size: - git: - url: https://github.com/google/flutter-desktop-embedding.git - path: plugins/window_size + window_manager: ^0.4.2 dependency_overrides: # gaze_interactive: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index d1a2f83..f5dbd3f 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,11 +7,17 @@ #include "generated_plugin_registrant.h" #include -#include +#include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { AudioplayersWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); - WindowSizePluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WindowSizePlugin")); + MillimetersPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("MillimetersPluginCApi")); + ScreenRetrieverPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + WindowManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 8985746..b2d5f01 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,7 +4,9 @@ list(APPEND FLUTTER_PLUGIN_LIST audioplayers_windows - window_size + millimeters + screen_retriever + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST