diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e41ddfb..22709fe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ -# Version 0.2.3 - 2020-01-XX +# Version 0.2.3 - 2020-01-08 ### New features - Added changelog -- Added copy button \ No newline at end of file +- Added copy button +### Fixes +- Groups without name now have a "Group with" prefix diff --git a/lib/components/list_items/chat_list_item.dart b/lib/components/list_items/chat_list_item.dart index 34adfe9d..38c4cef7 100644 --- a/lib/components/list_items/chat_list_item.dart +++ b/lib/components/list_items/chat_list_item.dart @@ -2,6 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/components/message_content.dart'; import 'package:fluffychat/utils/chat_time.dart'; import 'package:fluffychat/utils/app_route.dart'; +import 'package:fluffychat/utils/room_name_calculator.dart'; import 'package:fluffychat/views/chat.dart'; import 'package:flutter/material.dart'; import 'package:toast/toast.dart'; @@ -85,7 +86,7 @@ class ChatListItem extends StatelessWidget { children: [ Expanded( child: Text( - room.displayname, + RoomNameCalculator(room).name, maxLines: 1, overflow: TextOverflow.ellipsis, ), diff --git a/lib/components/matrix.dart b/lib/components/matrix.dart index b70a296a..2fcc4e79 100644 --- a/lib/components/matrix.dart +++ b/lib/components/matrix.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/utils/app_route.dart'; +import 'package:fluffychat/utils/room_name_calculator.dart'; import 'package:fluffychat/utils/sqflite_store.dart'; import 'package:fluffychat/views/chat.dart'; import 'package:flutter/foundation.dart'; @@ -283,7 +284,7 @@ class MatrixState extends State { // The person object for the android message style notification final person = Person( - name: room.displayname, + name: RoomNameCalculator(room).name, icon: room.avatar.mxc.isEmpty ? null : await downloadAndSaveContent( @@ -318,7 +319,7 @@ class MatrixState extends State { var platformChannelSpecifics = NotificationDetails( androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); await _flutterLocalNotificationsPlugin.show( - 0, room.displayname, body, platformChannelSpecifics, + 0, RoomNameCalculator(room).name, body, platformChannelSpecifics, payload: roomId); } catch (exception) { print("[Push] Error while processing notification: " + diff --git a/lib/utils/room_name_calculator.dart b/lib/utils/room_name_calculator.dart new file mode 100644 index 00000000..43b4d5ef --- /dev/null +++ b/lib/utils/room_name_calculator.dart @@ -0,0 +1,16 @@ +import 'package:famedlysdk/famedlysdk.dart'; + +class RoomNameCalculator { + final Room room; + + const RoomNameCalculator(this.room); + + String get name { + if (room.name.isEmpty && + room.canonicalAlias.isEmpty && + !room.isDirectChat) { + return "Group with ${room.displayname}"; + } + return room.displayname; + } +} diff --git a/lib/views/chat.dart b/lib/views/chat.dart index e707b465..992a428c 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -7,6 +7,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/chat_settings_popup_menu.dart'; import 'package:fluffychat/components/list_items/message.dart'; import 'package:fluffychat/components/matrix.dart'; +import 'package:fluffychat/utils/room_name_calculator.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; @@ -183,7 +184,7 @@ class _ChatState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(room.displayname), + Text(RoomNameCalculator(room).name), AnimatedContainer( duration: Duration(milliseconds: 500), height: typingText.isEmpty ? 0 : 20, diff --git a/lib/views/chat_details.dart b/lib/views/chat_details.dart index c729b27f..e8959cc7 100644 --- a/lib/views/chat_details.dart +++ b/lib/views/chat_details.dart @@ -8,6 +8,7 @@ import 'package:fluffychat/components/content_banner.dart'; import 'package:fluffychat/components/list_items/participant_list_item.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/utils/app_route.dart'; +import 'package:fluffychat/utils/room_name_calculator.dart'; import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/invitation_selection.dart'; import 'package:flutter/foundation.dart'; @@ -99,7 +100,7 @@ class _ChatDetailsState extends State { ), secondScaffold: Scaffold( appBar: AppBar( - title: Text(widget.room.displayname), + title: Text(RoomNameCalculator(widget.room).name), actions: [ChatSettingsPopupMenu(widget.room, false)], ), body: ListView.builder( @@ -127,7 +128,8 @@ class _ChatDetailsState extends State { border: InputBorder.none, labelText: "Edit group name", labelStyle: TextStyle(color: Colors.black), - hintText: (widget.room.displayname), + hintText: + (RoomNameCalculator(widget.room).name), ), ), ) diff --git a/pubspec.yaml b/pubspec.yaml index 21619e3c..fdd206f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Chat with your friends. # 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: 0.2.2+12 +version: 0.2.3+13 environment: sdk: ">=2.1.0 <3.0.0"