mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-23 20:49:26 +01:00
Merge branch 'krille/notification-timeline' into 'main'
feat: Display timeline of messages in android notification See merge request famedly/fluffychat!973
This commit is contained in:
commit
06d3a3a4c8
@ -11,6 +11,7 @@ import 'package:fluffychat/config/app_config.dart';
|
|||||||
import 'package:fluffychat/config/setting_keys.dart';
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
import 'package:fluffychat/utils/client_manager.dart';
|
import 'package:fluffychat/utils/client_manager.dart';
|
||||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
||||||
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
|
|
||||||
Future<void> pushHelper(
|
Future<void> pushHelper(
|
||||||
PushNotification notification, {
|
PushNotification notification, {
|
||||||
@ -68,7 +69,7 @@ Future<void> pushHelper(
|
|||||||
final body = await event.calcLocalizedBody(
|
final body = await event.calcLocalizedBody(
|
||||||
matrixLocals,
|
matrixLocals,
|
||||||
plaintextBody: true,
|
plaintextBody: true,
|
||||||
withSenderNamePrefix: !event.room.isDirectChat,
|
withSenderNamePrefix: false,
|
||||||
hideReply: true,
|
hideReply: true,
|
||||||
hideEdit: true,
|
hideEdit: true,
|
||||||
removeMarkdown: true,
|
removeMarkdown: true,
|
||||||
@ -85,28 +86,38 @@ Future<void> pushHelper(
|
|||||||
final avatarFile =
|
final avatarFile =
|
||||||
avatar == null ? null : await DefaultCacheManager().getSingleFile(avatar);
|
avatar == null ? null : await DefaultCacheManager().getSingleFile(avatar);
|
||||||
|
|
||||||
|
final id = await mapRoomIdToInt(event.room.id);
|
||||||
|
|
||||||
// Show notification
|
// Show notification
|
||||||
|
final newMessage = Message(
|
||||||
|
body,
|
||||||
|
event.originServerTs,
|
||||||
|
Person(
|
||||||
|
name: event.senderFromMemoryOrFallback.calcDisplayname(),
|
||||||
|
icon: avatarFile == null
|
||||||
|
? null
|
||||||
|
: BitmapFilePathAndroidIcon(avatarFile.path),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final messagingStyleInformation = PlatformInfos.isAndroid
|
||||||
|
? await AndroidFlutterLocalNotificationsPlugin()
|
||||||
|
.getActiveNotificationMessagingStyle(id)
|
||||||
|
: null;
|
||||||
|
messagingStyleInformation?.messages?.add(newMessage);
|
||||||
|
|
||||||
final androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
final androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
||||||
AppConfig.pushNotificationsChannelId,
|
AppConfig.pushNotificationsChannelId,
|
||||||
AppConfig.pushNotificationsChannelName,
|
AppConfig.pushNotificationsChannelName,
|
||||||
channelDescription: AppConfig.pushNotificationsChannelDescription,
|
channelDescription: AppConfig.pushNotificationsChannelDescription,
|
||||||
styleInformation: MessagingStyleInformation(
|
number: notification.counts?.unread,
|
||||||
Person(name: event.room.client.userID),
|
styleInformation: messagingStyleInformation ??
|
||||||
conversationTitle: event.room.displayname,
|
MessagingStyleInformation(
|
||||||
groupConversation: !event.room.isDirectChat,
|
Person(name: event.room.client.userID),
|
||||||
messages: [
|
conversationTitle: event.room.displayname,
|
||||||
Message(
|
groupConversation: !event.room.isDirectChat,
|
||||||
body,
|
messages: [newMessage],
|
||||||
event.originServerTs,
|
),
|
||||||
Person(
|
|
||||||
name: event.room.displayname,
|
|
||||||
icon: avatarFile == null
|
|
||||||
? null
|
|
||||||
: BitmapFilePathAndroidIcon(avatarFile.path),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
ticker: l10n.unreadChats(notification.counts?.unread ?? 1),
|
ticker: l10n.unreadChats(notification.counts?.unread ?? 1),
|
||||||
importance: Importance.max,
|
importance: Importance.max,
|
||||||
priority: Priority.high,
|
priority: Priority.high,
|
||||||
@ -117,8 +128,9 @@ Future<void> pushHelper(
|
|||||||
android: androidPlatformChannelSpecifics,
|
android: androidPlatformChannelSpecifics,
|
||||||
iOS: iOSPlatformChannelSpecifics,
|
iOS: iOSPlatformChannelSpecifics,
|
||||||
);
|
);
|
||||||
|
|
||||||
await _flutterLocalNotificationsPlugin.show(
|
await _flutterLocalNotificationsPlugin.show(
|
||||||
await mapRoomIdToInt(event.room.id),
|
id,
|
||||||
event.room.displayname,
|
event.room.displayname,
|
||||||
body,
|
body,
|
||||||
platformChannelSpecifics,
|
platformChannelSpecifics,
|
||||||
|
@ -572,14 +572,14 @@ packages:
|
|||||||
name: flutter_local_notifications
|
name: flutter_local_notifications
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.4.1"
|
version: "9.7.0"
|
||||||
flutter_local_notifications_linux:
|
flutter_local_notifications_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_local_notifications_linux
|
name: flutter_local_notifications_linux
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.2"
|
version: "0.5.0+1"
|
||||||
flutter_local_notifications_platform_interface:
|
flutter_local_notifications_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -35,7 +35,7 @@ dependencies:
|
|||||||
flutter_app_lock: ^2.0.0
|
flutter_app_lock: ^2.0.0
|
||||||
flutter_blurhash: ^0.7.0
|
flutter_blurhash: ^0.7.0
|
||||||
flutter_cache_manager: ^3.3.0
|
flutter_cache_manager: ^3.3.0
|
||||||
flutter_local_notifications: ^9.4.0
|
flutter_local_notifications: ^9.7.0
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_map: ^1.1.0
|
flutter_map: ^1.1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user