From 1bef2dcbbbd353a9059b64963d9fab87521e828b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ku=C3=9Fowski?= Date: Tue, 7 Oct 2025 10:51:04 +0200 Subject: [PATCH] chore: Follow up notification action --- .../notification_background_handler.dart | 26 +++++++++++++++++-- lib/utils/push_helper.dart | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/utils/notification_background_handler.dart b/lib/utils/notification_background_handler.dart index 972121443..d3e756735 100644 --- a/lib/utils/notification_background_handler.dart +++ b/lib/utils/notification_background_handler.dart @@ -9,6 +9,7 @@ import 'package:matrix/matrix.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:fluffychat/l10n/l10n.dart'; +import 'package:fluffychat/utils/client_download_content_extension.dart'; import 'package:fluffychat/utils/client_manager.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -157,16 +158,37 @@ Future notificationTap( final eventId = await room.sendTextEvent(input); if (PlatformInfos.isAndroid) { + final ownProfile = await room.client.fetchOwnProfile(); + final avatar = ownProfile.avatarUrl; + final avatarFile = avatar == null + ? null + : await client + .downloadMxcCached( + avatar, + thumbnailMethod: ThumbnailMethod.crop, + width: notificationAvatarDimension, + height: notificationAvatarDimension, + animated: false, + isThumbnail: true, + rounded: true, + ) + .timeout(const Duration(seconds: 3)); final messagingStyleInformation = await AndroidFlutterLocalNotificationsPlugin() .getActiveNotificationMessagingStyle(room.id.hashCode); if (messagingStyleInformation == null) return; - l10n ??= await lookupL10n(const Locale('en')); + l10n ??= await lookupL10n(PlatformDispatcher.instance.locale); messagingStyleInformation.messages?.add( Message( input, DateTime.now(), - Person(key: room.client.userID, name: l10n.you), + Person( + key: room.client.userID, + name: l10n.you, + icon: avatarFile == null + ? null + : ByteArrayAndroidIcon(avatarFile), + ), ), ); diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 7c2d1c15c..6d75d568c 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -38,7 +38,7 @@ Future pushHelper( } catch (e, s) { Logs().e('Push Helper has crashed! Writing into temporary file', e, s); - l10n ??= await lookupL10n(const Locale('en')); + l10n ??= await lookupL10n(PlatformDispatcher.instance.locale); flutterLocalNotificationsPlugin.show( notification.roomId?.hashCode ?? 0, l10n.newMessageInFluffyChat,