From 02407c5abe19fdae6dd1e0007e2ef985f3204c61 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 14 Feb 2022 11:00:46 -0800 Subject: [PATCH 1/4] Fix #371 Fix #368 Fix #16 --- lib/cwtch/gomobile.dart | 2 +- lib/views/globalsettingsview.dart | 12 ++++++++---- lib/views/messageview.dart | 7 +++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index 07501e17..91a08cec 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -196,7 +196,7 @@ class CwtchGomobile implements Cwtch { @override // ignore: non_constant_identifier_names void DeleteContact(String profileOnion, int conversation) { - cwtchPlatform.invokeMethod("DeleteContact", {"ProfileOnion": profileOnion, "conversation": conversation}); + cwtchPlatform.invokeMethod("DeleteConversation", {"ProfileOnion": profileOnion, "conversation": conversation}); } @override diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 3d14065e..66e74c63 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -137,7 +137,9 @@ class _GlobalSettingsViewState extends State { style: TextStyle(color: settings.current().mainTextColor), ), leading: Icon(Icons.table_chart, color: settings.current().mainTextColor), - trailing: DropdownButton( + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( value: settings.uiColumnModeLandscape.toString(), onChanged: (String? newValue) { settings.uiColumnModeLandscape = Settings.uiColumnModeFromString(newValue!); @@ -151,7 +153,7 @@ class _GlobalSettingsViewState extends State { overflow: TextOverflow.ellipsis, ), ); - }).toList())), + }).toList()))), SwitchListTile( title: Text(AppLocalizations.of(context)!.streamerModeLabel, style: TextStyle(color: settings.current().mainTextColor)), subtitle: Text(AppLocalizations.of(context)!.descriptionStreamerMode), @@ -192,7 +194,9 @@ class _GlobalSettingsViewState extends State { ListTile( title: Text(AppLocalizations.of(context)!.notificationContentSettingLabel), subtitle: Text(AppLocalizations.of(context)!.notificationContentSettingDescription), - trailing: DropdownButton( + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child:DropdownButton( value: settings.notificationContent, onChanged: (NotificationContent? newValue) { settings.notificationContent = newValue!; @@ -206,7 +210,7 @@ class _GlobalSettingsViewState extends State { overflow: TextOverflow.ellipsis, ), ); - }).toList()), + }).toList())), leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor), ), SwitchListTile( diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index d82f2e35..2a490567 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -197,6 +197,11 @@ class _MessageViewState extends State { static const GroupMessageLengthMax = 1600; void _sendMessage([String? ignoredParam]) { + + // Trim message + final messageWithoutNewLine = ctrlrCompose.value.text.trimRight(); + ctrlrCompose.value = TextEditingValue(text: messageWithoutNewLine); + var isGroup = Provider.of(context, listen: false).contactList.getContact(Provider.of(context, listen: false).selectedConversation!)!.isGroup; // peers and groups currently have different length constraints (servers can store less)... @@ -375,8 +380,6 @@ class _MessageViewState extends State { void handleKeyPress(event) { var data = event.data as RawKeyEventData; if (data.logicalKey == LogicalKeyboardKey.enter && !event.isShiftPressed) { - final messageWithoutNewLine = ctrlrCompose.value.text.trimRight(); - ctrlrCompose.value = TextEditingValue(text: messageWithoutNewLine); _sendMessage(); } } From a0f8be2d53c3f61f8fd5f774ff28c81aeedb42b4 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 14 Feb 2022 11:02:19 -0800 Subject: [PATCH 2/4] Bump Android Version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5c0d3327..706c652d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.6.0+25 +version: 1.6.1+26 environment: sdk: ">=2.15.0 <3.0.0" From 7bf2e15009aa7200518fd7aa2b434306889821fc Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 14 Feb 2022 11:03:28 -0800 Subject: [PATCH 3/4] Formatting --- lib/models/contact.dart | 1 - lib/settings.dart | 15 +++++--- lib/views/globalsettingsview.dart | 62 +++++++++++++++---------------- lib/views/messageview.dart | 1 - lib/views/splashView.dart | 2 +- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/lib/models/contact.dart b/lib/models/contact.dart index 04c97a5c..81669a8c 100644 --- a/lib/models/contact.dart +++ b/lib/models/contact.dart @@ -2,7 +2,6 @@ import 'package:cwtch/widgets/messagerow.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; - import 'message.dart'; import 'messagecache.dart'; diff --git a/lib/settings.dart b/lib/settings.dart index 2462cbb3..3b9a80cd 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -296,16 +296,21 @@ class Settings extends ChangeNotifier { static String notificationPolicyToString(NotificationPolicy np, BuildContext context) { switch (np) { - case NotificationPolicy.Mute: return AppLocalizations.of(context)!.notificationPolicyMute; - case NotificationPolicy.OptIn: return AppLocalizations.of(context)!.notificationPolicyOptIn; - case NotificationPolicy.DefaultAll: return AppLocalizations.of(context)!.notificationPolicyDefaultAll; + case NotificationPolicy.Mute: + return AppLocalizations.of(context)!.notificationPolicyMute; + case NotificationPolicy.OptIn: + return AppLocalizations.of(context)!.notificationPolicyOptIn; + case NotificationPolicy.DefaultAll: + return AppLocalizations.of(context)!.notificationPolicyDefaultAll; } } static String notificationContentToString(NotificationContent nc, BuildContext context) { switch (nc) { - case NotificationContent.SimpleEvent: return AppLocalizations.of(context)!.notificationContentSimpleEvent; - case NotificationContent.ContactInfo: return AppLocalizations.of(context)!.notificationContentContactInfo; + case NotificationContent.SimpleEvent: + return AppLocalizations.of(context)!.notificationContentSimpleEvent; + case NotificationContent.ContactInfo: + return AppLocalizations.of(context)!.notificationContentContactInfo; } } diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 66e74c63..f7d040bd 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -138,22 +138,22 @@ class _GlobalSettingsViewState extends State { ), leading: Icon(Icons.table_chart, color: settings.current().mainTextColor), trailing: Container( - width: MediaQuery.of(context).size.width / 4, + width: MediaQuery.of(context).size.width / 4, child: DropdownButton( - value: settings.uiColumnModeLandscape.toString(), - onChanged: (String? newValue) { - settings.uiColumnModeLandscape = Settings.uiColumnModeFromString(newValue!); - saveSettings(context); - }, - items: Settings.uiColumnModeOptions(true).map>((DualpaneMode value) { - return DropdownMenuItem( - value: value.toString(), - child: Text( - Settings.uiColumnModeToString(value, context), - overflow: TextOverflow.ellipsis, - ), - ); - }).toList()))), + value: settings.uiColumnModeLandscape.toString(), + onChanged: (String? newValue) { + settings.uiColumnModeLandscape = Settings.uiColumnModeFromString(newValue!); + saveSettings(context); + }, + items: Settings.uiColumnModeOptions(true).map>((DualpaneMode value) { + return DropdownMenuItem( + value: value.toString(), + child: Text( + Settings.uiColumnModeToString(value, context), + overflow: TextOverflow.ellipsis, + ), + ); + }).toList()))), SwitchListTile( title: Text(AppLocalizations.of(context)!.streamerModeLabel, style: TextStyle(color: settings.current().mainTextColor)), subtitle: Text(AppLocalizations.of(context)!.descriptionStreamerMode), @@ -195,22 +195,22 @@ class _GlobalSettingsViewState extends State { title: Text(AppLocalizations.of(context)!.notificationContentSettingLabel), subtitle: Text(AppLocalizations.of(context)!.notificationContentSettingDescription), trailing: Container( - width: MediaQuery.of(context).size.width / 4, - child:DropdownButton( - value: settings.notificationContent, - onChanged: (NotificationContent? newValue) { - settings.notificationContent = newValue!; - saveSettings(context); - }, - items: NotificationContent.values.map>((NotificationContent value) { - return DropdownMenuItem( - value: value, - child: Text( - Settings.notificationContentToString(value, context), - overflow: TextOverflow.ellipsis, - ), - ); - }).toList())), + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( + value: settings.notificationContent, + onChanged: (NotificationContent? newValue) { + settings.notificationContent = newValue!; + saveSettings(context); + }, + items: NotificationContent.values.map>((NotificationContent value) { + return DropdownMenuItem( + value: value, + child: Text( + Settings.notificationContentToString(value, context), + overflow: TextOverflow.ellipsis, + ), + ); + }).toList())), leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor), ), SwitchListTile( diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index 2a490567..e6b6789d 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -197,7 +197,6 @@ class _MessageViewState extends State { static const GroupMessageLengthMax = 1600; void _sendMessage([String? ignoredParam]) { - // Trim message final messageWithoutNewLine = ctrlrCompose.value.text.trimRight(); ctrlrCompose.value = TextEditingValue(text: messageWithoutNewLine); diff --git a/lib/views/splashView.dart b/lib/views/splashView.dart index 47b504ed..1beedc8d 100644 --- a/lib/views/splashView.dart +++ b/lib/views/splashView.dart @@ -17,7 +17,7 @@ class _SplashViewState extends State { Widget build(BuildContext context) { var cwtch = Provider.of(context, listen: false).cwtch; if (!cwtch.isL10nInit()) { - if (AppLocalizations.of(context) != null && AppLocalizations.of(context)!.newMessageNotificationSimple.isNotEmpty ) { + if (AppLocalizations.of(context) != null && AppLocalizations.of(context)!.newMessageNotificationSimple.isNotEmpty) { cwtch.l10nInit(AppLocalizations.of(context)!.newMessageNotificationSimple, AppLocalizations.of(context)!.newMessageNotificationConversationInfo); } } From dab09c6acb9c7ed15c8ad1256a8e71318b2de8da Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 14 Feb 2022 12:20:25 -0800 Subject: [PATCH 4/4] Fix #314 - Numpad enter should send message --- lib/views/messageview.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index e6b6789d..ecdc6527 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -376,9 +376,9 @@ class _MessageViewState extends State { } // Send the message if enter is pressed without the shift key... - void handleKeyPress(event) { - var data = event.data as RawKeyEventData; - if (data.logicalKey == LogicalKeyboardKey.enter && !event.isShiftPressed) { + void handleKeyPress(RawKeyEvent event) { + var data = event.data; + if ((data.logicalKey == LogicalKeyboardKey.enter && !event.isShiftPressed) || data.logicalKey == LogicalKeyboardKey.numpadEnter && !event.isShiftPressed) { _sendMessage(); } }