Summarize location, image and GIF messages in notifications
Notification bodies now use the chat's parsers to show a localized summary for shared locations (m: markers), channel images, GIFs and reactions instead of the raw payload. The marker parser moves out of the map screen into helpers/marker_message.dart so the service can use it.
This commit is contained in:
1 parent
ed5884e252
commit
caf20b4415
28 files changed
+575
-36
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
class MarkerPayload {
|
||||
final LatLng position;
|
||||
final String label;
|
||||
final String flags;
|
||||
|
||||
MarkerPayload({
|
||||
required this.position,
|
||||
required this.label,
|
||||
required this.flags,
|
||||
});
|
||||
}
|
||||
|
||||
/// Parse a shared marker text message of the form
|
||||
/// `m:<lat>,<lon>|<label>|<flags>` and return a [MarkerPayload].
|
||||
MarkerPayload? parseMarkerText(String text) {
|
||||
final trimmed = text.trim();
|
||||
final match = RegExp(
|
||||
r'm:([\-0-9.]+),([\-0-9.]+)\|([^|]*)\|(.*)',
|
||||
).firstMatch(trimmed);
|
||||
if (match == null) return null;
|
||||
final lat = double.tryParse(match.group(1) ?? '');
|
||||
final lon = double.tryParse(match.group(2) ?? '');
|
||||
if (lat == null || lon == null) return null;
|
||||
if (lat.abs() > 90 || lon.abs() > 180) return null;
|
||||
final label = (match.group(3) ?? '').trim();
|
||||
final flags = (match.group(4) ?? '').trim();
|
||||
return MarkerPayload(position: LatLng(lat, lon), label: label, flags: flags);
|
||||
}
|
||||
@@ -2711,6 +2711,25 @@
|
||||
}
|
||||
},
|
||||
"notification_receivedNewMessage": "Received new message",
|
||||
"notification_sharedLocation": "Shared a location",
|
||||
"notification_sharedLocationNamed": "Shared a location: {label}",
|
||||
"@notification_sharedLocationNamed": {
|
||||
"placeholders": {
|
||||
"label": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"notification_reacted": "Reacted {emoji}",
|
||||
"@notification_reacted": {
|
||||
"placeholders": {
|
||||
"emoji": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"notification_sentGif": "Sent a GIF",
|
||||
"notification_sentImage": "Sent an image",
|
||||
"notification_actionReply": "Reply",
|
||||
"notification_actionMarkRead": "Mark as read",
|
||||
"notification_actionMuteChannel": "Mute channel",
|
||||
|
||||
@@ -8138,6 +8138,36 @@ abstract class AppLocalizations {
|
||||
/// **'Received new message'**
|
||||
String get notification_receivedNewMessage;
|
||||
|
||||
/// No description provided for @notification_sharedLocation.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Shared a location'**
|
||||
String get notification_sharedLocation;
|
||||
|
||||
/// No description provided for @notification_sharedLocationNamed.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Shared a location: {label}'**
|
||||
String notification_sharedLocationNamed(String label);
|
||||
|
||||
/// No description provided for @notification_reacted.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Reacted {emoji}'**
|
||||
String notification_reacted(String emoji);
|
||||
|
||||
/// No description provided for @notification_sentGif.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Sent a GIF'**
|
||||
String get notification_sentGif;
|
||||
|
||||
/// No description provided for @notification_sentImage.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Sent an image'**
|
||||
String get notification_sentImage;
|
||||
|
||||
/// No description provided for @notification_actionReply.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -4768,6 +4768,25 @@ class AppLocalizationsBg extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Получено ново съобщение';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Отговори';
|
||||
|
||||
|
||||
@@ -4779,6 +4779,25 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Neue Nachricht empfangen';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Antworten';
|
||||
|
||||
|
||||
@@ -4703,6 +4703,25 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Received new message';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Reply';
|
||||
|
||||
|
||||
@@ -4770,6 +4770,25 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Nuevo mensaje recibido';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Responder';
|
||||
|
||||
|
||||
@@ -4789,6 +4789,25 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Nouveau message reçu';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Répondre';
|
||||
|
||||
|
||||
@@ -4767,6 +4767,25 @@ class AppLocalizationsHu extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Új üzenet érkezett';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Válasz';
|
||||
|
||||
|
||||
@@ -4776,6 +4776,25 @@ class AppLocalizationsIt extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Nuovo messaggio ricevuto';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Rispondi';
|
||||
|
||||
|
||||
@@ -4539,6 +4539,25 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => '新しいメッセージを受信';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => '返信';
|
||||
|
||||
|
||||
@@ -4550,6 +4550,25 @@ class AppLocalizationsKo extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => '새로운 메시지를 받았습니다';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => '답장';
|
||||
|
||||
|
||||
@@ -4745,6 +4745,25 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Nieuw bericht ontvangen';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Reageren';
|
||||
|
||||
|
||||
@@ -4802,6 +4802,25 @@ class AppLocalizationsPl extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Otrzymano nową wiadomość';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Odpowiedz';
|
||||
|
||||
|
||||
@@ -4772,6 +4772,25 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Nova mensagem recebida';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Responder';
|
||||
|
||||
|
||||
@@ -4786,6 +4786,25 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Получено новое сообщение';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Ответить';
|
||||
|
||||
|
||||
@@ -4756,6 +4756,25 @@ class AppLocalizationsSk extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Prijatá nová správa';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Odpovedať';
|
||||
|
||||
|
||||
@@ -4757,6 +4757,25 @@ class AppLocalizationsSl extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Prejeto novo sporočilo';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Odgovori';
|
||||
|
||||
|
||||
@@ -4727,6 +4727,25 @@ class AppLocalizationsSv extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Nytt meddelande mottaget';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Svara';
|
||||
|
||||
|
||||
@@ -4785,6 +4785,25 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => 'Отримано нове повідомлення';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => 'Відповісти';
|
||||
|
||||
|
||||
@@ -4429,6 +4429,25 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
@override
|
||||
String get notification_receivedNewMessage => '收到新消息';
|
||||
|
||||
@override
|
||||
String get notification_sharedLocation => 'Shared a location';
|
||||
|
||||
@override
|
||||
String notification_sharedLocationNamed(String label) {
|
||||
return 'Shared a location: $label';
|
||||
}
|
||||
|
||||
@override
|
||||
String notification_reacted(String emoji) {
|
||||
return 'Reacted $emoji';
|
||||
}
|
||||
|
||||
@override
|
||||
String get notification_sentGif => 'Sent a GIF';
|
||||
|
||||
@override
|
||||
String get notification_sentImage => 'Sent an image';
|
||||
|
||||
@override
|
||||
String get notification_actionReply => '回复';
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import '../helpers/chat_scroll_controller.dart';
|
||||
import '../connector/meshcore_protocol.dart';
|
||||
import '../helpers/cyr2lat.dart';
|
||||
import '../helpers/gif_helper.dart';
|
||||
import '../helpers/marker_message.dart';
|
||||
import '../helpers/message_url_image_helper.dart';
|
||||
import '../helpers/path_helper.dart';
|
||||
import '../helpers/reaction_helper.dart';
|
||||
|
||||
@@ -20,6 +20,7 @@ import '../widgets/message_status_icon.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
import '../helpers/chat_scroll_controller.dart';
|
||||
import '../helpers/gif_helper.dart';
|
||||
import '../helpers/marker_message.dart';
|
||||
import '../models/channel_message.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../l10n/contact_localization.dart';
|
||||
|
||||
@@ -45,6 +45,7 @@ import '../widgets/repeater_login_dialog.dart';
|
||||
import '../widgets/room_login_dialog.dart';
|
||||
import '../widgets/set_my_location_dialog.dart';
|
||||
import '../helpers/guessed_location_estimator.dart';
|
||||
import '../helpers/marker_message.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../helpers/utf8_length_limiter.dart';
|
||||
import 'repeater_hub_screen.dart';
|
||||
@@ -4369,35 +4370,6 @@ class _GuessedLocation {
|
||||
});
|
||||
}
|
||||
|
||||
class MarkerPayload {
|
||||
final LatLng position;
|
||||
final String label;
|
||||
final String flags;
|
||||
|
||||
MarkerPayload({
|
||||
required this.position,
|
||||
required this.label,
|
||||
required this.flags,
|
||||
});
|
||||
}
|
||||
|
||||
/// Parse a shared marker text message of the form
|
||||
/// `m:<lat>,<lon>|<label>|<flags>` and return a [MarkerPayload].
|
||||
MarkerPayload? parseMarkerText(String text) {
|
||||
final trimmed = text.trim();
|
||||
final match = RegExp(
|
||||
r'm:([\-0-9.]+),([\-0-9.]+)\|([^|]*)\|(.*)',
|
||||
).firstMatch(trimmed);
|
||||
if (match == null) return null;
|
||||
final lat = double.tryParse(match.group(1) ?? '');
|
||||
final lon = double.tryParse(match.group(2) ?? '');
|
||||
if (lat == null || lon == null) return null;
|
||||
if (lat.abs() > 90 || lon.abs() > 180) return null;
|
||||
final label = (match.group(3) ?? '').trim();
|
||||
final flags = (match.group(4) ?? '').trim();
|
||||
return MarkerPayload(position: LatLng(lat, lon), label: label, flags: flags);
|
||||
}
|
||||
|
||||
/// Build a normalized dedupe key for shared markers.
|
||||
/// Keeps the same algorithm previously present in both chat and map screens.
|
||||
String buildSharedMarkerKey({
|
||||
|
||||
@@ -8,12 +8,15 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
|
||||
import '../helpers/gif_helper.dart';
|
||||
import '../helpers/marker_message.dart';
|
||||
import '../helpers/message_url_image_helper.dart';
|
||||
import '../helpers/reaction_helper.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../storage/prefs_manager.dart';
|
||||
import '../utils/platform_info.dart';
|
||||
import 'notification_reply.dart';
|
||||
import 'received_image_store.dart' show ReceivedImageRef;
|
||||
|
||||
class NotificationService {
|
||||
static final NotificationService _instance = NotificationService._internal();
|
||||
@@ -278,15 +281,26 @@ class NotificationService {
|
||||
await requestPermissions();
|
||||
}
|
||||
|
||||
/// Format special message types for human-readable notifications.
|
||||
static String formatNotificationText(String text) {
|
||||
/// Summarizes structured payloads (reactions, images, GIFs, shared
|
||||
/// locations) with the same parsers the chat bubbles use; other text is
|
||||
/// returned unchanged.
|
||||
static String formatNotificationText(String text, AppLocalizations l10n) {
|
||||
final trimmed = text.trim();
|
||||
final reaction = ReactionHelper.parseReaction(trimmed);
|
||||
if (reaction != null) {
|
||||
return 'Reacted ${reaction.emoji}';
|
||||
return l10n.notification_reacted(reaction.emoji);
|
||||
}
|
||||
if (RegExp(r'^g:[A-Za-z0-9_-]+$').hasMatch(trimmed)) {
|
||||
return 'Sent a GIF';
|
||||
if (ReceivedImageRef.parse(trimmed) != null) {
|
||||
return l10n.notification_sentImage;
|
||||
}
|
||||
if (GifHelper.parseGif(trimmed) != null) {
|
||||
return l10n.notification_sentGif;
|
||||
}
|
||||
final marker = parseMarkerText(trimmed);
|
||||
if (marker != null) {
|
||||
return marker.label.isEmpty
|
||||
? l10n.notification_sharedLocation
|
||||
: l10n.notification_sharedLocationNamed(marker.label);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@@ -397,7 +411,7 @@ class NotificationService {
|
||||
message,
|
||||
urlImagesEnabled: urlImagesEnabled,
|
||||
);
|
||||
final preview = formatNotificationText(message.trim());
|
||||
final preview = formatNotificationText(message.trim(), _l10n);
|
||||
final body = preview.isEmpty
|
||||
? _l10n.notification_receivedNewMessage
|
||||
: preview;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/screens/map_screen.dart';
|
||||
import 'package:meshcore_open/helpers/marker_message.dart';
|
||||
|
||||
void main() {
|
||||
test('parseMarkerText accepts in-range coordinates', () {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/helpers/gif_helper.dart';
|
||||
import 'package:meshcore_open/helpers/reaction_helper.dart';
|
||||
import 'package:meshcore_open/l10n/app_localizations.dart';
|
||||
import 'package:meshcore_open/services/notification_service.dart';
|
||||
import 'package:meshcore_open/services/received_image_store.dart';
|
||||
import 'package:meshcore_open/widgets/marker_label_dialog.dart';
|
||||
|
||||
void main() {
|
||||
final l10n = lookupAppLocalizations(const Locale('en'));
|
||||
String format(String text) =>
|
||||
NotificationService.formatNotificationText(text, l10n);
|
||||
|
||||
test('shared locations show a summary instead of coordinates', () {
|
||||
expect(
|
||||
format(formatMarkerText(45.5, -122.6, 'Camp', 'poi')),
|
||||
'Shared a location: Camp',
|
||||
);
|
||||
expect(
|
||||
format(formatMarkerText(45.5, -122.6, '', 'poi')),
|
||||
'Shared a location',
|
||||
);
|
||||
});
|
||||
|
||||
test('reactions, GIFs and images are summarized', () {
|
||||
expect(
|
||||
format(ReactionHelper.encodeReaction('ab12', '00')),
|
||||
startsWith('Reacted '),
|
||||
);
|
||||
expect(format('👍\nabcd2345'), 'Reacted 👍');
|
||||
expect(format(GifHelper.encodeGif('xT9IgG50Fb7Mi0prBC')), 'Sent a GIF');
|
||||
expect(
|
||||
format('https://media.giphy.com/media/xT9IgG50Fb7Mi0prBC/giphy.gif'),
|
||||
'Sent a GIF',
|
||||
);
|
||||
expect(format(ReceivedImageRef.encode('0a1b2c3d4e5f60')), 'Sent an image');
|
||||
});
|
||||
|
||||
test('plain text is unchanged', () {
|
||||
expect(format('see you at m:ain street'), 'see you at m:ain street');
|
||||
expect(format('hello'), 'hello');
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"bg": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -7,6 +12,11 @@
|
||||
],
|
||||
|
||||
"de": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -14,6 +24,11 @@
|
||||
],
|
||||
|
||||
"es": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -21,6 +36,11 @@
|
||||
],
|
||||
|
||||
"fr": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -28,6 +48,11 @@
|
||||
],
|
||||
|
||||
"hu": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -35,6 +60,11 @@
|
||||
],
|
||||
|
||||
"it": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -42,6 +72,11 @@
|
||||
],
|
||||
|
||||
"ja": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -49,6 +84,11 @@
|
||||
],
|
||||
|
||||
"ko": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -56,6 +96,11 @@
|
||||
],
|
||||
|
||||
"nl": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -63,6 +108,11 @@
|
||||
],
|
||||
|
||||
"pl": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -70,6 +120,11 @@
|
||||
],
|
||||
|
||||
"pt": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -77,6 +132,11 @@
|
||||
],
|
||||
|
||||
"ru": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -84,6 +144,11 @@
|
||||
],
|
||||
|
||||
"sk": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -91,6 +156,11 @@
|
||||
],
|
||||
|
||||
"sl": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -98,6 +168,11 @@
|
||||
],
|
||||
|
||||
"sv": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -105,6 +180,11 @@
|
||||
],
|
||||
|
||||
"uk": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
@@ -112,6 +192,11 @@
|
||||
],
|
||||
|
||||
"zh": [
|
||||
"notification_sharedLocation",
|
||||
"notification_sharedLocationNamed",
|
||||
"notification_reacted",
|
||||
"notification_sentGif",
|
||||
"notification_sentImage",
|
||||
"contacts_keyPrefixSemantics",
|
||||
"networkMap_sourceLocalHint",
|
||||
"networkMap_sourceOnlineHint",
|
||||
|
||||
Reference in new issue
Block a user