diff --git a/lib/pages/archive/archive.dart b/lib/pages/archive/archive.dart index be1a975c..823fe836 100644 --- a/lib/pages/archive/archive.dart +++ b/lib/pages/archive/archive.dart @@ -42,7 +42,7 @@ class ArchiveController extends State { context: context, future: () async { while (archive.isNotEmpty) { - Logs().v('Forget room ${archive.last.displayname}'); + Logs().v('Forget room ${archive.last.getLocalizedDisplayname()}'); await archive.last.forget(); archive.removeLast(); } diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index f5107580..69265d29 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -134,15 +134,6 @@ class ChatController extends State { bool showEmojiPicker = false; - bool get isLeftDMRoom { - final room = this.room; - final userId = room?.directChatMatrixID; - if (room == null || userId == null) return false; - return room.isDirectChat && - room.unsafeGetUserFromMemoryOrFallback(userId).membership == - Membership.leave; - } - void recreateChat() async { final room = this.room; final userId = room?.directChatMatrixID; diff --git a/lib/pages/chat/chat_app_bar_title.dart b/lib/pages/chat/chat_app_bar_title.dart index 7dffe860..cffe7411 100644 --- a/lib/pages/chat/chat_app_bar_title.dart +++ b/lib/pages/chat/chat_app_bar_title.dart @@ -47,7 +47,9 @@ class ChatAppBarTitle extends StatelessWidget { tag: 'content_banner', child: Avatar( mxContent: room.avatar, - name: room.displayname, + name: room.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ), size: 32, ), ), diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index dd6faf18..8e6f0601 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -291,7 +291,8 @@ class ChatView extends StatelessWidget { Brightness.light ? Colors.white : Colors.black, - child: controller.isLeftDMRoom + child: controller.room?.isAbandonedDMRoom == + true ? Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 555fdbe6..7591aea2 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -196,7 +196,7 @@ class InputBar extends StatelessWidget { ret.add({ 'type': 'room', 'mxid': (r.canonicalAlias.isNotEmpty) ? r.canonicalAlias : r.id, - 'displayname': r.displayname, + 'displayname': r.getLocalizedDisplayname(), 'avatar_url': r.avatar?.toString(), }); } diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 44a7dd6f..b452a161 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -18,6 +18,7 @@ import 'package:fluffychat/pages/chat_list/chat_list_view.dart'; import 'package:fluffychat/utils/famedlysdk_store.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import '../../../utils/account_bundles.dart'; import '../../utils/matrix_sdk_extensions/matrix_file_extension.dart'; @@ -508,7 +509,8 @@ class ChatListController extends State .map( (space) => AlertDialogAction( key: space.id, - label: space.displayname, + label: space + .getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)), ), ) .toList()); diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index 6e1e2aaf..d7a09d9d 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -11,6 +11,7 @@ import 'package:fluffychat/pages/chat_list/space_view.dart'; import 'package:fluffychat/pages/chat_list/stories_header.dart'; import 'package:fluffychat/utils/adaptive_bottom_sheet.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/stream_extension.dart'; import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/profile_bottom_sheet.dart'; @@ -205,8 +206,11 @@ class ChatListViewBody extends StatelessWidget { ); } i--; - if (!rooms[i].displayname.toLowerCase().contains( - controller.searchController.text.toLowerCase())) { + if (!rooms[i] + .getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)) + .toLowerCase() + .contains( + controller.searchController.text.toLowerCase())) { return Container(); } return ChatListItem( diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index fd62cef7..86f0e61c 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -124,6 +124,9 @@ class ChatListItem extends StatelessWidget { ? 20.0 : 14.0 : 0.0; + final displayname = room.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ); return Material( color: selected ? Theme.of(context).colorScheme.primaryContainer @@ -144,14 +147,14 @@ class ChatListItem extends StatelessWidget { ) : Avatar( mxContent: room.avatar, - name: room.displayname, + name: displayname, onTap: onLongPress, ), title: Row( children: [ Expanded( child: Text( - room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)), + displayname, maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: false, diff --git a/lib/pages/chat_list/chat_list_view.dart b/lib/pages/chat_list/chat_list_view.dart index f86ca2b0..6bd24a49 100644 --- a/lib/pages/chat_list/chat_list_view.dart +++ b/lib/pages/chat_list/chat_list_view.dart @@ -10,6 +10,7 @@ import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/pages/chat_list/chat_list.dart'; import 'package:fluffychat/pages/chat_list/navi_rail_item.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/unread_rooms_badge.dart'; import '../../widgets/matrix.dart'; @@ -140,13 +141,16 @@ class ChatListView extends StatelessWidget { controller.activeFilter == ActiveFilter.spaces && rootSpaces[i].id == controller.activeSpaceId; return NaviRailItem( - toolTip: rootSpaces[i].displayname, + toolTip: rootSpaces[i].getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!)), isSelected: isSelected, onTap: () => controller.setActiveSpace(rootSpaces[i].id), icon: Avatar( mxContent: rootSpaces[i].avatar, - name: rootSpaces[i].displayname, + name: rootSpaces[i].getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ), size: 32, fontSize: 12, ), diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 3885503a..3ca6ba45 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -10,6 +10,7 @@ import 'package:vrouter/vrouter.dart'; import 'package:fluffychat/pages/chat_list/chat_list.dart'; import 'package:fluffychat/pages/chat_list/chat_list_item.dart'; import 'package:fluffychat/pages/chat_list/search_title.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/widgets/avatar.dart'; import '../../utils/localized_exception_extension.dart'; import '../../widgets/matrix.dart'; @@ -85,7 +86,10 @@ class _SpaceViewState extends State { activeSpaceId == null ? null : client.getRoomById(activeSpaceId); final action = await showModalActionSheet( context: context, - title: spaceChild?.name ?? room?.displayname, + title: spaceChild?.name ?? + room?.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ), message: spaceChild?.topic ?? room?.topic, actions: [ if (room == null) @@ -148,25 +152,31 @@ class _SpaceViewState extends State { return ListView.builder( itemCount: rootSpaces.length, controller: widget.scrollController, - itemBuilder: (context, i) => Material( - color: Theme.of(context).backgroundColor, - child: ListTile( - leading: Avatar( - mxContent: rootSpaces[i].avatar, - name: rootSpaces[i].displayname, + itemBuilder: (context, i) { + final rootSpace = rootSpaces[i]; + final displayname = rootSpace.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ); + return Material( + color: Theme.of(context).backgroundColor, + child: ListTile( + leading: Avatar( + mxContent: rootSpace.avatar, + name: displayname, + ), + title: Text( + displayname, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + subtitle: Text(L10n.of(context)! + .numChats(rootSpace.spaceChildren.length.toString())), + onTap: () => widget.controller.setActiveSpace(rootSpace.id), + onLongPress: () => _onSpaceChildContextMenu(null, rootSpace), + trailing: const Icon(Icons.chevron_right_outlined), ), - title: Text( - rootSpaces[i].displayname, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - subtitle: Text(L10n.of(context)! - .numChats(rootSpaces[i].spaceChildren.length.toString())), - onTap: () => widget.controller.setActiveSpace(rootSpaces[i].id), - onLongPress: () => _onSpaceChildContextMenu(null, rootSpaces[i]), - trailing: const Icon(Icons.chevron_right_outlined), - ), - ), + ); + }, ); } return FutureBuilder( @@ -218,7 +228,9 @@ class _SpaceViewState extends State { ), title: Text(parentSpace == null ? L10n.of(context)!.allSpaces - : parentSpace.displayname), + : parentSpace.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + )), trailing: IconButton( icon: snapshot.connectionState != ConnectionState.done ? const CircularProgressIndicator.adaptive() diff --git a/lib/pages/dialer/dialer.dart b/lib/pages/dialer/dialer.dart index e612b56e..6c11aecf 100644 --- a/lib/pages/dialer/dialer.dart +++ b/lib/pages/dialer/dialer.dart @@ -30,6 +30,7 @@ import 'package:matrix/matrix.dart'; import 'package:vibration/vibration.dart'; import 'package:wakelock/wakelock.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/widgets/avatar.dart'; import 'pip/pip_view.dart'; @@ -129,7 +130,9 @@ class Calling extends StatefulWidget { class MyCallingPage extends State { Room? get room => call.room; - String get displayName => call.displayName ?? ''; + String get displayName => call.room.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ); String get callId => widget.callId; @@ -464,7 +467,9 @@ class MyCallingPage extends State { if (call.localHold || call.remoteOnHold) { var title = ''; if (call.localHold) { - title = '${call.displayName} held the call.'; + title = '${call.room.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + )} held the call.'; } else if (call.remoteOnHold) { title = 'You held the call.'; } diff --git a/lib/pages/invitation_selection/invitation_selection.dart b/lib/pages/invitation_selection/invitation_selection.dart index cba0dd8f..ab10628b 100644 --- a/lib/pages/invitation_selection/invitation_selection.dart +++ b/lib/pages/invitation_selection/invitation_selection.dart @@ -9,6 +9,7 @@ import 'package:matrix/matrix.dart'; import 'package:vrouter/vrouter.dart'; import 'package:fluffychat/pages/invitation_selection/invitation_selection_view.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/widgets/matrix.dart'; import '../../utils/localized_exception_extension.dart'; @@ -55,7 +56,11 @@ class InvitationSelectionController extends State { if (OkCancelResult.ok != await showOkCancelAlertDialog( context: context, - title: L10n.of(context)!.inviteContactToGroup(room.displayname), + title: L10n.of(context)!.inviteContactToGroup( + room.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ), + ), okLabel: L10n.of(context)!.yes, cancelLabel: L10n.of(context)!.cancel, )) { diff --git a/lib/utils/matrix_sdk_extensions/client_stories_extension.dart b/lib/utils/matrix_sdk_extensions/client_stories_extension.dart index eff87f23..281ab323 100644 --- a/lib/utils/matrix_sdk_extensions/client_stories_extension.dart +++ b/lib/utils/matrix_sdk_extensions/client_stories_extension.dart @@ -1,8 +1,11 @@ import 'package:flutter/cupertino.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; + extension ClientStoriesExtension on Client { static const String storiesRoomType = 'msc3588.stories.stories-room'; static const String storiesBlockListType = 'msc3588.stories.block-list'; @@ -85,7 +88,11 @@ extension ClientStoriesExtension on Client { context: context, actions: candidates .map( - (room) => SheetAction(label: room.displayname, key: room), + (room) => SheetAction( + label: room.getLocalizedDisplayname( + MatrixLocals(L10n.of(context)!), + ), + key: room), ) .toList()); } diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 018c9de3..242576f4 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -200,7 +200,9 @@ Future _tryPushHelper( styleInformation: messagingStyleInformation ?? MessagingStyleInformation( Person(name: event.room.client.userID), - conversationTitle: event.room.displayname, + conversationTitle: event.room.getLocalizedDisplayname( + MatrixLocals(l10n), + ), groupConversation: !event.room.isDirectChat, messages: [newMessage], ), @@ -217,7 +219,9 @@ Future _tryPushHelper( await flutterLocalNotificationsPlugin.show( id, - event.room.displayname, + event.room.getLocalizedDisplayname( + MatrixLocals(l10n), + ), body, platformChannelSpecifics, payload: event.roomId, diff --git a/lib/utils/voip/callkeep_manager.dart b/lib/utils/voip/callkeep_manager.dart index 5041725c..6df4a81d 100644 --- a/lib/utils/voip/callkeep_manager.dart +++ b/lib/utils/voip/callkeep_manager.dart @@ -222,8 +222,9 @@ class CallKeepManager { addCall(call.callId, callKeeper); await _callKeep.displayIncomingCall( call.callId, - '${call.displayName!} (FluffyChat)', - localizedCallerName: '${call.displayName!} (FluffyChat)', + '${call.room.getLocalizedDisplayname()} (FluffyChat)', + localizedCallerName: + '${call.room.getLocalizedDisplayname()} (FluffyChat)', handleType: 'number', hasVideo: call.type == CallType.kVideo, ); diff --git a/pubspec.lock b/pubspec.lock index d15884e6..e853ffdb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -944,7 +944,7 @@ packages: name: matrix url: "https://pub.dartlang.org" source: hosted - version: "0.15.11" + version: "0.15.12" matrix_api_lite: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ea4db187..c9b7a8cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,7 +58,7 @@ dependencies: just_audio_mpv: ^0.1.6 keyboard_shortcuts: ^0.1.4 latlong2: ^0.8.1 - matrix: ^0.15.11 + matrix: ^0.15.12 matrix_homeserver_recommendations: ^0.3.0 matrix_link_text: ^1.0.2 native_imaging: ^0.1.0