From 127c997ea151aced7d304886d4a3bb4b04ee2b10 Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Sat, 13 Dec 2025 15:17:28 +0100 Subject: [PATCH] less warnings for Click V2 users --- .../devices/zwift/zwift_clickv2.dart | 122 ++++++++++-------- lib/i10n/intl_en.arb | 3 +- linux/flutter/generated_plugin_registrant.cc | 8 ++ linux/flutter/generated_plugins.cmake | 2 + pubspec.lock | 8 +- 5 files changed, 84 insertions(+), 59 deletions(-) diff --git a/lib/bluetooth/devices/zwift/zwift_clickv2.dart b/lib/bluetooth/devices/zwift/zwift_clickv2.dart index 8795064..d3e321c 100644 --- a/lib/bluetooth/devices/zwift/zwift_clickv2.dart +++ b/lib/bluetooth/devices/zwift/zwift_clickv2.dart @@ -4,7 +4,6 @@ import 'package:shadcn_flutter/shadcn_flutter.dart'; import 'package:swift_control/bluetooth/devices/zwift/constants.dart'; import 'package:swift_control/bluetooth/devices/zwift/protocol/zp.pbenum.dart'; import 'package:swift_control/bluetooth/devices/zwift/zwift_ride.dart'; -import 'package:swift_control/bluetooth/messages/notification.dart'; import 'package:swift_control/gen/l10n.dart'; import 'package:swift_control/pages/markdown.dart'; import 'package:swift_control/utils/core.dart'; @@ -51,12 +50,6 @@ class ZwiftClickV2 extends ZwiftRide { if (bytes.startsWith(ZwiftConstants.RESPONSE_STOPPED_CLICK_V2_VARIANT_1) || bytes.startsWith(ZwiftConstants.RESPONSE_STOPPED_CLICK_V2_VARIANT_2)) { _noLongerSendsEvents = true; - actionStreamInternal.add( - AlertNotification( - LogLevel.LOGLEVEL_WARNING, - 'Your Zwift Click V2 no longer sends events. Connect it in the Zwift app once each session.', - ), - ); } return super.processData(bytes); } @@ -72,53 +65,74 @@ class ZwiftClickV2 extends ZwiftRide { children: [ super.showInformation(context), - if (isConnected && _noLongerSendsEvents && core.settings.getShowZwiftClickV2ReconnectWarning()) - Warning( - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - AppLocalizations.of(context).clickV2Instructions, - ).xSmall, - ), - IconButton.link( - icon: Icon(Icons.close), - onPressed: () { - core.settings.setShowZwiftClickV2ReconnectWarning(false); - setState(() {}); - }, - ), - ], - ), - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - spacing: 8, - children: [ - GhostButton( - onPressed: () { - sendCommand(Opcode.RESET, null); - }, - child: Text('Reset now'), - ), - OutlineButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), - ), - ); - }, - leading: const Icon(Icons.open_in_new), - child: Text(context.i18n.troubleshootingGuide), - ), - ], - ), - ], - ), + if (isConnected && _noLongerSendsEvents) + if (core.settings.getShowZwiftClickV2ReconnectWarning()) + Warning( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + AppLocalizations.of(context).clickV2Instructions, + ).xSmall, + ), + IconButton.link( + icon: Icon(Icons.close), + onPressed: () { + core.settings.setShowZwiftClickV2ReconnectWarning(false); + setState(() {}); + }, + ), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 8, + children: [ + GhostButton( + onPressed: () { + sendCommand(Opcode.RESET, null); + }, + child: Text('Reset now'), + ), + OutlineButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), + ), + ); + }, + leading: const Icon(Icons.open_in_new), + child: Text(context.i18n.troubleshootingGuide), + ), + ], + ), + ], + ) + else + Warning( + important: false, + children: [ + Text( + AppLocalizations.of(context).clickV2EventInfo, + ).xSmall, + LinkButton( + child: Text(context.i18n.troubleshootingGuide), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), + ), + ); + }, + ), + ], + ), ], ); }, diff --git a/lib/i10n/intl_en.arb b/lib/i10n/intl_en.arb index 3e6e079..a062ffa 100644 --- a/lib/i10n/intl_en.arb +++ b/lib/i10n/intl_en.arb @@ -457,5 +457,6 @@ "noTrainerSelected": "No Trainer selected", "instructions": "Instructions", "mailSupportExplanation": "Providing individual support via email is a lot of work for me.\n\nPlease consider using Reddit, Facebook or GitHub for questions and issues so that the whole community can benefit from it.", - "myWhooshLinkInfo": "Please check the troubleshooting section if you encounter any issues. A much more reliable connection method is coming soon!" + "myWhooshLinkInfo": "Please check the troubleshooting section if you encounter any issues. A much more reliable connection method is coming soon!", + "clickV2EventInfo": "Your Click V2 may no longer send button events. Please check by tapping a few buttons and see if they are visible in BikeControl." } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 1c45750..205b9e5 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -9,10 +9,12 @@ #include #include #include +#include #include #include #include #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) bluetooth_low_energy_linux_registrar = @@ -24,6 +26,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) gamepads_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "GamepadsLinuxPlugin"); gamepads_linux_plugin_register_with_registrar(gamepads_linux_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) media_key_detector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKeyDetectorPlugin"); media_key_detector_plugin_register_with_registrar(media_key_detector_linux_registrar); @@ -36,4 +41,7 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) window_manager_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); window_manager_plugin_register_with_registrar(window_manager_registrar); + g_autoptr(FlPluginRegistrar) yaru_window_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "YaruWindowLinuxPlugin"); + yaru_window_linux_plugin_register_with_registrar(yaru_window_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 4f57d1b..483dedc 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -6,10 +6,12 @@ list(APPEND FLUTTER_PLUGIN_LIST bluetooth_low_energy_linux file_selector_linux gamepads_linux + gtk media_key_detector_linux screen_retriever_linux url_launcher_linux window_manager + yaru_window_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/pubspec.lock b/pubspec.lock index ebd44e7..e53a324 100755 --- a/pubspec.lock +++ b/pubspec.lock @@ -863,10 +863,10 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" mime: dependency: transitive description: @@ -1365,10 +1365,10 @@ packages: dependency: transitive description: name: test_api - sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 url: "https://pub.dev" source: hosted - version: "0.7.6" + version: "0.7.7" time: dependency: transitive description: