|
|
|
@ -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<void> 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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|