From 715b2c6876c9191cb5f60468bdbf4cc63f53b442 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 2 Feb 2022 12:18:08 -0800 Subject: [PATCH 1/6] windows notifications: switch from desktoats to win_toats --- lib/notification_manager.dart | 61 +++++++++---------- pubspec.lock | 14 ++--- pubspec.yaml | 2 +- .../flutter/generated_plugin_registrant.cc | 9 ++- windows/flutter/generated_plugins.cmake | 3 +- 5 files changed, 44 insertions(+), 45 deletions(-) diff --git a/lib/notification_manager.dart b/lib/notification_manager.dart index 91f1cb52..68f56f3e 100644 --- a/lib/notification_manager.dart +++ b/lib/notification_manager.dart @@ -1,7 +1,8 @@ +import 'dart:async'; import 'dart:io'; import 'package:cwtch/main.dart'; -import 'package:desktoasts/desktoasts.dart'; +import 'package:win_toast/win_toast.dart'; import 'package:desktop_notifications/desktop_notifications.dart'; import 'package:path/path.dart' as path; @@ -30,51 +31,43 @@ class LinuxNotificationsManager implements NotificationsManager { Future notify(String message) async { var iconPath = Uri.file(path.join(path.current, "cwtch.png")); - client.notify(message, appName: "cwtch", appIcon: iconPath.toString(), replacesId: this.previous_id).then((Notification value) => previous_id = value.id); + client + .notify(message, + appName: "cwtch", + appIcon: iconPath.toString(), + replacesId: this.previous_id) + .then((Notification value) => previous_id = value.id); } } // Windows Notification Manager uses https://pub.dev/packages/desktoasts to implement // windows notifications class WindowsNotificationManager implements NotificationsManager { - late ToastService service; bool active = false; + bool initialized = false; WindowsNotificationManager() { - service = new ToastService( - appName: 'cwtch', - companyName: 'Open Privacy Research Society', - productName: 'Cwtch', - ); - - service.stream.listen((event) { - // the user closed the notification of the OS timed it out - if (event is ToastDismissed) { - active = false; - } - // clicked - if (event is ToastActivated) { - active = false; - } - // if a supplied action was clicked - if (event is ToastInteracted) { - active = false; - } + scheduleMicrotask(() async { + initialized = await WinToast.instance().initialize( + appName: 'cwtch', + productName: 'Cwtch', + companyName: 'Open Privacy Research Society'); }); } Future notify(String message) async { - if (!globalAppState.focus) { + if (initialized && !globalAppState.focus) { if (!active) { - // One string of bold text on the first line (title), - // one string (subtitle) of regular text wrapped across the second and third lines. - Toast toast = new Toast( - type: ToastType.text02, - title: 'Cwtch', - subtitle: message, - ); - service.show(toast); + WinToast.instance().clear(); + final toast = await WinToast.instance() + .showToast(type: ToastType.text01, title: message); active = true; + toast?.eventStream.listen((event) { + if (event is ActivatedEvent) { + WinToast.instance().bringWindowToFront(); + } + active = false; + }); } } } @@ -89,13 +82,15 @@ NotificationsManager newDesktopNotificationsManager() { client.getCapabilities(); return LinuxNotificationsManager(client); } catch (e) { - EnvironmentConfig.debugLog("Attempted to access DBUS for notifications but failed. Switching off notifications."); + EnvironmentConfig.debugLog( + "Attempted to access DBUS for notifications but failed. Switching off notifications."); } } else if (Platform.isWindows) { try { return WindowsNotificationManager(); } catch (e) { - EnvironmentConfig.debugLog("Failed to create Windows desktoasts notification manager"); + EnvironmentConfig.debugLog( + "Failed to create Windows desktoasts notification manager"); } } return NullNotificationsManager(); diff --git a/pubspec.lock b/pubspec.lock index 1e1a4bec..0fa7e9d9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -78,13 +78,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.5.2" - desktoasts: - dependency: "direct main" - description: - name: desktoasts - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.2" desktop_notifications: dependency: "direct main" description: @@ -474,6 +467,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.2.4" + win_toast: + dependency: "direct main" + description: + name: win_toast + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2" window_manager: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index c4dc007b..e13164d9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,7 +44,7 @@ dependencies: file_picker: ^4.3.2 file_picker_desktop: ^1.1.0 url_launcher: ^6.0.12 - desktoasts: ^0.0.2 + win_toast: ^0.0.2 window_manager: ^0.1.4 dev_dependencies: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 6859cc41..0177b517 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,12 +6,15 @@ #include "generated_plugin_registrant.h" -#include #include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { - DesktoastsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("DesktoastsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); + WinToastPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WinToastPlugin")); + WindowManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index cb499b22..21bba102 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,8 +3,9 @@ # list(APPEND FLUTTER_PLUGIN_LIST - desktoasts url_launcher_windows + win_toast + window_manager ) set(PLUGIN_BUNDLED_LIBRARIES) From a82ade8663a71a1c258145633a6369dcd4afaebe Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 25 Jan 2022 17:37:51 -0500 Subject: [PATCH 2/6] profile level unread notifications and in profile other profile unread notifications --- android/app/build.gradle | 4 ++-- lib/cwtch/cwtchNotifier.dart | 15 ++++++++++----- lib/models/appstate.dart | 17 +++++++++++++++++ lib/models/profile.dart | 18 ++++++++++++++++++ lib/models/profilelist.dart | 4 ++++ lib/themes/cwtch.dart | 6 +++--- lib/views/contactsview.dart | 24 ++++++++++++++++++++++++ lib/widgets/profilerow.dart | 3 ++- 8 files changed, 80 insertions(+), 11 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 4899ea9e..abbe8f45 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -65,8 +65,8 @@ android { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - // signingConfig signingConfigs.debug - signingConfig signingConfigs.release + signingConfig signingConfigs.debug + // signingConfig signingConfigs.release } } diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 0367c7ee..5584ae35 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -8,6 +8,7 @@ import 'package:cwtch/models/profileservers.dart'; import 'package:cwtch/models/remoteserver.dart'; import 'package:cwtch/models/servers.dart'; import 'package:cwtch/notification_manager.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:cwtch/torstatus.dart'; @@ -145,9 +146,10 @@ class CwtchNotifier { var senderImage = data['Picture']; var isAuto = data['Auto'] == "true"; String? contenthash = data['ContentHash']; - var selectedConversation = appState.selectedProfile == data["ProfileOnion"] && appState.selectedConversation == identifier; + var selectedProfile = appState.selectedProfile == data["ProfileOnion"]; + var selectedConversation = selectedProfile && appState.selectedConversation == identifier; - profileCN.getProfile(data["ProfileOnion"])?.contactList.newMessage( + profileCN.getProfile(data["ProfileOnion"])?.newMessage( identifier, messageID, timestamp, @@ -156,9 +158,10 @@ class CwtchNotifier { isAuto, data["Data"], contenthash, + selectedProfile, selectedConversation, ); - + appState.notifyProfileUnread(); break; case "PeerAcknowledgement": // We don't use these anymore, IndexedAcknowledgement is more suited to the UI front end... @@ -198,7 +201,8 @@ class CwtchNotifier { var currentTotal = contact!.totalMessages; var isAuto = data['Auto'] == "true"; String? contenthash = data['ContentHash']; - var selectedConversation = appState.selectedProfile == data["ProfileOnion"] && appState.selectedConversation == identifier; + var selectedProfile = appState.selectedProfile == data["ProfileOnion"]; + var selectedConversation = selectedProfile && appState.selectedConversation == identifier; // Only bother to do anything if we know about the group and the provided index is greater than our current total... if (currentTotal != null && idx >= currentTotal) { @@ -212,9 +216,10 @@ class CwtchNotifier { // For now we perform some minimal checks on the sent timestamp to use to provide a useful ordering for honest contacts // and ensure that malicious contacts in groups can only set this timestamp to a value within the range of `last seen message time` // and `local now`. - profileCN.getProfile(data["ProfileOnion"])?.contactList.newMessage(identifier, idx, timestampSent, senderHandle, senderImage, isAuto, data["Data"], contenthash, selectedConversation); + profileCN.getProfile(data["ProfileOnion"])?.newMessage(identifier, idx, timestampSent, senderHandle, senderImage, isAuto, data["Data"], contenthash, selectedProfile, selectedConversation); notificationManager.notify("New Message From Group!"); + appState.notifyProfileUnread(); } RemoteServerInfoState? server = profileCN.getProfile(data["ProfileOnion"])?.serverList.getServer(contact.server); server?.updateSyncProgressFor(timestampSent); diff --git a/lib/models/appstate.dart b/lib/models/appstate.dart index 5a2293c3..9d78dcbb 100644 --- a/lib/models/appstate.dart +++ b/lib/models/appstate.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/widgets.dart'; enum ModalState { none, storageMigration } @@ -16,6 +18,13 @@ class AppState extends ChangeNotifier { bool _disableFilePicker = false; bool _focus = true; + StreamController _profilesUnreadNotifyControler = StreamController(); + late Stream profilesUnreadNotify; + + AppState() { + profilesUnreadNotify = _profilesUnreadNotifyControler.stream.asBroadcastStream(); + } + void SetCwtchInit() { cwtchInit = true; notifyListeners(); @@ -82,4 +91,12 @@ class AppState extends ChangeNotifier { } bool isLandscape(BuildContext c) => MediaQuery.of(c).size.width > MediaQuery.of(c).size.height; + + void notifyProfileUnread() { + _profilesUnreadNotifyControler.add(true); + } + + Stream getUnreadProfileNotifyStream() { + return profilesUnreadNotify; + } } diff --git a/lib/models/profile.dart b/lib/models/profile.dart index 268eeb78..2c193865 100644 --- a/lib/models/profile.dart +++ b/lib/models/profile.dart @@ -173,6 +173,24 @@ class ProfileInfoState extends ChangeNotifier { this._contacts.resort(); } + void newMessage(int identifier, int messageID, DateTime timestamp, String senderHandle, String senderImage, bool isAuto, String data, String? contenthash, bool selectedProfile, bool selectedConversation) { + if (!selectedProfile) { + unreadMessages++; + notifyListeners(); + } + + contactList.newMessage( + identifier, + messageID, + timestamp, + senderHandle, + senderImage, + isAuto, + data, + contenthash, + selectedConversation); + } + void downloadInit(String fileKey, int numChunks) { this._downloads[fileKey] = FileDownloadProgress(numChunks, DateTime.now()); notifyListeners(); diff --git a/lib/models/profilelist.dart b/lib/models/profilelist.dart index 1e0eb3e2..8cae18b5 100644 --- a/lib/models/profilelist.dart +++ b/lib/models/profilelist.dart @@ -27,4 +27,8 @@ class ProfileListState extends ChangeNotifier { _profiles.removeWhere((element) => element.onion == onion); notifyListeners(); } + + int generateUnreadCount(String selectedProfile) => _profiles.where( (p) => p.onion != selectedProfile ).fold(0, (i, p) => i + p.unreadMessages); + + } diff --git a/lib/themes/cwtch.dart b/lib/themes/cwtch.dart index e4a660c5..5d0eb3e1 100644 --- a/lib/themes/cwtch.dart +++ b/lib/themes/cwtch.dart @@ -68,8 +68,8 @@ class CwtchDark extends OpaqueThemeType { get portraitBlockedTextColor => lightGrey; get portraitContactBadgeColor => hotPink; get portraitContactBadgeTextColor => whiteishPurple; - get portraitProfileBadgeColor => mauvePurple; - get portraitProfileBadgeTextColor => darkGreyPurple; + get portraitProfileBadgeColor => hotPink; + get portraitProfileBadgeTextColor => whiteishPurple; get dropShadowColor => mauvePurple; get toolbarIconColor => settings; //whiteishPurple; get messageFromMeBackgroundColor => userBubble; // mauvePurple; @@ -112,7 +112,7 @@ class CwtchLight extends OpaqueThemeType { get portraitBlockedTextColor => softGrey; get portraitContactBadgeColor => accent; get portraitContactBadgeTextColor => whitePurple; - get portraitProfileBadgeColor => brightPurple; + get portraitProfileBadgeColor => accent; get portraitProfileBadgeTextColor => whitePurple; get dropShadowColor => purple; get toolbarIconColor => settings; //darkPurple; diff --git a/lib/views/contactsview.dart b/lib/views/contactsview.dart index 7f6b2236..c7ab0271 100644 --- a/lib/views/contactsview.dart +++ b/lib/views/contactsview.dart @@ -76,6 +76,30 @@ class _ContactsViewState extends State { endDrawerEnableOpenDragGesture: false, drawerEnableOpenDragGesture: false, appBar: AppBar( + leading: Row(children: [ + IconButton( + icon: Icon(Icons.arrow_back), + tooltip: MaterialLocalizations.of(context).backButtonTooltip, + onPressed: () { + Provider.of(context, listen: false).selectedProfile = ""; + Navigator.of(context).pop(); + }, + ), + + StreamBuilder( + stream: Provider.of(context).getUnreadProfileNotifyStream(), + builder: (BuildContext context, AsyncSnapshot unreadCountSnapshot) { + int unreadCount = Provider.of(context).generateUnreadCount(Provider.of(context).selectedProfile ?? "") ; + + return Visibility( + visible: unreadCount > 0, + child: CircleAvatar( + radius: 10.0, + backgroundColor: Provider.of(context).theme.portraitProfileBadgeColor, + child: Text(unreadCount > 99 ? "99+" : unreadCount.toString(), style: TextStyle(color: Provider.of(context).theme.portraitProfileBadgeTextColor, fontSize: 8.0)), + )); + }), + ]), title: RepaintBoundary( child: Row(children: [ ProfileImage( diff --git a/lib/widgets/profilerow.dart b/lib/widgets/profilerow.dart index acbdce0a..2ddda6d9 100644 --- a/lib/widgets/profilerow.dart +++ b/lib/widgets/profilerow.dart @@ -33,7 +33,7 @@ class _ProfileRowState extends State { Padding( padding: const EdgeInsets.all(6.0), //border size child: ProfileImage( - badgeCount: 0, + badgeCount: profile.unreadMessages, badgeColor: Provider.of(context).theme.portraitProfileBadgeColor, badgeTextColor: Provider.of(context).theme.portraitProfileBadgeTextColor, diameter: 64.0, @@ -83,6 +83,7 @@ class _ProfileRowState extends State { } void _pushContactList(ProfileInfoState profile, bool isLandscape) { + Provider.of(context, listen: false).unreadMessages = 0; Navigator.of(context).push( MaterialPageRoute( settings: RouteSettings(name: "conversations"), From 1a9f0763d76b5e66008da144dfd392e2c81456ed Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 25 Jan 2022 17:47:13 -0500 Subject: [PATCH 3/6] update goldens with new profile unread widgetry --- android/app/build.gradle | 4 ++-- test/profileimage_init.png | Bin 6704 -> 6711 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index abbe8f45..4899ea9e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -65,8 +65,8 @@ android { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug - // signingConfig signingConfigs.release + // signingConfig signingConfigs.debug + signingConfig signingConfigs.release } } diff --git a/test/profileimage_init.png b/test/profileimage_init.png index a7f5369fbb2798cff8f5c79a5be0d11bee29f9a3..7f1a1602dc8364e69369a757518b40eb7665b2cc 100644 GIT binary patch literal 6711 zcmZWuc|26__rGKr``E^k7+m`jA=xv=GWLCoFxgYq?4q$w_KA{&EM=E9`z};=QVESE zRI-z7zuV{g=kLDmz0d1D%Q@$H&Uwyr&imqx4Yld0IjI2vpu^~(O`&q|-vgt7-j&u> zxllpkZ>o&~sz$ihp${^D6vi9|UEwh21OVV5V$ka5!8sex!vZX(pAU2%p6cIa+5sNK zfCy$%q6oFFh)I{BJDt5mpy(xE%S#P~*vh3_l_H+y4IdZt8!aEpNK|;bmEIP$*YhCP z>Jp_zCOo*F29oi`f%2&|hw0Cbv(+Sp+QCEL`P8t;yoOqW|E9vR*M9iP#=`vZugYkY z@;ATXJZ#O$TbOl5S+q4RnvX|qZXq&nVjtNzkUy2oKo&jMptbbMu+X=dTT0Y|LHhOj z{>qGPWt}Q5S)-Ue8_JG_nGA`6?H86H0Sv0-Vm~>F4il=q1O<-*d8hE6WF)m3gc~SD5?(J(ewNHv66MN^JutWr&w=S#chP_Uy~x#r2Ai!#hb6DFhHx^ z!ieBZshIx0m9=XI_&{Rpb0qJrOGi;LG#ald6e!ofaxnZ%`fzrE`>=Ut<89DJ;( zX9#~izJb2W0r*PVCHlIe=nqypAP!YhW9?}E6nwf20CjUIw>de-A{NQ^?CpKl_uXk? zoy(j?u$pZG{tQuOfb9_iT*e)Z^he!L{ZA#tuEw&>XGcorW)|m%GGJRMH^jeG|()w_4m|WHH1sGlVM|3 z(YK;OGo!X4K}ZUC^Cql9_y+KGs6kv6=Y>*U1%PE6`>ZSnlIWYc^wPxwL@~-}a{^e{ z+(14olnNCBt1);qf0NI)xFlT|liGd8Ted1szljbi_7zeBT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Kj#N=$d7vt3!sI{7+D-P=^yTw>Dla;`G%e(S05poMe6f+ zrkPJEyiT$uzTcp*v96Pm*aSkp0w0dbWAu?BP7ux%gL9ccr;pu8nu29~;mo^Od)rz- z;iSv=o=FHsJ^qBOXk8LQ`y|~n+h1HWH+8K?O{D8(b(SoNVvH~%&_Pz5r>T2K*_n~0 zj8VZ|qC5CwS7K1CxCxD&^8IH8JBI#?bLx3CtW*donr_F*7(o-InLfY=TsJg|bgPlX zbZn&(1^ZG5-67D^S*<{|B(jT;2cx From 8a9ee402bff4f1dabd300b5f53b361e1baa71d4e Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 3 Feb 2022 08:43:02 -0500 Subject: [PATCH 4/6] recalculate unrad count incases some not read --- lib/models/profile.dart | 5 +++++ lib/views/contactsview.dart | 1 + lib/widgets/profilerow.dart | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/models/profile.dart b/lib/models/profile.dart index 2c193865..ee10ec47 100644 --- a/lib/models/profile.dart +++ b/lib/models/profile.dart @@ -120,6 +120,10 @@ class ProfileInfoState extends ChangeNotifier { notifyListeners(); } + void recountUnread() { + this._unreadMessages = _contacts.contacts.fold(0, (i, c) => i + c.unreadMessages); + } + // Remove a contact from a list. Currently only used when rejecting a group invitation. // Eventually will also be used for other removals. void removeContact(String handle) { @@ -168,6 +172,7 @@ class ProfileInfoState extends ChangeNotifier { lastMessageTime: DateTime.fromMillisecondsSinceEpoch(1000 * int.parse(contact["lastMsgTime"])), )); } + unreadMessages += int.parse(contact["numUnread"]); }); } this._contacts.resort(); diff --git a/lib/views/contactsview.dart b/lib/views/contactsview.dart index c7ab0271..24168764 100644 --- a/lib/views/contactsview.dart +++ b/lib/views/contactsview.dart @@ -81,6 +81,7 @@ class _ContactsViewState extends State { icon: Icon(Icons.arrow_back), tooltip: MaterialLocalizations.of(context).backButtonTooltip, onPressed: () { + Provider.of(context, listen: false).recountUnread(); Provider.of(context, listen: false).selectedProfile = ""; Navigator.of(context).pop(); }, diff --git a/lib/widgets/profilerow.dart b/lib/widgets/profilerow.dart index 2ddda6d9..0554373d 100644 --- a/lib/widgets/profilerow.dart +++ b/lib/widgets/profilerow.dart @@ -1,6 +1,7 @@ import 'package:cwtch/models/appstate.dart'; import 'package:cwtch/models/contactlist.dart'; import 'package:cwtch/models/profile.dart'; +import 'package:cwtch/models/profilelist.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:cwtch/views/addeditprofileview.dart'; @@ -83,7 +84,6 @@ class _ProfileRowState extends State { } void _pushContactList(ProfileInfoState profile, bool isLandscape) { - Provider.of(context, listen: false).unreadMessages = 0; Navigator.of(context).push( MaterialPageRoute( settings: RouteSettings(name: "conversations"), From be65417f27cd93e98e18df6886b2237f59c86c5e Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 3 Feb 2022 08:43:29 -0500 Subject: [PATCH 5/6] new plugin generated code --- linux/flutter/generated_plugin_registrant.cc | 4 ++++ linux/flutter/generated_plugins.cmake | 1 + 2 files changed, 5 insertions(+) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index f6f23bfe..51e7cad4 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,9 +7,13 @@ #include "generated_plugin_registrant.h" #include +#include void fl_register_plugins(FlPluginRegistry* registry) { 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); + 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 1fc8ed34..ec48ebfc 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_linux + window_manager ) set(PLUGIN_BUNDLED_LIBRARIES) From 19a202a04c576a19a96961c06c8dc280c9cf5cd8 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 3 Feb 2022 13:58:51 -0800 Subject: [PATCH 6/6] formating, and moving active=true up to be better --- lib/notification_manager.dart | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/lib/notification_manager.dart b/lib/notification_manager.dart index 68f56f3e..91d6ada8 100644 --- a/lib/notification_manager.dart +++ b/lib/notification_manager.dart @@ -31,12 +31,7 @@ class LinuxNotificationsManager implements NotificationsManager { Future notify(String message) async { var iconPath = Uri.file(path.join(path.current, "cwtch.png")); - client - .notify(message, - appName: "cwtch", - appIcon: iconPath.toString(), - replacesId: this.previous_id) - .then((Notification value) => previous_id = value.id); + client.notify(message, appName: "cwtch", appIcon: iconPath.toString(), replacesId: this.previous_id).then((Notification value) => previous_id = value.id); } } @@ -48,20 +43,16 @@ class WindowsNotificationManager implements NotificationsManager { WindowsNotificationManager() { scheduleMicrotask(() async { - initialized = await WinToast.instance().initialize( - appName: 'cwtch', - productName: 'Cwtch', - companyName: 'Open Privacy Research Society'); + initialized = await WinToast.instance().initialize(appName: 'cwtch', productName: 'Cwtch', companyName: 'Open Privacy Research Society'); }); } Future notify(String message) async { if (initialized && !globalAppState.focus) { if (!active) { - WinToast.instance().clear(); - final toast = await WinToast.instance() - .showToast(type: ToastType.text01, title: message); active = true; + WinToast.instance().clear(); + final toast = await WinToast.instance().showToast(type: ToastType.text01, title: message); toast?.eventStream.listen((event) { if (event is ActivatedEvent) { WinToast.instance().bringWindowToFront(); @@ -82,15 +73,13 @@ NotificationsManager newDesktopNotificationsManager() { client.getCapabilities(); return LinuxNotificationsManager(client); } catch (e) { - EnvironmentConfig.debugLog( - "Attempted to access DBUS for notifications but failed. Switching off notifications."); + EnvironmentConfig.debugLog("Attempted to access DBUS for notifications but failed. Switching off notifications."); } } else if (Platform.isWindows) { try { return WindowsNotificationManager(); } catch (e) { - EnvironmentConfig.debugLog( - "Failed to create Windows desktoasts notification manager"); + EnvironmentConfig.debugLog("Failed to create Windows desktoasts notification manager"); } } return NullNotificationsManager();