diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ac3b4792..e4ef43fb 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index fb605bc8..ca7fe065 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -19,8 +19,8 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.9.1" apply false - id("org.jetbrains.kotlin.android") version "2.1.0" apply false + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false } include(":app") diff --git a/docs/PRIVACY_POLICY.md b/docs/PRIVACY_POLICY.md index bdbe89d0..64bff9fb 100644 --- a/docs/PRIVACY_POLICY.md +++ b/docs/PRIVACY_POLICY.md @@ -1,6 +1,6 @@ # Privacy Policy for MeshCore Open -**Last Updated:** January 11, 2026 +**Last Updated:** August 23, 2026 ## Introduction @@ -11,16 +11,17 @@ MeshCore Open ("the App") is an open-source Flutter application for communicatin ### Data We Do NOT Collect MeshCore Open does **not**: -- Collect personal information -- Send data to external servers (except map tile requests) +- Collect personal information for the developer - Track your usage or behavior - Use analytics services - Require account creation -- Share any data with third parties +- Sell personal information + +The App does make limited requests to third-party services when you use features that require internet access, as described below. ### Data Stored Locally on Your Device -The App stores the following data **locally on your device only**: +The App stores the following data **locally on your device**: - **Messages**: Chat messages sent and received through the mesh network - **Contacts**: Names and identifiers of mesh network contacts @@ -30,7 +31,7 @@ The App stores the following data **locally on your device only**: - **Debug Logs**: Optional BLE and app debug logs (if enabled by user) - **Cached Map Tiles**: Offline map data for the mapping feature -All locally stored data remains on your device and is never transmitted to us or any third party. +This locally stored data is not transmitted to the MeshCore Open developer. Some features may send specific data to third-party services as described in the Third-Party Services section. ## Permissions @@ -45,12 +46,12 @@ These permissions are used solely to discover and communicate with MeshCore hard ### Location Permission - **ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION** -Required by Android for BLE scanning on Android 11 and below. The App does not track or store your location. Location data may be optionally shared over the mesh network if you choose to enable location sharing features. +Required by Android for BLE scanning on Android 11 and below. MeshCore Open does not use the phone's GPS to determine your location. Location data shown in the App comes from MeshCore devices and mesh advertisements. Location data may also be optionally shared over the mesh network if you choose to enable location sharing features. ### Internet Permission - **INTERNET** -Used only for downloading map tiles from OpenStreetMap tile servers when using the map feature. No personal data is transmitted. +Used for features that access third-party internet services, including map tiles, Line-of-Sight elevation lookups, optional model downloads, and optional GIF search. ### Notification Permission - **POST_NOTIFICATIONS** (Android 13+) @@ -65,7 +66,23 @@ Used to maintain BLE connection with your MeshCore device while the app is in th ## Third-Party Services ### Map Tiles -The App uses OpenStreetMap tile servers to display maps. When viewing maps, your device's IP address may be visible to the tile server. No other data is shared. See [OpenStreetMap's Privacy Policy](https://wiki.osmfoundation.org/wiki/Privacy_Policy) for more information. +The App uses OpenStreetMap and, when selected in settings, Stadia Maps tile servers to display maps. Map tile requests include tile coordinates that identify the geographic area being viewed, and your device's IP address may be visible to the tile provider. + +See [OpenStreetMap's Privacy Policy](https://wiki.osmfoundation.org/wiki/Privacy_Policy) and [Stadia Maps' Privacy Policy](https://stadiamaps.com/privacy/) for more information. + +### Line-of-Sight Elevation Lookups (Open-Meteo) +When you use the Line-of-Sight (LOS) analysis feature, the App sends latitude and longitude coordinates for points along the selected radio path to the Open-Meteo Elevation API. These coordinates come from MeshCore node positions or locations selected in the map, not from the phone's GPS. + +Open-Meteo uses these coordinates to return terrain elevation data needed for the LOS calculation. The request also exposes your device's IP address to Open-Meteo as part of normal internet communication. + +LOS elevation lookups are only made when the LOS feature is used. See [Open-Meteo's Terms and Privacy information](https://open-meteo.com/en/terms) for more information. + +### Model Downloads (Hugging Face) +The App can download optional translation models and the optional neural image-codec model bundle from Hugging Face when you choose to install or update those models in Settings. + +When a model download is requested, the App sends standard HTTP requests for the selected model files to `huggingface.co`. Your device's IP address is visible to Hugging Face as part of normal internet communication. The App does not upload your messages, contacts, mesh location data, or other locally stored content to Hugging Face as part of these model downloads. + +Model-download requests are only made when you choose to download or update a model. See [Hugging Face's Privacy Policy](https://huggingface.co/privacy) for more information. ### GIF Search (Giphy) The App includes a GIF picker feature powered by Giphy. When you use the GIF search feature: @@ -81,7 +98,7 @@ Messages sent through the MeshCore mesh network are transmitted over radio frequ ## Data Security -All data is stored locally on your device using standard Flutter/Android storage mechanisms. The App does not implement additional encryption for locally stored data beyond what the operating system provides. +All data stored locally on your device uses standard Flutter/Android storage mechanisms. The App does not implement additional encryption for locally stored data beyond what the operating system provides. ## Children's Privacy @@ -101,4 +118,4 @@ If you have questions about this Privacy Policy or the App's privacy practices, --- -**Summary**: MeshCore Open is a privacy-respecting app that stores all data locally on your device. We do not collect, track, or share your personal information. +**Summary**: MeshCore Open does not use the phone's GPS for location, does not include analytics, and does not collect personal information for the developer. Some optional features communicate with third-party services, including map tile providers, Open-Meteo for LOS elevation lookups, Hugging Face for model downloads, and Giphy for GIF search. diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 6db7f11e..5e073e4c 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -375,12 +375,14 @@ class MeshCoreConnector extends ChangeNotifier { List _cachedChannels = []; final Map _channelSmazEnabled = {}; final Map _channelCyr2LatEnabled = {}; + final Map _channelUrlImagesEnabled = {}; final Map _channelCyr2LatProfileId = {}; final Map _channelRegions = {}; bool _lastSentWasCliCommand = false; // Track if last sent message was a CLI command final Map _contactSmazEnabled = {}; final Map _contactCyr2LatEnabled = {}; + final Map _contactUrlImagesEnabled = {}; final Map _contactCyr2LatProfileId = {}; final Set _knownContactKeys = {}; final Map _contactUnreadCount = {}; @@ -454,6 +456,13 @@ class MeshCoreConnector extends ChangeNotifier { ); } + Contact? getContactByPubKeyHex(String contactPubKeyHex) { + return _contacts.cast().firstWhere( + (c) => c?.publicKeyHex == contactPubKeyHex, + orElse: () => null, + ); + } + List get allContacts => List.unmodifiable([ ..._contacts, ..._discoveredContacts.where( @@ -782,6 +791,15 @@ class MeshCoreConnector extends ChangeNotifier { return _contactSmazEnabled[contactKeyHex] ?? false; } + bool isChannelUrlImagesEnabled(int channelIndex) { + return _channelUrlImagesEnabled[channelIndex] ?? false; + } + + bool isContactUrlImagesEnabled(String contactKeyHex) { + _ensureContactUrlImagesSettingLoaded(contactKeyHex); + return _contactUrlImagesEnabled[contactKeyHex] ?? false; + } + bool hasChannelRegion(int channelIndex) { return (_channelRegions[channelIndex] ?? '').isNotEmpty; } @@ -924,6 +942,24 @@ class MeshCoreConnector extends ChangeNotifier { notifyListeners(); } + Future setChannelUrlImagesEnabled( + int channelIndex, + bool enabled, + ) async { + _channelUrlImagesEnabled[channelIndex] = enabled; + await _channelSettingsStore.saveUrlImagesEnabled(channelIndex, enabled); + notifyListeners(); + } + + Future setContactUrlImagesEnabled( + String contactKeyHex, + bool enabled, + ) async { + _contactUrlImagesEnabled[contactKeyHex] = enabled; + await _contactSettingsStore.saveUrlImagesEnabled(contactKeyHex, enabled); + notifyListeners(); + } + Future setChannelCyr2LatEnabled(int channelIndex, bool enabled) async { _channelCyr2LatEnabled[channelIndex] = enabled; if (enabled) { @@ -1094,6 +1130,7 @@ class MeshCoreConnector extends ChangeNotifier { } Future loadContactCache() async { + _contactUrlImagesEnabled.clear(); final cached = await _contactStore.loadContacts(); _knownContactKeys ..clear() @@ -1104,6 +1141,7 @@ class MeshCoreConnector extends ChangeNotifier { for (final contact in cached) { _ensureContactSmazSettingLoaded(contact.publicKeyHex); _ensureContactCyr2LatSettingLoaded(contact.publicKeyHex); + _ensureContactUrlImagesSettingLoaded(contact.publicKeyHex); } } @@ -1136,12 +1174,15 @@ class MeshCoreConnector extends ChangeNotifier { Future loadChannelSettings({int? maxChannels}) async { _channelSmazEnabled.clear(); _channelCyr2LatEnabled.clear(); + _channelUrlImagesEnabled.clear(); _channelRegions.clear(); final channelCount = maxChannels ?? _maxChannels; for (int i = 0; i < channelCount; i++) { _channelSmazEnabled[i] = await _channelSettingsStore.loadSmazEnabled(i); _channelCyr2LatEnabled[i] = await _channelSettingsStore .loadCyr2LatEnabled(i); + _channelUrlImagesEnabled[i] = await _channelSettingsStore + .loadUrlImagesEnabled(i); _channelRegions[i] = await _channelRegionStore.loadRegion(i); } } @@ -3162,9 +3203,15 @@ class MeshCoreConnector extends ChangeNotifier { // Check if this is a reaction - apply locally with pending status and route through retry service final reactionInfo = ReactionHelper.parseReaction(text); if (reactionInfo != null) { + appLogger.info('Sending reaction: ${reactionInfo.identifier()}'); _conversations.putIfAbsent(contact.publicKeyHex, () => []); final messages = _conversations[contact.publicKeyHex]!; + // No check for duplicates. If you want to do it again to resend, you can. + final String reactionID = reactionInfo.identifier(); + _processedContactReactions.putIfAbsent(contact.publicKeyHex, () => {}); + _processedContactReactions[contact.publicKeyHex]!.add(reactionID); + // Apply reaction locally with pending status _processOutgoingContactReaction(messages, reactionInfo, contact); _setReactionStatus( @@ -3206,7 +3253,7 @@ class MeshCoreConnector extends ChangeNotifier { translatedLanguageCode: translatedLanguageCode, translationModelId: translationModelId, ); - _addMessage(contact.publicKeyHex, message); + _addMessage(contact.publicKeyHex, message); // recipient as "sender" notifyListeners(); final outboundText = prepareContactOutboundText(contact, text); await sendFrame(buildSendTextMsgFrame(contact.publicKey, outboundText)); @@ -3543,11 +3590,12 @@ class MeshCoreConnector extends ChangeNotifier { // Check if this is a reaction - if so, process it immediately instead of adding as a message final reactionInfo = ReactionHelper.parseReaction(text); if (reactionInfo != null) { + reactionInfo.senderName = selfName; // Check if we've already processed this reaction _processedChannelReactions.putIfAbsent(channel.index, () => {}); - final reactionIdentifier = - '${reactionInfo.targetHash}_${reactionInfo.emoji}'; + final reactionIdentifier = reactionInfo.identifier(); + // Maybe we should allow resending. Recipients can drop duplicates. if (_processedChannelReactions[channel.index]!.contains( reactionIdentifier, )) { @@ -3560,6 +3608,7 @@ class MeshCoreConnector extends ChangeNotifier { final messages = _channelMessages[channel.index]!; // Process reaction locally to update the UI immediately + appLogger.info('Adding sent channel reaction, id: $reactionIdentifier'); _processReaction(messages, reactionInfo); await _channelMessageStore.saveChannelMessages(channel.index, messages); @@ -5326,6 +5375,8 @@ class MeshCoreConnector extends ChangeNotifier { await _notificationService.showMessageNotification( contactName: c?.name ?? 'Unknown', message: resolvedText, + urlImagesEnabled: + c != null && isContactUrlImagesEnabled(c.publicKeyHex), contactId: msg.senderKeyHex, badgeCount: getTotalUnreadCount(), ); @@ -5340,6 +5391,8 @@ class MeshCoreConnector extends ChangeNotifier { await _notificationService.showMessageNotification( contactName: c?.name ?? 'Unknown Room', message: resolvedText, + urlImagesEnabled: + c != null && isContactUrlImagesEnabled(c.publicKeyHex), contactId: msg.senderKeyHex, badgeCount: getTotalUnreadCount(), ); @@ -5490,6 +5543,15 @@ class MeshCoreConnector extends ChangeNotifier { }); } + void _ensureContactUrlImagesSettingLoaded(String contactKeyHex) { + if (_contactUrlImagesEnabled.containsKey(contactKeyHex)) return; + _contactSettingsStore.loadUrlImagesEnabled(contactKeyHex).then((enabled) { + if (_contactUrlImagesEnabled[contactKeyHex] == enabled) return; + _contactUrlImagesEnabled[contactKeyHex] = enabled; + notifyListeners(); + }); + } + void _ensureContactCyr2LatProfileLoaded(String contactKeyHex) { if (_contactCyr2LatProfileId.containsKey(contactKeyHex)) return; _contactSettingsStore.loadCyr2LatProfileId(contactKeyHex).then((profileId) { @@ -5644,6 +5706,7 @@ class MeshCoreConnector extends ChangeNotifier { channelName: label, senderName: message.senderName, message: resolvedText, + urlImagesEnabled: isChannelUrlImagesEnabled(channelIndex), channelIndex: message.channelIndex, badgeCount: getTotalUnreadCount(), ); @@ -6219,15 +6282,23 @@ class MeshCoreConnector extends ChangeNotifier { if (reactionInfo != null) { // Check if we've already processed this exact reaction _processedContactReactions.putIfAbsent(pubKeyHex, () => {}); - final reactionIdentifier = - '${reactionInfo.targetHash}_${reactionInfo.emoji}'; - + reactionInfo.senderName = _resolveContactSenderName(message, null, false); + final reactionIdentifier = reactionInfo.identifier(); final isDuplicate = _processedContactReactions[pubKeyHex]!.contains( reactionIdentifier, ); if (!isDuplicate) { // New reaction - process it + appLogger.info('Adding reaction, id: $reactionIdentifier'); + // For hashing and dup checking, we use null for sender names in + // normal 1:1 chats. This way if we and they have different ideas + // about what their name is, reactions still work. But for reaction + // reports, we want to know who sent what, rather than infer it later, + // so we'll add it to the reactionInfo before storing it. + reactionInfo.senderName ??= message.isOutgoing + ? selfName + : getContactByPubKeyHex(pubKeyHex)?.name ?? '???'; _processContactReaction(messages, reactionInfo, pubKeyHex); _messageStore.saveMessages(pubKeyHex, messages); @@ -6252,10 +6323,7 @@ class MeshCoreConnector extends ChangeNotifier { ReactionInfo reactionInfo, String contactPubKeyHex, ) { - final contact = _contacts.cast().firstWhere( - (c) => c?.publicKeyHex == contactPubKeyHex, - orElse: () => null, - ); + final contact = getContactByPubKeyHex(contactPubKeyHex); final isRoomServer = contact?.type == advTypeRoom; ReactionHelper.applyReaction( @@ -6304,10 +6372,7 @@ class MeshCoreConnector extends ChangeNotifier { ) { final messages = _conversations[pubKeyHex]; if (messages == null) return; - final contact = _contacts.cast().firstWhere( - (c) => c?.publicKeyHex == pubKeyHex, - orElse: () => null, - ); + final contact = getContactByPubKeyHex(pubKeyHex); final isRoomServer = contact?.type == advTypeRoom; for (int i = messages.length - 1; i >= 0; i--) { final msg = messages[i]; @@ -6466,12 +6531,11 @@ class MeshCoreConnector extends ChangeNotifier { final messages = _channelMessages[channelIndex]!; // Parse reaction info - final reactionInfo = ChannelMessage.parseReaction(message.text); + final reactionInfo = message.parseReaction(); if (reactionInfo != null) { // Check if we've already processed this exact reaction _processedChannelReactions.putIfAbsent(channelIndex, () => {}); - final reactionIdentifier = - '${reactionInfo.targetHash}_${reactionInfo.emoji}'; + final reactionIdentifier = reactionInfo.identifier(); final isDuplicate = _processedChannelReactions[channelIndex]!.contains( reactionIdentifier, @@ -6479,6 +6543,7 @@ class MeshCoreConnector extends ChangeNotifier { if (!isDuplicate) { // New reaction - process it + appLogger.info('Adding channel reaction, id: $reactionIdentifier'); _processReaction(messages, reactionInfo); // Save updated messages _channelMessageStore.saveChannelMessages(channelIndex, messages); diff --git a/lib/helpers/message_url_image_helper.dart b/lib/helpers/message_url_image_helper.dart new file mode 100644 index 00000000..d917af6d --- /dev/null +++ b/lib/helpers/message_url_image_helper.dart @@ -0,0 +1,338 @@ +import 'dart:async'; +import 'dart:collection'; + +import 'package:flutter/material.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:http/http.dart' as http; + +/// Finds and renders image URLs embedded in ordinary text messages. +/// +/// This is deliberately separate from MeshCore's transmitted channel-image +/// protocol, which is handled by [ReceivedImageStore]. +class MessageUrlImageHelper { + static final Map> _verifiedImageCache = + >{}; + static const int _maxMessageImageCacheEntries = 200; + static final LinkedHashMap> _messageImageCache = + LinkedHashMap>(); + + static final RegExp _pyxPattern = RegExp( + r'''https?://pyx\.li/\?i=([^\s<>'"`]+)''', + caseSensitive: false, + ); + + static final RegExp _ipfsUrlPattern = RegExp( + r'''https?://[^\s<>'"`]+/(?:ipfs|ipns)/[^\s<>'"`]+''', + caseSensitive: false, + ); + + static final RegExp _ipfsCidPattern = RegExp( + r'''ipfs:(?://)?([^\s<>'"`]+)''', + caseSensitive: false, + ); + + static final RegExp _ibbSharePattern = RegExp( + r'''https?://(?:www\.)?ibb\.co/[^\s<>'"`/?#]+(?:[/?#][^\s<>'"`]*)?''', + caseSensitive: false, + ); + + static final RegExp _imagePattern = RegExp( + r'''https?://[^\s<>'"`]+?\.(?:png|jpe?g|webp)(?:\?[^\s<>'"`]+)?(?:#[^\s<>'"`]+)?''', + caseSensitive: false, + ); + + /// Checks locally whether [text] contains a URL format this helper supports. + /// This deliberately does not resolve sharing pages or fetch image data. + static bool hasPotentialImageUrl(String text) { + return _pyxPattern.hasMatch(text) || + _ipfsUrlPattern.hasMatch(text) || + _ipfsCidPattern.hasMatch(text) || + _ibbSharePattern.hasMatch(text) || + _imagePattern.hasMatch(text); + } + + static Future parse(String text) async { + final trimmed = text.trim(); + if (trimmed.isEmpty) return null; + + final pyxMatch = _pyxPattern.firstMatch(trimmed); + if (pyxMatch != null) { + return _extractFromUrl( + _trimBoundary(pyxMatch.group(0)!), + RegExp(r''']+src=["']([^"']+)["']''', caseSensitive: false), + ); + } + + final ipfsUrlMatch = _ipfsUrlPattern.firstMatch(trimmed); + if (ipfsUrlMatch != null) { + return _trimBoundary(ipfsUrlMatch.group(0)!); + } + + final ipfsCidMatch = _ipfsCidPattern.firstMatch(trimmed); + if (ipfsCidMatch != null) { + final cid = _trimBoundary(ipfsCidMatch.group(1)!); + return 'https://ipfs.io/ipfs/$cid'; + } + + final ibbMatch = _ibbSharePattern.firstMatch(trimmed); + if (ibbMatch != null) { + return _extractFromUrl( + _trimBoundary(ibbMatch.group(0)!), + RegExp( + r''']+property=["']og:image["'][^>]+content=["']([^"']+)["']''', + caseSensitive: false, + ), + ); + } + + final imageMatch = _imagePattern.firstMatch(trimmed); + if (imageMatch != null) { + return _trimBoundary(imageMatch.group(0)!); + } + + return null; + } + + static Future parseVerified(String text) async { + final imageUrl = await parse(text); + if (imageUrl == null) return null; + + final verified = await _verifyImageUrl(imageUrl); + return verified ? imageUrl : null; + } + + /// Caches successful URL-image parsing by stable message identity. + /// + /// Null results are evicted so temporary connectivity or host failures can + /// be retried when a message is shown again. + static Future parseVerifiedForMessage( + String messageId, + String text, + ) { + final cached = _messageImageCache.remove(messageId); + if (cached != null) { + _messageImageCache[messageId] = cached; + return cached; + } + + final parsing = parseVerified(text); + _messageImageCache[messageId] = parsing; + parsing.then((imageUrl) { + if (imageUrl == null && + identical(_messageImageCache[messageId], parsing)) { + _messageImageCache.remove(messageId); + } else if (imageUrl != null) { + while (_messageImageCache.length > _maxMessageImageCacheEntries) { + _messageImageCache.remove(_messageImageCache.keys.first); + } + } + }); + return parsing; + } + + static Future _extractFromUrl(String pageUrl, RegExp pattern) async { + try { + final response = await http + .get(Uri.parse(pageUrl)) + .timeout(const Duration(seconds: 8)); + if (response.statusCode < 200 || response.statusCode >= 300) { + return null; + } + final value = pattern.firstMatch(response.body)?.group(1); + if (value == null || value.isEmpty) return null; + + final imageUrl = Uri.parse( + pageUrl, + ).resolve(value.replaceAll('&', '&')); + return imageUrl.scheme == 'http' || imageUrl.scheme == 'https' + ? imageUrl.toString() + : null; + } catch (_) { + return null; + } + } + + static String _trimBoundary(String value) { + return value.trim().replaceAll(RegExp(r"[.,;:!?]+$"), ''); + } + + static Future _verifyImageUrl(String imageUrl) { + final cached = _verifiedImageCache[imageUrl]; + if (cached != null) return cached; + + final verification = _tryLoadImage(imageUrl); + _verifiedImageCache[imageUrl] = verification; + verification.then((verified) { + if (!verified && identical(_verifiedImageCache[imageUrl], verification)) { + _verifiedImageCache.remove(imageUrl); + } + }); + return verification; + } + + static Future _tryLoadImage(String imageUrl) async { + final completer = Completer(); + final stream = CachedNetworkImageProvider( + imageUrl, + ).resolve(const ImageConfiguration()); + + late final ImageStreamListener listener; + listener = ImageStreamListener( + (_, _) { + if (!completer.isCompleted) completer.complete(true); + stream.removeListener(listener); + }, + onError: (_, _) { + if (!completer.isCompleted) completer.complete(false); + stream.removeListener(listener); + }, + ); + + stream.addListener(listener); + + return completer.future.timeout( + const Duration(seconds: 8), + onTimeout: () { + stream.removeListener(listener); + return false; + }, + ); + } +} + +class MessageUrlImageFutureBuilder extends StatefulWidget { + const MessageUrlImageFutureBuilder({ + super.key, + required this.messageId, + required this.text, + required this.builder, + }); + + final String messageId; + final String text; + final AsyncWidgetBuilder builder; + + @override + State createState() => + _MessageUrlImageFutureBuilderState(); +} + +class _MessageUrlImageFutureBuilderState + extends State { + late Future _imageFuture; + + @override + void initState() { + super.initState(); + _imageFuture = MessageUrlImageHelper.parseVerifiedForMessage( + widget.messageId, + widget.text, + ); + } + + @override + void didUpdateWidget(covariant MessageUrlImageFutureBuilder oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.messageId != widget.messageId) { + _imageFuture = MessageUrlImageHelper.parseVerifiedForMessage( + widget.messageId, + widget.text, + ); + } + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: _imageFuture, + builder: widget.builder, + ); + } +} + +class MessageUrlImagePreview extends StatelessWidget { + const MessageUrlImagePreview({super.key, required this.imageUrl}); + + final String imageUrl; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (context) => Dialog( + insetPadding: const EdgeInsets.all(12), + backgroundColor: Colors.black, + child: SizedBox( + width: double.infinity, + height: double.infinity, + child: Stack( + children: [ + Positioned.fill( + child: InteractiveViewer( + boundaryMargin: const EdgeInsets.all(80), + minScale: 1.0, + maxScale: 3.0, + child: Center( + child: CachedNetworkImage( + imageUrl: imageUrl, + fit: BoxFit.contain, + placeholder: (context, url) => const Center( + child: CircularProgressIndicator(strokeWidth: 2), + ), + errorWidget: (context, url, error) => const Center( + child: Icon( + Icons.broken_image, + color: Colors.white, + ), + ), + ), + ), + ), + ), + Positioned( + top: 12, + right: 12, + child: IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: const Icon(Icons.close, color: Colors.white), + style: IconButton.styleFrom( + backgroundColor: Colors.black54, + ), + ), + ), + ], + ), + ), + ), + ); + }, + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: SizedBox( + width: 240, + height: 240, + child: CachedNetworkImage( + imageUrl: imageUrl, + fit: BoxFit.contain, + placeholder: (context, url) => ColoredBox( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + child: const Center( + child: CircularProgressIndicator(strokeWidth: 2), + ), + ), + errorWidget: (context, url, error) => Container( + padding: const EdgeInsets.all(12), + color: Theme.of(context).colorScheme.surfaceContainerHighest, + child: Text( + 'Unable to load image', + style: Theme.of(context).textTheme.bodySmall, + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/helpers/reaction_helper.dart b/lib/helpers/reaction_helper.dart index 36118ca3..18a72388 100644 --- a/lib/helpers/reaction_helper.dart +++ b/lib/helpers/reaction_helper.dart @@ -3,8 +3,17 @@ import '../widgets/emoji_picker.dart'; class ReactionInfo { final String targetHash; final String emoji; + String? senderName; - ReactionInfo({required this.targetHash, required this.emoji}); + ReactionInfo({ + required this.targetHash, + required this.emoji, + this.senderName, + }); + + String identifier() { + return '$targetHash:$emoji:${senderName ?? ""}'; + } } class ReactionHelper { @@ -26,9 +35,8 @@ class ReactionHelper { required int Function(T) getTimestampSecs, required String? Function(T) getSenderName, required String Function(T) getMessageText, - required Map Function(T) getReactions, + required Map> Function(T) getReactions, required bool Function(T) shouldSkip, - required void Function(int index, Map newReactions) updateMessage, }) { final targetHash = reactionInfo.targetHash; @@ -42,9 +50,12 @@ class ReactionHelper { getMessageText(msg), ); if (msgHash == targetHash) { - final currentReactions = Map.from(getReactions(msg)); - currentReactions[reactionInfo.emoji] = - (currentReactions[reactionInfo.emoji] ?? 0) + 1; + final currentReactions = Map>.from( + getReactions(msg), + ); + (currentReactions[reactionInfo.emoji] ??= []).add( + reactionInfo.senderName, + ); updateMessage(i, currentReactions); return true; } diff --git a/lib/l10n/app_bg.arb b/lib/l10n/app_bg.arb index 723fc17f..fe84e37d 100644 --- a/lib/l10n/app_bg.arb +++ b/lib/l10n/app_bg.arb @@ -485,6 +485,7 @@ } } }, + "chat_selectSendAction": "Изберете действие за изпращане", "chat_sendGif": "Изпрати GIF", "chat_reply": "Отговори", "chat_addReaction": "Добави Реакция", @@ -2756,7 +2757,7 @@ "channels_regionNotSet": "Регион: ние", "channels_regionSelect_Title": "Выберете регион", "channels_clearRegion": "Чиста зона", - "chat_sendImage": "Изпрати изображение", + "chat_sendImageLora": "Изпращане на изображение чрез MeshCore", "chat_imagePickFailed": "Не мог да откривам та изображин", "chat_receivedGif": "Получил GIF", "repeater_keySettings": "Изменяне на идентичности ключа", diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 549ac823..ef963287 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -507,6 +507,7 @@ } } }, + "chat_selectSendAction": "Sendeaktion auswählen", "chat_sendGif": "GIF senden", "chat_reply": "Antworten", "chat_addReaction": "Reaktion hinzufügen", @@ -2627,6 +2628,8 @@ "messageStatus_pending": "Wird gesendet", "messageStatus_failed": "Senden fehlgeschlagen", "messageStatus_repeated": "Mehrfach gehört", + "urlImage_enable": "URL-Bilder anzeigen", + "urlImage_possible": "Mögliches URL-Bild; in den Einstellungen aktivieren.", "contacts_moreOptions": "Weitere Optionen", "contacts_searchOpen": "Suche öffnen", "contacts_searchClose": "Suche schließen", @@ -2892,7 +2895,7 @@ "repeater_pathHashModeOption2": "2 - 3 Bytes", "repeater_pathHashModeOption3": "3 - 4 Bytes", "appSettings_batteryLipoHv": "LiPo HV (3,0–4,35 V)", - "chat_sendImage": "Bild senden", + "chat_sendImageLora": "Bild über MeshCore senden", "chat_imagePickFailed": "Konnte dieses Bild nicht öffnen.", "chat_receivedGif": "Erhalten eines GIF", "repeater_keySettings": "Identitätsschlüssel ändern", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e7f448df..16eae50c 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -34,6 +34,8 @@ "messageStatus_pending": "Sending", "messageStatus_failed": "Failed to send", "messageStatus_repeated": "Heard repeated", + "urlImage_enable": "Enable URL images", + "urlImage_possible": "Possible URL image; enable it in Settings.", "common_reboot": "Reboot", "common_loading": "Loading...", "common_notAvailable": "—", @@ -740,8 +742,9 @@ } } }, + "chat_selectSendAction": "Select send action", "chat_sendGif": "Send GIF", - "chat_sendImage": "Send image", + "chat_sendImageLora": "Send image via meshcore", "chat_imagePickFailed": "Couldn't open that image", "@chat_imagePickFailed": { "description": "Shown when picking or reading a photo to send fails" @@ -750,6 +753,7 @@ "chat_reply": "Reply", "chat_addReaction": "Add Reaction", "chat_me": "Me", + "reaction_report": "Emoji Reactions", "emojiCategorySmileys": "Smileys", "emojiCategoryGestures": "Gestures", "emojiCategoryHearts": "Hearts", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index fc2b0fbc..07a22733 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -507,6 +507,7 @@ } } }, + "chat_selectSendAction": "Seleccionar acción de envío", "chat_sendGif": "Enviar GIF", "chat_reply": "Responder", "chat_addReaction": "Añadir Reacción", @@ -2890,7 +2891,7 @@ "channels_regionNotSet": "Región: ninguna", "channels_regionSelect_Title": "Seleccione una región", "channels_clearRegion": "Zona despejada", - "chat_sendImage": "Enviar imagen", + "chat_sendImageLora": "Enviar imagen mediante MeshCore", "chat_imagePickFailed": "No pude abrir esa imagen", "chat_receivedGif": "Recibido un GIF", "repeater_keySettings": "Cambiar Claves de Identidad", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 6b7a28f4..678c4e21 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -507,6 +507,7 @@ } } }, + "chat_selectSendAction": "Sélectionner une action d’envoi", "chat_sendGif": "Envoyer un GIF", "chat_reply": "Répondre", "chat_addReaction": "Ajouter une réaction", @@ -2890,7 +2891,7 @@ "channels_regionNotSet": "Région : aucune", "channels_regionSelect_Title": "Choisissez une région", "channels_clearRegion": "Zone dégagée", - "chat_sendImage": "Envoyer l'image", + "chat_sendImageLora": "Envoyer une image via MeshCore", "chat_imagePickFailed": "Je n'ai pas pu ouvrir cette image", "chat_receivedGif": "Reçu un GIF", "repeater_keySettings": "Modifier les clés d'identité", diff --git a/lib/l10n/app_hu.arb b/lib/l10n/app_hu.arb index 6df4f5bb..432a8895 100644 --- a/lib/l10n/app_hu.arb +++ b/lib/l10n/app_hu.arb @@ -657,6 +657,7 @@ } } }, + "chat_selectSendAction": "Küldési művelet kiválasztása", "chat_sendGif": "GIF küldése", "chat_reply": "Válasz", "chat_addReaction": "Reakció hozzáadása", @@ -2794,7 +2795,7 @@ "channels_regionNotSet": "Tájékoztetés: nem", "channels_regionSelect_Title": "Válassz egy regionot", "channels_clearRegion": "Kéres kör", - "chat_sendImage": "Felhasználj az image", + "chat_sendImageLora": "Kép küldése MeshCore-on keresztül", "chat_imagePickFailed": "Nem tudtam ezt a fenti fényre kapni", "chat_receivedGif": "GIF-ot kapott", "repeater_keySettings": "Képzőítsekei jelölt", diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 70b74dcb..91e52f67 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -551,6 +551,7 @@ } } }, + "chat_selectSendAction": "Seleziona azione di invio", "chat_sendGif": "Invia GIF", "chat_reply": "Rispondi", "chat_addReaction": "Aggiungi Reazione", @@ -2890,7 +2891,7 @@ "channels_regionNotSet": "Regione: nessuna", "channels_regionSelect_Title": "Scegli una regione", "channels_clearRegion": "Zona chiara", - "chat_sendImage": "Invia immagine", + "chat_sendImageLora": "Invia immagine tramite MeshCore", "chat_imagePickFailed": "Non sono riuscito ad aprire quell'immagine", "chat_receivedGif": "Ricevuto un GIF", "repeater_keySettings": "Cambia le Chiavi di Identità", diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index 26ec3caf..3652c9b6 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -675,6 +675,7 @@ } } }, + "chat_selectSendAction": "送信アクションを選択", "chat_sendGif": "GIF を送信", "chat_reply": "返信", "chat_addReaction": "リアクションを追加", @@ -2890,7 +2891,7 @@ "channels_regionNotSet": "地域:なし", "channels_regionSelect_Title": "地域を選択する", "channels_clearRegion": "クリアな地域", - "chat_sendImage": "画像を送信", + "chat_sendImageLora": "MeshCore経由で画像を送信", "chat_imagePickFailed": "その画像を開けませんでした", "chat_receivedGif": "GIFを受け取りました", "repeater_keySettings": "アイデンティティキーの変更", diff --git a/lib/l10n/app_ko.arb b/lib/l10n/app_ko.arb index 686e02e1..fcea4e39 100644 --- a/lib/l10n/app_ko.arb +++ b/lib/l10n/app_ko.arb @@ -657,6 +657,7 @@ } } }, + "chat_selectSendAction": "전송 작업 선택", "chat_sendGif": "GIF 보내기", "chat_reply": "답변", "chat_addReaction": "댓글 추가", @@ -2890,7 +2891,7 @@ "channels_regionNotSet": "지역: 없음", "channels_regionSelect_Title": "지역을 선택하세요", "channels_clearRegion": "명확한 지역", - "chat_sendImage": "이미지를 보내세요", + "chat_sendImageLora": "MeshCore를 통해 이미지 보내기", "chat_imagePickFailed": "그 이미지를 열 수 없었어요.", "chat_receivedGif": "GIF를 받았습니다", "repeater_keySettings": "신원 키 변경", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 98983f83..a94fba29 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -334,6 +334,18 @@ abstract class AppLocalizations { /// **'Heard repeated'** String get messageStatus_repeated; + /// No description provided for @urlImage_enable. + /// + /// In en, this message translates to: + /// **'Enable URL images'** + String get urlImage_enable; + + /// No description provided for @urlImage_possible. + /// + /// In en, this message translates to: + /// **'Possible URL image; enable it in Settings.'** + String get urlImage_possible; + /// No description provided for @common_reboot. /// /// In en, this message translates to: @@ -2728,17 +2740,23 @@ abstract class AppLocalizations { /// **'Retry {current}/{max}'** String chat_retryCount(int current, int max); + /// No description provided for @chat_selectSendAction. + /// + /// In en, this message translates to: + /// **'Select send action'** + String get chat_selectSendAction; + /// No description provided for @chat_sendGif. /// /// In en, this message translates to: /// **'Send GIF'** String get chat_sendGif; - /// No description provided for @chat_sendImage. + /// No description provided for @chat_sendImageLora. /// /// In en, this message translates to: - /// **'Send image'** - String get chat_sendImage; + /// **'Send image via meshcore'** + String get chat_sendImageLora; /// Shown when picking or reading a photo to send fails /// @@ -2770,6 +2788,12 @@ abstract class AppLocalizations { /// **'Me'** String get chat_me; + /// No description provided for @reaction_report. + /// + /// In en, this message translates to: + /// **'Emoji Reactions'** + String get reaction_report; + /// No description provided for @emojiCategorySmileys. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 654e59db..d2048744 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -110,6 +110,12 @@ class AppLocalizationsBg extends AppLocalizations { @override String get messageStatus_repeated => 'Повторно чуто'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Рестартирай'; @@ -1489,11 +1495,14 @@ class AppLocalizationsBg extends AppLocalizations { return 'Опитай отново $current/$max'; } + @override + String get chat_selectSendAction => 'Изберете действие за изпращане'; + @override String get chat_sendGif => 'Изпрати GIF'; @override - String get chat_sendImage => 'Изпрати изображение'; + String get chat_sendImageLora => 'Изпращане на изображение чрез MeshCore'; @override String get chat_imagePickFailed => 'Не мог да откривам та изображин'; @@ -1510,6 +1519,9 @@ class AppLocalizationsBg extends AppLocalizations { @override String get chat_me => 'Аз'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Емотикони'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index c60adf27..82e9fabe 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -110,6 +110,13 @@ class AppLocalizationsDe extends AppLocalizations { @override String get messageStatus_repeated => 'Mehrfach gehört'; + @override + String get urlImage_enable => 'URL-Bilder anzeigen'; + + @override + String get urlImage_possible => + 'Mögliches URL-Bild; in den Einstellungen aktivieren.'; + @override String get common_reboot => 'Neustart'; @@ -1488,11 +1495,14 @@ class AppLocalizationsDe extends AppLocalizations { return 'Wiederholen $current/$max'; } + @override + String get chat_selectSendAction => 'Sendeaktion auswählen'; + @override String get chat_sendGif => 'GIF senden'; @override - String get chat_sendImage => 'Bild senden'; + String get chat_sendImageLora => 'Bild über MeshCore senden'; @override String get chat_imagePickFailed => 'Konnte dieses Bild nicht öffnen.'; @@ -1509,6 +1519,9 @@ class AppLocalizationsDe extends AppLocalizations { @override String get chat_me => 'Ich'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoticons'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index bca5bf50..e9d10f91 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -110,6 +110,12 @@ class AppLocalizationsEn extends AppLocalizations { @override String get messageStatus_repeated => 'Heard repeated'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Reboot'; @@ -1456,11 +1462,14 @@ class AppLocalizationsEn extends AppLocalizations { return 'Retry $current/$max'; } + @override + String get chat_selectSendAction => 'Select send action'; + @override String get chat_sendGif => 'Send GIF'; @override - String get chat_sendImage => 'Send image'; + String get chat_sendImageLora => 'Send image via meshcore'; @override String get chat_imagePickFailed => 'Couldn\'t open that image'; @@ -1477,6 +1486,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get chat_me => 'Me'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Smileys'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 3d05ba8c..6dbf2f0b 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -110,6 +110,12 @@ class AppLocalizationsEs extends AppLocalizations { @override String get messageStatus_repeated => 'Escuchado repetidamente'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Reiniciar'; @@ -1484,11 +1490,14 @@ class AppLocalizationsEs extends AppLocalizations { return 'Reintentar $current/$max'; } + @override + String get chat_selectSendAction => 'Seleccionar acción de envío'; + @override String get chat_sendGif => 'Enviar GIF'; @override - String get chat_sendImage => 'Enviar imagen'; + String get chat_sendImageLora => 'Enviar imagen mediante MeshCore'; @override String get chat_imagePickFailed => 'No pude abrir esa imagen'; @@ -1505,6 +1514,9 @@ class AppLocalizationsEs extends AppLocalizations { @override String get chat_me => 'Yo'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoticones'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 9b7a5ce1..8c18cfa4 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -110,6 +110,12 @@ class AppLocalizationsFr extends AppLocalizations { @override String get messageStatus_repeated => 'Reçu plusieurs fois'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Redémarrer'; @@ -1487,11 +1493,14 @@ class AppLocalizationsFr extends AppLocalizations { return 'Essai $current/$max'; } + @override + String get chat_selectSendAction => 'Sélectionner une action d’envoi'; + @override String get chat_sendGif => 'Envoyer un GIF'; @override - String get chat_sendImage => 'Envoyer l\'image'; + String get chat_sendImageLora => 'Envoyer une image via MeshCore'; @override String get chat_imagePickFailed => 'Je n\'ai pas pu ouvrir cette image'; @@ -1508,6 +1517,9 @@ class AppLocalizationsFr extends AppLocalizations { @override String get chat_me => 'Moi'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Émojis'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index fcca2849..2399a885 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -110,6 +110,12 @@ class AppLocalizationsHu extends AppLocalizations { @override String get messageStatus_repeated => '– ismételte Heard'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Indítsa újra'; @@ -1479,11 +1485,14 @@ class AppLocalizationsHu extends AppLocalizations { return 'Próbálja újra $current/$max'; } + @override + String get chat_selectSendAction => 'Küldési művelet kiválasztása'; + @override String get chat_sendGif => 'GIF küldése'; @override - String get chat_sendImage => 'Felhasználj az image'; + String get chat_sendImageLora => 'Kép küldése MeshCore-on keresztül'; @override String get chat_imagePickFailed => 'Nem tudtam ezt a fenti fényre kapni'; @@ -1500,6 +1509,9 @@ class AppLocalizationsHu extends AppLocalizations { @override String get chat_me => 'Nekem'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Hangulatjelek'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index ab592389..d37d7766 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -110,6 +110,12 @@ class AppLocalizationsIt extends AppLocalizations { @override String get messageStatus_repeated => 'Ricevuto ripetutamente'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Riavvia'; @@ -1487,11 +1493,14 @@ class AppLocalizationsIt extends AppLocalizations { return 'Riprova $current/$max'; } + @override + String get chat_selectSendAction => 'Seleziona azione di invio'; + @override String get chat_sendGif => 'Invia GIF'; @override - String get chat_sendImage => 'Invia immagine'; + String get chat_sendImageLora => 'Invia immagine tramite MeshCore'; @override String get chat_imagePickFailed => @@ -1509,6 +1518,9 @@ class AppLocalizationsIt extends AppLocalizations { @override String get chat_me => 'Io'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 0f412ac3..7ffd4a28 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -110,6 +110,12 @@ class AppLocalizationsJa extends AppLocalizations { @override String get messageStatus_repeated => '何度も聞いた'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => '再起動'; @@ -1412,11 +1418,14 @@ class AppLocalizationsJa extends AppLocalizations { return '$current/$max 回目'; } + @override + String get chat_selectSendAction => '送信アクションを選択'; + @override String get chat_sendGif => 'GIF を送信'; @override - String get chat_sendImage => '画像を送信'; + String get chat_sendImageLora => 'MeshCore経由で画像を送信'; @override String get chat_imagePickFailed => 'その画像を開けませんでした'; @@ -1433,6 +1442,9 @@ class AppLocalizationsJa extends AppLocalizations { @override String get chat_me => '私'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => '顔文字'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 02874cd6..68e7e84e 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -110,6 +110,12 @@ class AppLocalizationsKo extends AppLocalizations { @override String get messageStatus_repeated => '반복 수신됨'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => '재부팅'; @@ -1415,11 +1421,14 @@ class AppLocalizationsKo extends AppLocalizations { return '$current/$max 시도'; } + @override + String get chat_selectSendAction => '전송 작업 선택'; + @override String get chat_sendGif => 'GIF 보내기'; @override - String get chat_sendImage => '이미지를 보내세요'; + String get chat_sendImageLora => 'MeshCore를 통해 이미지 보내기'; @override String get chat_imagePickFailed => '그 이미지를 열 수 없었어요.'; @@ -1436,6 +1445,9 @@ class AppLocalizationsKo extends AppLocalizations { @override String get chat_me => '나'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => '이모티콘'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 997fb0e9..d5cbbf88 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -110,6 +110,12 @@ class AppLocalizationsNl extends AppLocalizations { @override String get messageStatus_repeated => 'Hearsay, herhaald'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Herstarten'; @@ -1474,11 +1480,14 @@ class AppLocalizationsNl extends AppLocalizations { return 'Poging opnieuw $current/$max'; } + @override + String get chat_selectSendAction => 'Verzendactie selecteren'; + @override String get chat_sendGif => 'GIF verzenden'; @override - String get chat_sendImage => 'Beeld verzenden'; + String get chat_sendImageLora => 'Afbeelding verzenden via MeshCore'; @override String get chat_imagePickFailed => 'Kunde die afbeelding niet openen'; @@ -1495,6 +1504,9 @@ class AppLocalizationsNl extends AppLocalizations { @override String get chat_me => 'Mijn'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji\'s'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 0119c220..0260d82d 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -110,6 +110,12 @@ class AppLocalizationsPl extends AppLocalizations { @override String get messageStatus_repeated => 'Usłyszałem to wielokrotnie'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Uruchom ponownie'; @@ -1497,11 +1503,14 @@ class AppLocalizationsPl extends AppLocalizations { return 'Próba $current/$max'; } + @override + String get chat_selectSendAction => 'Wybierz czynność wysyłania'; + @override String get chat_sendGif => 'Wyślij GIF'; @override - String get chat_sendImage => 'Wyślij obraz'; + String get chat_sendImageLora => 'Wyślij obraz przez MeshCore'; @override String get chat_imagePickFailed => 'Nie mogłem otworzyć tego obrazu'; @@ -1518,6 +1527,9 @@ class AppLocalizationsPl extends AppLocalizations { @override String get chat_me => 'Ja'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 46db1382..d9338356 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -110,6 +110,12 @@ class AppLocalizationsPt extends AppLocalizations { @override String get messageStatus_repeated => 'Ouvi repetidamente'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Reiniciar'; @@ -1483,11 +1489,14 @@ class AppLocalizationsPt extends AppLocalizations { return 'Tentar $current/$max'; } + @override + String get chat_selectSendAction => 'Selecionar ação de envio'; + @override String get chat_sendGif => 'Enviar GIF'; @override - String get chat_sendImage => 'Enviar imagem'; + String get chat_sendImageLora => 'Enviar imagem via MeshCore'; @override String get chat_imagePickFailed => 'Não consegui abrir essa imagem'; @@ -1504,6 +1513,9 @@ class AppLocalizationsPt extends AppLocalizations { @override String get chat_me => 'Eu'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emojis'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 7c34b4d3..58245ee8 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -110,6 +110,12 @@ class AppLocalizationsRu extends AppLocalizations { @override String get messageStatus_repeated => 'Услышал несколько раз'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Перезагрузить'; @@ -1487,11 +1493,14 @@ class AppLocalizationsRu extends AppLocalizations { return 'Попытка $current/$max'; } + @override + String get chat_selectSendAction => 'Выберите действие отправки'; + @override String get chat_sendGif => 'Отправить GIF'; @override - String get chat_sendImage => 'Отправьте изображение'; + String get chat_sendImageLora => 'Отправить изображение через MeshCore'; @override String get chat_imagePickFailed => 'Не удалось открыть это изображение'; @@ -1508,6 +1517,9 @@ class AppLocalizationsRu extends AppLocalizations { @override String get chat_me => 'Я'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Смайлы'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index da22d68b..82ef3eab 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -110,6 +110,12 @@ class AppLocalizationsSk extends AppLocalizations { @override String get messageStatus_repeated => 'Slyšal som to opakovane'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Restartovať'; @@ -1472,11 +1478,14 @@ class AppLocalizationsSk extends AppLocalizations { return 'Skúsiť $current/$max'; } + @override + String get chat_selectSendAction => 'Vybrať akciu odoslania'; + @override String get chat_sendGif => 'Odoslať GIF'; @override - String get chat_sendImage => 'Vyslat obraz'; + String get chat_sendImageLora => 'Odoslať obrázok cez MeshCore'; @override String get chat_imagePickFailed => 'Nesmiela jsem otvoriť tento obrázok'; @@ -1493,6 +1502,9 @@ class AppLocalizationsSk extends AppLocalizations { @override String get chat_me => 'Mne'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 2f886dc3..44576664 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -111,6 +111,12 @@ class AppLocalizationsSl extends AppLocalizations { @override String get messageStatus_repeated => 'Slišal sem večkrat'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Ponoviti'; @@ -1472,11 +1478,14 @@ class AppLocalizationsSl extends AppLocalizations { return 'Ponovit $current/$max'; } + @override + String get chat_selectSendAction => 'Izberite dejanje pošiljanja'; + @override String get chat_sendGif => 'Pošlji GIF'; @override - String get chat_sendImage => 'Sločaji slik'; + String get chat_sendImageLora => 'Pošlji sliko prek MeshCore'; @override String get chat_imagePickFailed => 'Nispeval sem tega ta slik'; @@ -1493,6 +1502,9 @@ class AppLocalizationsSl extends AppLocalizations { @override String get chat_me => 'jaz'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emoji'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 57d7b972..c1aece30 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -110,6 +110,12 @@ class AppLocalizationsSv extends AppLocalizations { @override String get messageStatus_repeated => 'Hördes upprepade gånger'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Start om'; @@ -1464,11 +1470,14 @@ class AppLocalizationsSv extends AppLocalizations { return 'Försök igen $current/$max'; } + @override + String get chat_selectSendAction => 'Välj sändningsåtgärd'; + @override String get chat_sendGif => 'Skicka GIF'; @override - String get chat_sendImage => 'Send vagnbild'; + String get chat_sendImageLora => 'Skicka bild via MeshCore'; @override String get chat_imagePickFailed => 'Kunde inte öppna det bildet'; @@ -1485,6 +1494,9 @@ class AppLocalizationsSv extends AppLocalizations { @override String get chat_me => 'Mig'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Emojis'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index b4b913c9..4dd461df 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -110,6 +110,12 @@ class AppLocalizationsUk extends AppLocalizations { @override String get messageStatus_repeated => 'Почув неодноразово'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => 'Перезавантажити'; @@ -1477,12 +1483,14 @@ class AppLocalizationsUk extends AppLocalizations { return 'Повторна спроба $current/$max'; } + @override + String get chat_selectSendAction => 'Виберіть дію надсилання'; + @override String get chat_sendGif => 'Надіслати GIF'; @override - String get chat_sendImage => - 'Нашкоду зовні\n\n(or more naturally, depending on context)\n\nПошукуєте изображення'; + String get chat_sendImageLora => 'Надіслати зображення через MeshCore'; @override String get chat_imagePickFailed => 'Неможливо відкрити це изображення'; @@ -1499,6 +1507,9 @@ class AppLocalizationsUk extends AppLocalizations { @override String get chat_me => 'Я'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => 'Емодзі'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index c3a0dfc9..64be13aa 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -110,6 +110,12 @@ class AppLocalizationsZh extends AppLocalizations { @override String get messageStatus_repeated => '多次听到'; + @override + String get urlImage_enable => 'Enable URL images'; + + @override + String get urlImage_possible => 'Possible URL image; enable it in Settings.'; + @override String get common_reboot => '重启'; @@ -1398,11 +1404,14 @@ class AppLocalizationsZh extends AppLocalizations { return '重试 $current/$max'; } + @override + String get chat_selectSendAction => '选择发送操作'; + @override String get chat_sendGif => '发送 GIF'; @override - String get chat_sendImage => '发送图片'; + String get chat_sendImageLora => '通过 MeshCore 发送图片'; @override String get chat_imagePickFailed => '无法打开该图片'; @@ -1419,6 +1428,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get chat_me => '我'; + @override + String get reaction_report => 'Emoji Reactions'; + @override String get emojiCategorySmileys => '表情'; diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index 11688370..eda38c12 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -485,6 +485,7 @@ } } }, + "chat_selectSendAction": "Verzendactie selecteren", "chat_sendGif": "GIF verzenden", "chat_reply": "Reageren", "chat_addReaction": "Reactie toevoegen", @@ -2756,7 +2757,7 @@ "channels_regionNotSet": "Regio: geen", "channels_regionSelect_Title": "Kies een regio", "channels_clearRegion": "Duidelijke regio", - "chat_sendImage": "Beeld verzenden", + "chat_sendImageLora": "Afbeelding verzenden via MeshCore", "chat_imagePickFailed": "Kunde die afbeelding niet openen", "chat_receivedGif": "Ontvangen van een GIF", "repeater_keySettings": "Verander de Identiteitskies", diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index f5dab677..6f1811f8 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -495,6 +495,7 @@ } } }, + "chat_selectSendAction": "Wybierz czynność wysyłania", "chat_sendGif": "Wyślij GIF", "chat_reply": "Odpowiedz", "chat_addReaction": "Dodaj Reakcję", @@ -2794,7 +2795,7 @@ "channels_regionNotSet": "Region: brak", "channels_regionSelect_Title": "Wybierz region", "channels_clearRegion": "Przejrzyste obszar", - "chat_sendImage": "Wyślij obraz", + "chat_sendImageLora": "Wyślij obraz przez MeshCore", "chat_imagePickFailed": "Nie mogłem otworzyć tego obrazu", "chat_receivedGif": "Otrzymano GIF", "repeater_keySettings": "Zmiana kluczy tożsamości", diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index 32364c5a..e0da74bb 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -485,6 +485,7 @@ } } }, + "chat_selectSendAction": "Selecionar ação de envio", "chat_sendGif": "Enviar GIF", "chat_reply": "Responder", "chat_addReaction": "Adicionar Reação", @@ -2756,7 +2757,7 @@ "channels_regionNotSet": "Região: nenhuma", "channels_regionSelect_Title": "Escolha uma região", "channels_clearRegion": "Região desimpedida", - "chat_sendImage": "Enviar imagem", + "chat_sendImageLora": "Enviar imagem via MeshCore", "chat_imagePickFailed": "Não consegui abrir essa imagem", "chat_receivedGif": "Recebi um GIF", "repeater_keySettings": "Alterar Chaves de Identidade", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index 614e0201..f34a52e5 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -316,6 +316,7 @@ "chat_messageDeleted": "Сообщение удалено", "chat_retryingMessage": "Повтор отправки сообщения", "chat_retryCount": "Попытка {current}/{max}", + "chat_selectSendAction": "Выберите действие отправки", "chat_sendGif": "Отправить GIF", "chat_reply": "Ответить", "chat_addReaction": "Добавить реакцию", @@ -2059,7 +2060,7 @@ "channels_regionNotSet": "Регион: отсутствует", "channels_regionSelect_Title": "Выберите регион", "channels_clearRegion": "Чистый регион", - "chat_sendImage": "Отправьте изображение", + "chat_sendImageLora": "Отправить изображение через MeshCore", "chat_imagePickFailed": "Не удалось открыть это изображение", "chat_receivedGif": "Получен GIF", "repeater_keySettings": "Изменить ключи идентичности", diff --git a/lib/l10n/app_sk.arb b/lib/l10n/app_sk.arb index 7b217e67..83f4147b 100644 --- a/lib/l10n/app_sk.arb +++ b/lib/l10n/app_sk.arb @@ -485,6 +485,7 @@ } } }, + "chat_selectSendAction": "Vybrať akciu odoslania", "chat_sendGif": "Odoslať GIF", "chat_reply": "Odpovedať", "chat_addReaction": "Pridať Reakciu", @@ -2756,7 +2757,7 @@ "channels_regionNotSet": "Region: žiadné", "channels_regionSelect_Title": "Vyberte region", "channels_clearRegion": "Jasný údajný oblasť", - "chat_sendImage": "Vyslat obraz", + "chat_sendImageLora": "Odoslať obrázok cez MeshCore", "chat_imagePickFailed": "Nesmiela jsem otvoriť tento obrázok", "chat_receivedGif": "Odeslaný GIF", "repeater_keySettings": "Zmena identititačných klíčov", diff --git a/lib/l10n/app_sl.arb b/lib/l10n/app_sl.arb index 868d92d8..1c70803f 100644 --- a/lib/l10n/app_sl.arb +++ b/lib/l10n/app_sl.arb @@ -485,6 +485,7 @@ } } }, + "chat_selectSendAction": "Izberite dejanje pošiljanja", "chat_sendGif": "Pošlji GIF", "chat_reply": "Odgovori", "chat_addReaction": "Dodaj reakcijo", @@ -2756,7 +2757,7 @@ "channels_regionNotSet": "Region: brak", "channels_regionSelect_Title": "Vablajte region", "channels_clearRegion": "Jasna regija", - "chat_sendImage": "Sločaji slik", + "chat_sendImageLora": "Pošlji sliko prek MeshCore", "chat_imagePickFailed": "Nispeval sem tega ta slik", "chat_receivedGif": "Otrvljen GIF", "repeater_keySettings": "Zmeničke ključe identitete", diff --git a/lib/l10n/app_sv.arb b/lib/l10n/app_sv.arb index 33128c4b..25a136b8 100644 --- a/lib/l10n/app_sv.arb +++ b/lib/l10n/app_sv.arb @@ -485,6 +485,7 @@ } } }, + "chat_selectSendAction": "Välj sändningsåtgärd", "chat_sendGif": "Skicka GIF", "chat_reply": "Svara", "chat_addReaction": "Lägg till reaktion", @@ -2756,7 +2757,7 @@ "channels_regionNotSet": "Region: ingen", "channels_regionSelect_Title": "Välj en region", "channels_clearRegion": "klar region", - "chat_sendImage": "Send vagnbild", + "chat_sendImageLora": "Skicka bild via MeshCore", "chat_imagePickFailed": "Kunde inte öppna det bildet", "chat_receivedGif": "Mottagit en GIF", "repeater_keySettings": "Ändra identitetsnyckel", diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index 3dccd6e3..2e5e3de2 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -488,6 +488,7 @@ } } }, + "chat_selectSendAction": "Виберіть дію надсилання", "chat_sendGif": "Надіслати GIF", "chat_reply": "Відповісти", "chat_addReaction": "Додати реакцію", @@ -2736,7 +2737,7 @@ "channels_regionNotSet": "Ріон: нема", "channels_regionSelect_Title": "Вybірте регіон", "channels_clearRegion": "Чистя зона", - "chat_sendImage": "Нашкоду зовні\n\n(or more naturally, depending on context)\n\nПошукуєте изображення", + "chat_sendImageLora": "Надіслати зображення через MeshCore", "chat_imagePickFailed": "Неможливо відкрити це изображення", "chat_receivedGif": "Підймовано GIF", "repeater_keySettings": "Зміна ключів ідентифікації", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 4aabd445..56989f27 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -512,6 +512,7 @@ } } }, + "chat_selectSendAction": "选择发送操作", "chat_sendGif": "发送 GIF", "chat_reply": "回复", "chat_addReaction": "添加表情", @@ -2761,7 +2762,7 @@ "channels_regionNotSet": "地区:无", "channels_regionSelect_Title": "选择一个地区", "channels_clearRegion": "无碍区域", - "chat_sendImage": "发送图片", + "chat_sendImageLora": "通过 MeshCore 发送图片", "chat_imagePickFailed": "无法打开该图片", "chat_receivedGif": "收到一个GIF", "repeater_keySettings": "更改身份密钥", diff --git a/lib/models/channel_message.dart b/lib/models/channel_message.dart index 0113c807..56bf4849 100644 --- a/lib/models/channel_message.dart +++ b/lib/models/channel_message.dart @@ -50,7 +50,7 @@ class ChannelMessage { final String? replyToMessageId; final String? replyToSenderName; final String? replyToText; - final Map reactions; + final Map> reactions; ChannelMessage({ this.senderKey, @@ -76,7 +76,7 @@ class ChannelMessage { this.replyToMessageId, this.replyToSenderName, this.replyToText, - Map? reactions, + Map>? reactions, }) : messageId = messageId ?? '${timestamp.millisecondsSinceEpoch}_${senderName.hashCode}_${text.hashCode}', @@ -107,7 +107,7 @@ class ChannelMessage { Object? translatedLanguageCode = _unset, MessageTranslationStatus? translationStatus, Object? translationModelId = _unset, - Map? reactions, + Map>? reactions, }) { return ChannelMessage( senderKey: senderKey, @@ -297,8 +297,32 @@ class ChannelMessage { ); } - static ReactionInfo? parseReaction(String text) { - return ReactionHelper.parseReaction(text); + ReactionInfo? parseReaction() { + final reactionInfo = ReactionHelper.parseReaction(text); + reactionInfo?.senderName = senderName; + return reactionInfo; + } + + String computeReactionHash() { + return ReactionHelper.computeReactionHash( + timestamp.millisecondsSinceEpoch ~/ 1000, + senderName, + text, + ); + } + + List reactionList() { + final String hash = computeReactionHash(); + List reactionList = []; + for (final entry in reactions.entries) { + final emoji = entry.key; + for (final senderName in entry.value) { + reactionList.add( + ReactionInfo(targetHash: hash, emoji: emoji, senderName: senderName), + ); + } + } + return reactionList; } } diff --git a/lib/models/message.dart b/lib/models/message.dart index e1395617..a9b7c0cd 100644 --- a/lib/models/message.dart +++ b/lib/models/message.dart @@ -8,7 +8,7 @@ enum MessageStatus { pending, sent, delivered, failed } class Message { static const Object _unset = Object(); - final Uint8List senderKey; + final Uint8List senderKey; // For outgoing msgs, gets used as recipientKey final String text; final DateTime timestamp; final bool isOutgoing; @@ -30,7 +30,7 @@ class Message { final int? tripTimeMs; final int? pathLength; final Uint8List pathBytes; - final Map reactions; + final Map> reactions; final Map reactionStatuses; final Uint8List fourByteRoomContactKey; @@ -56,7 +56,7 @@ class Message { this.pathLength, Uint8List? pathBytes, Uint8List? fourByteRoomContactKey, - Map? reactions, + Map>? reactions, Map? reactionStatuses, }) : messageId = messageId ?? @@ -84,7 +84,7 @@ class Message { Object? translatedLanguageCode = _unset, MessageTranslationStatus? translationStatus, Object? translationModelId = _unset, - Map? reactions, + Map>? reactions, Map? reactionStatuses, Uint8List? fourByteRoomContactKey, }) { diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index f2332964..fc8a4460 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -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/message_url_image_helper.dart'; import '../helpers/path_helper.dart'; import '../helpers/reaction_helper.dart'; import '../helpers/snack_bar_builder.dart'; @@ -41,7 +42,6 @@ import '../widgets/emoji_picker.dart'; import '../widgets/gif_message.dart'; import '../widgets/jump_to_bottom_button.dart'; import '../widgets/gif_picker.dart'; -import '../widgets/image_send_button.dart'; import '../widgets/image_send_codec_binding.dart'; import '../widgets/image_send_preview_sheet.dart'; import '../widgets/message_translation_button.dart'; @@ -413,6 +413,9 @@ class _ChannelChatScreenState extends State { ); } + final urlImagesEnabled = connector.isChannelUrlImagesEnabled( + widget.channel.index, + ); // Images are not ChannelMessages: they arrive as GRP_DATA // chunks and are owned by ReceivedImageStore, so the two // sources are merged here in timestamp order and the list @@ -501,7 +504,11 @@ class _ChannelChatScreenState extends State { ); final message = row.message; final bubble = message != null - ? _buildMessageBubble(message, textScale) + ? _buildMessageBubble( + message, + textScale, + urlImagesEnabled, + ) : _buildImageBubble( row.image!, textScale, @@ -525,7 +532,7 @@ class _ChannelChatScreenState extends State { }, ), ), - _buildMessageComposer(), + _buildInputBar(), ], ), ), @@ -544,7 +551,11 @@ class _ChannelChatScreenState extends State { connector.setChannelUnreadCount(widget.channel.index, count); } - Widget _buildMessageBubble(ChannelMessage message, double textScale) { + Widget _buildMessageBubble( + ChannelMessage message, + double textScale, + bool urlImagesEnabled, + ) { final settingsService = context.watch(); final enableTracing = settingsService.settings.enableMessageTracing; final isOutgoing = message.isOutgoing; @@ -584,6 +595,33 @@ class _ChannelChatScreenState extends State { final metaColor = textColor.withValues(alpha: 0.65); const bodyFontSize = 14.0; + Widget buildTextContent() { + return Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Flexible( + child: TranslatedMessageContent( + displayText: translatedDisplayText, + originalText: originalDisplayText, + style: TextStyle( + color: textColor, + fontSize: bodyFontSize * textScale, + ), + originalStyle: TextStyle( + fontSize: bodyFontSize * textScale, + fontStyle: FontStyle.italic, + color: textColor.withValues(alpha: 0.72), + ), + onSecondaryTap: PlatformInfo.isDesktop + ? () => _showMessageActions(message) + : null, + ), + ), + ], + ); + } + // Asymmetric radius matching chat_screen bubbles. final borderRadius = isOutgoing ? const BorderRadius.only( @@ -689,29 +727,76 @@ class _ChannelChatScreenState extends State { ), ], ) + else if (urlImagesEnabled) + MessageUrlImageFutureBuilder( + messageId: message.messageId, + text: message.text, + builder: (context, snapshot) { + final imageAttachment = snapshot.data; + + if (imageAttachment != null) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 4, + ), + child: Align( + alignment: isOutgoing + ? Alignment.centerRight + : Alignment.centerLeft, + child: MessageUrlImagePreview( + imageUrl: imageAttachment, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 8), + child: TranslatedMessageContent( + displayText: translatedDisplayText, + originalText: originalDisplayText, + style: TextStyle( + color: textColor, + fontSize: bodyFontSize * textScale, + ), + originalStyle: TextStyle( + fontSize: bodyFontSize * textScale, + fontStyle: FontStyle.italic, + color: textColor.withValues( + alpha: 0.72, + ), + ), + onSecondaryTap: PlatformInfo.isDesktop + ? () => _showMessageActions(message) + : null, + ), + ), + ], + ); + } + + return buildTextContent(); + }, + ) else - Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Flexible( - child: TranslatedMessageContent( - displayText: translatedDisplayText, - originalText: originalDisplayText, - style: TextStyle( - color: textColor, - fontSize: bodyFontSize * textScale, + if (MessageUrlImageHelper.hasPotentialImageUrl( + message.text, + )) + Padding( + padding: const EdgeInsets.only(bottom: 4), + child: Text( + context.l10n.urlImage_possible, + style: TextStyle( + color: metaColor, + fontSize: 11 * textScale, + ), ), - originalStyle: TextStyle( - fontSize: bodyFontSize * textScale, - fontStyle: FontStyle.italic, - color: textColor.withValues(alpha: 0.72), - ), - onSecondaryTap: PlatformInfo.isDesktop - ? () => _showMessageActions(message) - : null, ), - ), + buildTextContent(), ], ), if (enableTracing && displayPath.isNotEmpty) ...[ @@ -961,7 +1046,7 @@ class _ChannelChatScreenState extends State { runSpacing: 6, children: message.reactions.entries.map((entry) { final emoji = entry.key; - final count = entry.value; + final int count = entry.value.length; return Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), @@ -970,35 +1055,97 @@ class _ChannelChatScreenState extends State { borderRadius: BorderRadius.circular(MeshRadii.pill), border: Border.all(color: scheme.outlineVariant, width: 1), ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - emoji, - style: MeshTheme.emoji(fontSize: 16), - textHeightBehavior: const TextHeightBehavior( - applyHeightToFirstAscent: false, - applyHeightToLastDescent: false, - ), - ), - if (count > 1) ...[ - const SizedBox(width: 4), + child: InkWell( + onTap: () => _showReactionsReport(message), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ Text( - '$count', - style: MeshTheme.mono( - fontSize: 11, - fontWeight: FontWeight.w700, - color: scheme.onSurface, + emoji, + style: MeshTheme.emoji(fontSize: 16), + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, ), ), + if (count > 1) ...[ + const SizedBox(width: 4), + Text( + '$count', + style: MeshTheme.mono( + fontSize: 11, + fontWeight: FontWeight.w700, + color: scheme.onSurface, + ), + ), + ], ], - ], + ), ), ); }).toList(), ); } + void _showReactionsReport(ChannelMessage message) { + final scheme = Theme.of(context).colorScheme; + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(context.l10n.reaction_report), + content: SizedBox( + width: double.maxFinite, + child: Scrollbar( + child: ListView( + shrinkWrap: true, + padding: const EdgeInsets.symmetric(vertical: 4), + children: message.reactionList().map((reaction) { + return Container( + padding: const EdgeInsetsDirectional.symmetric(vertical: 4), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + decoration: BoxDecoration( + color: scheme.surfaceContainerHigh, + borderRadius: BorderRadius.circular(MeshRadii.pill), + border: Border.all( + color: scheme.outlineVariant, + width: 1, + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + reaction.emoji, + style: MeshTheme.emoji(fontSize: 16), + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + ), + ), + const SizedBox(width: 12), + Expanded(child: Text(reaction.senderName ?? '???')), + ], + ), + ), + ), + ); + }).toList(), + ), + ), + ), + ), + ); + } + Widget _buildPoiMessage( BuildContext context, MarkerPayload poi, @@ -1079,10 +1226,9 @@ class _ChannelChatScreenState extends State { /// Whether the image codec model is currently downloading. /// - /// The image button must stay hidden while the model downloads: an encode - /// cannot start until the weights are on disk, and the preview sheet would - /// have nothing to show but a spinner. - bool get _imageCodecDownloading { + /// This must be read while [context] is building; popup item builders run + /// from an overlay and cannot listen to a provider. + bool _isImageCodecDownloading(BuildContext context) { try { return context.watch().isDownloading; } on ProviderNotFoundException { @@ -1603,41 +1749,84 @@ class _ChannelChatScreenState extends State { ); } - Widget _buildMessageComposer() { + Widget _buildInputBar() { final connector = context.watch(); final maxBytes = maxChannelMessageBytes(connector.selfName); final settings = context.watch().settings; + final imageCodecDownloading = _isImageCodecDownloading(context); + final showImageAction = + settings.imageMessagesEnabled && !imageCodecDownloading; final scheme = Theme.of(context).colorScheme; - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (_replyingToMessage != null) - Builder( - builder: (context) { - final textScale = context.select( - (service) => service.scale, - ); - return _buildReplyBanner(textScale); - }, - ), - if (_imageSendTotal > 0) _buildImageSendProgress(scheme), - Container( - decoration: BoxDecoration( - color: scheme.surface, - border: Border( - top: BorderSide(color: scheme.outlineVariant, width: 1), - ), - ), - child: SafeArea( - child: Padding( + return Container( + decoration: BoxDecoration( + color: scheme.surface, + border: Border(top: BorderSide(color: scheme.outlineVariant, width: 1)), + ), + child: SafeArea( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (_replyingToMessage != null) + Builder( + builder: (context) { + final textScale = context + .select( + (service) => service.scale, + ); + return _buildReplyBanner(textScale); + }, + ), + if (_imageSendTotal > 0) _buildImageSendProgress(scheme), + Padding( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - IconButton( - icon: const Icon(Icons.gif_box), - onPressed: () => _showGifPicker(context), - tooltip: context.l10n.chat_sendGif, + PopupMenuButton( + icon: const Icon(Icons.add_circle_outline), + position: PopupMenuPosition.over, + offset: Offset(0, showImageAction ? -112 : -64), + tooltip: context.l10n.chat_selectSendAction, + onSelected: (action) { + switch (action) { + case 'gif': + _showGifPicker(context); + break; + case 'meshcore-image': + _showImageSendPreview(); + break; + } + }, + itemBuilder: (context) => [ + PopupMenuItem( + value: 'gif', + child: Row( + children: [ + const Icon(Icons.gif_box), + const SizedBox(width: 12), + Text(context.l10n.chat_sendGif), + ], + ), + ), + if (showImageAction) + PopupMenuItem( + value: 'meshcore-image', + // Gated on the codec, not just the setting. The preview + // sheet explains why a send is impossible, but a fully + // live button in a build that cannot encode invites the + // tap that produces that explanation. + enabled: + _imageCodec?.availability == + ImageCodecAvailability.ready, + child: Row( + children: [ + const Icon(Icons.image_outlined), + const SizedBox(width: 12), + Text(context.l10n.chat_sendImageLora), + ], + ), + ), + ], ), if (settings.translationEnabled) MessageTranslationButton( @@ -1645,17 +1834,6 @@ class _ChannelChatScreenState extends State { languageCode: settings.translationTargetLanguageCode, onPressed: _showTranslationOptions, ), - if (settings.imageMessagesEnabled && !_imageCodecDownloading) - ImageSendButton( - // Gated on the codec, not just the setting. The preview - // sheet explains why a send is impossible, but a fully - // live button in a build that cannot encode invites the - // tap that produces that explanation. - enabled: - _imageCodec?.availability == - ImageCodecAvailability.ready, - onPressed: () => _showImageSendPreview(), - ), Expanded( child: ValueListenableBuilder( valueListenable: _textController, @@ -1787,9 +1965,9 @@ class _ChannelChatScreenState extends State { ], ), ), - ), + ], ), - ], + ), ); } @@ -2037,12 +2215,7 @@ class _ChannelChatScreenState extends State { final connector = context.read(); final emojiIndex = ReactionHelper.emojiToIndex(emoji); if (emojiIndex == null) return; // Unknown emoji, skip - final timestampSecs = message.timestamp.millisecondsSinceEpoch ~/ 1000; - final hash = ReactionHelper.computeReactionHash( - timestampSecs, - message.senderName, - message.text, - ); + final hash = message.computeReactionHash(); final reactionText = ReactionHelper.encodeReaction(hash, emojiIndex); connector.sendChannelMessage(widget.channel, reactionText); } diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index 1867f5de..74c07c0c 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -1533,6 +1533,7 @@ class _ChannelsScreenState extends State final pskController = TextEditingController(text: channel.pskHex); bool smazEnabled = connector.isChannelSmazEnabled(channel.index); bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index); + bool urlImagesEnabled = connector.isChannelUrlImagesEnabled(channel.index); String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId( channel.index, ); @@ -1635,6 +1636,13 @@ class _ChannelsScreenState extends State ), ), ], + SwitchListTile( + contentPadding: EdgeInsets.zero, + title: Text(sheetContext.l10n.urlImage_enable), + value: urlImagesEnabled, + onChanged: (value) => + setSheetState(() => urlImagesEnabled = value), + ), const SizedBox(height: 24), ], ), @@ -1684,6 +1692,10 @@ class _ChannelsScreenState extends State channel.index, cyr2latEnabled, ); + await connector.setChannelUrlImagesEnabled( + channel.index, + urlImagesEnabled, + ); await connector.setChannelCyr2LatProfileId( channel.index, selectedCyr2LatProfileId, diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index bafa5f25..6c1f306f 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -7,11 +7,13 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; +import '../utils/app_logger.dart'; import '../utils/platform_info.dart'; import '../connector/meshcore_connector.dart'; import '../connector/meshcore_protocol.dart'; import '../helpers/cyr2lat.dart'; +import '../helpers/message_url_image_helper.dart'; import '../helpers/path_helper.dart'; import '../helpers/reaction_helper.dart'; import '../widgets/message_status_icon.dart'; @@ -477,10 +479,26 @@ class _ChatScreenState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - IconButton( - icon: const Icon(Icons.gif_box), - onPressed: () => _showGifPicker(context), - tooltip: context.l10n.chat_sendGif, + PopupMenuButton( + icon: const Icon(Icons.add_circle_outline), + position: PopupMenuPosition.over, + offset: const Offset(0, -64), + tooltip: context.l10n.chat_selectSendAction, + onSelected: (action) { + if (action == 'gif') _showGifPicker(context); + }, + itemBuilder: (context) => [ + PopupMenuItem( + value: 'gif', + child: Row( + children: [ + const Icon(Icons.gif_box), + const SizedBox(width: 12), + Text(context.l10n.chat_sendGif), + ], + ), + ), + ], ), if (settings.translationEnabled) MessageTranslationButton( @@ -878,6 +896,9 @@ class _ChatScreenState extends State { bool cyr2latEnabled = connector.isContactCyr2LatEnabled( contact.publicKeyHex, ); + bool urlImagesEnabled = connector.isContactUrlImagesEnabled( + contact.publicKeyHex, + ); String? selectedCyr2LatProfileId = connector.getContactCyr2LatProfileId( contact.publicKeyHex, ); @@ -977,6 +998,19 @@ class _ChatScreenState extends State { ), ], const Divider(height: 8), + SwitchListTile( + contentPadding: EdgeInsets.zero, + title: Text(context.l10n.urlImage_enable), + value: urlImagesEnabled, + onChanged: (value) { + connector.setContactUrlImagesEnabled( + contact.publicKeyHex, + value, + ); + setDialogState(() => urlImagesEnabled = value); + }, + ), + const Divider(height: 8), SwitchListTile( contentPadding: EdgeInsets.zero, title: Text(context.l10n.contact_teleBase), @@ -1281,6 +1315,7 @@ class _ChatScreenState extends State { final senderName = liveContact.type == advTypeRoom ? senderContact.name : null; + appLogger.info('Sending reaction using senderName: $senderName'); final hash = ReactionHelper.computeReactionHash( timestampSecs, senderName, @@ -1317,6 +1352,9 @@ class _MessageBubble extends StatelessWidget { final gifId = GifHelper.parseGif(message.text); final poi = parseMarkerText(message.text); final isFailed = message.status == MessageStatus.failed; + final urlImagesEnabled = context.select( + (connector) => connector.isContactUrlImagesEnabled(sourceId), + ); // Bubble colors — outgoing uses MeshPalette.me / meBorder / meInk. final bubbleColor = isFailed @@ -1364,6 +1402,30 @@ class _MessageBubble extends StatelessWidget { ? message.originalText : (translatedDisplayText != messageText ? messageText : null); + Widget buildTextContent() { + return Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Flexible( + child: TranslatedMessageContent( + displayText: translatedDisplayText, + originalText: originalDisplayText, + style: TextStyle( + color: textColor, + fontSize: bodyFontSize * textScale, + ), + originalStyle: TextStyle( + color: textColor.withValues(alpha: 0.72), + fontSize: bodyFontSize * textScale, + ), + onSecondaryTap: PlatformInfo.isDesktop ? onLongPress : null, + ), + ), + ], + ); + } + return Padding( padding: const EdgeInsets.symmetric(vertical: 3), child: Column( @@ -1451,28 +1513,76 @@ class _MessageBubble extends StatelessWidget { ), ], ) + else if (urlImagesEnabled) + MessageUrlImageFutureBuilder( + messageId: message.messageId, + text: message.text, + builder: (context, snapshot) { + final imageAttachment = snapshot.data; + + if (imageAttachment != null) { + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 4, + ), + child: Align( + alignment: isOutgoing + ? Alignment.centerRight + : Alignment.centerLeft, + child: MessageUrlImagePreview( + imageUrl: imageAttachment, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 8), + child: TranslatedMessageContent( + displayText: translatedDisplayText, + originalText: originalDisplayText, + style: TextStyle( + color: textColor, + fontSize: bodyFontSize * textScale, + ), + originalStyle: TextStyle( + color: textColor.withValues( + alpha: 0.72, + ), + fontSize: bodyFontSize * textScale, + ), + onSecondaryTap: PlatformInfo.isDesktop + ? onLongPress + : null, + ), + ), + ], + ); + } + + return buildTextContent(); + }, + ) else - Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Flexible( - child: TranslatedMessageContent( - displayText: translatedDisplayText, - originalText: originalDisplayText, - style: TextStyle( - color: textColor, - fontSize: bodyFontSize * textScale, + if (MessageUrlImageHelper.hasPotentialImageUrl( + message.text, + )) + Padding( + padding: const EdgeInsets.only(bottom: 4), + child: Text( + context.l10n.urlImage_possible, + style: TextStyle( + color: metaColor, + fontSize: 11 * textScale, + ), ), - originalStyle: TextStyle( - color: textColor.withValues(alpha: 0.72), - fontSize: bodyFontSize * textScale, - ), - onSecondaryTap: PlatformInfo.isDesktop - ? onLongPress - : null, ), - ), + buildTextContent(), ], ), if (enableTracing && @@ -1654,7 +1764,7 @@ class _MessageBubble extends StatelessWidget { runSpacing: 6, children: message.reactions.entries.map((entry) { final emoji = entry.key; - final count = entry.value; + final count = entry.value.length; final status = message.reactionStatuses[emoji]; final isPending = status == MessageStatus.pending || status == MessageStatus.sent; diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index 05ebf6b0..e2cad357 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -3,7 +3,9 @@ import 'dart:ui'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter/foundation.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; +import '../helpers/message_url_image_helper.dart'; import '../helpers/reaction_helper.dart'; import '../l10n/app_localizations.dart'; import '../utils/platform_info.dart'; @@ -196,14 +198,40 @@ class NotificationService { return text; } + Future _resolveNotificationImagePath( + String text, { + required bool urlImagesEnabled, + }) async { + if (!urlImagesEnabled) return null; + + final imageUrl = await MessageUrlImageHelper.parseVerified(text); + if (imageUrl == null) return null; + + try { + // Cache the image so notification platforms can read it from disk. + final imageFile = await DefaultCacheManager().getSingleFile(imageUrl); + if (!imageFile.existsSync()) return null; + return imageFile.path; + } catch (e) { + debugPrint('Failed to resolve notification image: $e'); + return null; + } + } + Future _showMessageNotificationImpl({ required String contactName, required String message, + required bool urlImagesEnabled, String? contactId, int? badgeCount, }) async { if (!await _ensureCanNotify()) return; + final imagePath = await _resolveNotificationImagePath( + message, + urlImagesEnabled: urlImagesEnabled, + ); + final androidDetails = AndroidNotificationDetails( 'messages', 'Messages', @@ -212,6 +240,12 @@ class NotificationService { priority: Priority.high, icon: '@mipmap/ic_launcher', number: badgeCount, + styleInformation: imagePath != null + ? BigPictureStyleInformation( + FilePathAndroidBitmap(imagePath), + summaryText: formatNotificationText(message), + ) + : null, ); final iosDetails = DarwinNotificationDetails( @@ -219,6 +253,11 @@ class NotificationService { presentBadge: true, presentSound: true, badgeNumber: badgeCount, + attachments: imagePath != null + ? [ + DarwinNotificationAttachment(imagePath), + ] + : null, ); final macDetails = DarwinNotificationDetails( @@ -226,6 +265,11 @@ class NotificationService { presentBadge: true, presentSound: true, badgeNumber: badgeCount, + attachments: imagePath != null + ? [ + DarwinNotificationAttachment(imagePath), + ] + : null, ); final notificationDetails = NotificationDetails( @@ -299,11 +343,17 @@ class NotificationService { Future _showChannelMessageNotificationImpl({ required String channelName, required String message, + required bool urlImagesEnabled, int? channelIndex, int? badgeCount, }) async { if (!await _ensureCanNotify()) return; + final imagePath = await _resolveNotificationImagePath( + message, + urlImagesEnabled: urlImagesEnabled, + ); + final androidDetails = AndroidNotificationDetails( 'channel_messages', 'Channel Messages', @@ -312,6 +362,12 @@ class NotificationService { priority: Priority.high, icon: '@mipmap/ic_launcher', number: badgeCount, + styleInformation: imagePath != null + ? BigPictureStyleInformation( + FilePathAndroidBitmap(imagePath), + summaryText: formatNotificationText(message), + ) + : null, ); final iosDetails = DarwinNotificationDetails( @@ -319,6 +375,11 @@ class NotificationService { presentBadge: true, presentSound: true, badgeNumber: badgeCount, + attachments: imagePath != null + ? [ + DarwinNotificationAttachment(imagePath), + ] + : null, ); final macDetails = DarwinNotificationDetails( @@ -326,6 +387,11 @@ class NotificationService { presentBadge: true, presentSound: true, badgeNumber: badgeCount, + attachments: imagePath != null + ? [ + DarwinNotificationAttachment(imagePath), + ] + : null, ); final notificationDetails = NotificationDetails( @@ -448,6 +514,7 @@ class NotificationService { Future showMessageNotification({ required String contactName, required String message, + required bool urlImagesEnabled, String? contactId, int? badgeCount, }) async { @@ -458,6 +525,7 @@ class NotificationService { type: _NotificationType.message, title: contactName, body: message, + urlImagesEnabled: urlImagesEnabled, id: contactId, badgeCount: badgeCount, ), @@ -485,6 +553,7 @@ class NotificationService { required String channelName, required String senderName, required String message, + required bool urlImagesEnabled, int? channelIndex, int? badgeCount, }) async { @@ -495,6 +564,7 @@ class NotificationService { type: _NotificationType.channelMessage, title: channelName, body: '$senderName: $message', + urlImagesEnabled: urlImagesEnabled, id: channelIndex?.toString(), badgeCount: badgeCount, ), @@ -556,6 +626,7 @@ class NotificationService { await _showMessageNotificationImpl( contactName: notification.title, message: notification.body, + urlImagesEnabled: notification.urlImagesEnabled, contactId: notification.id, badgeCount: notification.badgeCount, ); @@ -571,6 +642,7 @@ class NotificationService { await _showChannelMessageNotificationImpl( channelName: notification.title, message: notification.body, + urlImagesEnabled: notification.urlImagesEnabled, channelIndex: int.tryParse(notification.id ?? ''), badgeCount: notification.badgeCount, ); @@ -647,6 +719,7 @@ class _PendingNotification { final _NotificationType type; final String title; final String body; + final bool urlImagesEnabled; final String? id; final int? badgeCount; @@ -654,6 +727,7 @@ class _PendingNotification { required this.type, required this.title, required this.body, + this.urlImagesEnabled = false, this.id, this.badgeCount, }); diff --git a/lib/storage/channel_message_store.dart b/lib/storage/channel_message_store.dart index f16081a6..2d99f501 100644 --- a/lib/storage/channel_message_store.dart +++ b/lib/storage/channel_message_store.dart @@ -195,7 +195,12 @@ class ChannelMessageStore { replyToText: json['replyToText'] as String?, reactions: (json['reactions'] as Map?)?.map( - (key, value) => MapEntry(key, value as int), + (key, value) => MapEntry( + key, + (value is int) + ? List.filled(value, null) + : List.from(value), + ), ) ?? {}, ); diff --git a/lib/storage/channel_settings_store.dart b/lib/storage/channel_settings_store.dart index e0b390f8..2415d01c 100644 --- a/lib/storage/channel_settings_store.dart +++ b/lib/storage/channel_settings_store.dart @@ -4,6 +4,7 @@ import 'prefs_manager.dart'; class ChannelSettingsStore { static const String _keyPrefix = 'channel_smaz_'; static const String _cyr2latKeyPrefix = 'channel_cyr2lat_'; + static const String _urlImagesKeyPrefix = 'channel_url_images_'; String publicKeyHex = ''; set setPublicKeyHex(String value) => @@ -11,6 +12,7 @@ class ChannelSettingsStore { String get keyFor => '$_keyPrefix$publicKeyHex'; String get keyForCyr2Lat => '$_cyr2latKeyPrefix$publicKeyHex'; + String get keyForUrlImages => '$_urlImagesKeyPrefix$publicKeyHex'; Future loadSmazEnabled(int channelIndex) async { if (publicKeyHex.isEmpty) { @@ -73,6 +75,31 @@ class ChannelSettingsStore { await prefs.setBool(key, enabled); } + Future loadUrlImagesEnabled(int channelIndex) async { + if (publicKeyHex.isEmpty) { + appLogger.warn( + 'Public key hex is not set. Cannot load channel URL image settings.', + ); + return false; + } + final prefs = PrefsManager.instance; + final key = '$keyForUrlImages$channelIndex'; + return prefs.getBool(key) ?? false; + } + + Future saveUrlImagesEnabled(int channelIndex, bool enabled) async { + if (publicKeyHex.isEmpty) { + appLogger.warn( + 'Public key hex is not set. Cannot save channel URL image settings.', + ); + return; + } + await PrefsManager.instance.setBool( + '$keyForUrlImages$channelIndex', + enabled, + ); + } + Future loadCyr2LatProfileId(int channelIndex) async { if (publicKeyHex.isEmpty) { appLogger.warn( diff --git a/lib/storage/contact_settings_store.dart b/lib/storage/contact_settings_store.dart index 682f1af6..a0760477 100644 --- a/lib/storage/contact_settings_store.dart +++ b/lib/storage/contact_settings_store.dart @@ -4,6 +4,7 @@ import 'prefs_manager.dart'; class ContactSettingsStore { static const String _keyPrefix = 'contact_smaz_'; static const String _cyr2latKeyPrefix = 'contact_cyr2lat_'; + static const String _urlImagesKeyPrefix = 'contact_url_images_'; String publicKeyHex = ''; set setPublicKeyHex(String value) => @@ -11,6 +12,7 @@ class ContactSettingsStore { String get keyFor => '$_keyPrefix$publicKeyHex'; String get keyForCyr2Lat => '$_cyr2latKeyPrefix$publicKeyHex'; + String get keyForUrlImages => '$_urlImagesKeyPrefix$publicKeyHex'; Future loadSmazEnabled(String contactKeyHex) async { if (publicKeyHex.isEmpty) { @@ -73,6 +75,31 @@ class ContactSettingsStore { await prefs.setBool(key, enabled); } + Future loadUrlImagesEnabled(String contactKeyHex) async { + if (publicKeyHex.isEmpty) { + appLogger.warn( + 'Public key hex is not set. Cannot load contact URL image settings.', + ); + return false; + } + final prefs = PrefsManager.instance; + final key = '$keyForUrlImages$contactKeyHex'; + return prefs.getBool(key) ?? false; + } + + Future saveUrlImagesEnabled(String contactKeyHex, bool enabled) async { + if (publicKeyHex.isEmpty) { + appLogger.warn( + 'Public key hex is not set. Cannot save contact URL image settings.', + ); + return; + } + await PrefsManager.instance.setBool( + '$keyForUrlImages$contactKeyHex', + enabled, + ); + } + Future loadCyr2LatProfileId(String contactKeyHex) async { if (publicKeyHex.isEmpty) { appLogger.warn( diff --git a/lib/storage/message_store.dart b/lib/storage/message_store.dart index 96aaba9c..52f632b4 100644 --- a/lib/storage/message_store.dart +++ b/lib/storage/message_store.dart @@ -171,7 +171,12 @@ class MessageStore { pathBytes: decodedPathBytes, reactions: (json['reactions'] as Map?)?.map( - (key, value) => MapEntry(key, value as int), + (key, value) => MapEntry( + key, + (value is int) + ? List.filled(value, null) + : List.from(value), + ), ) ?? {}, reactionStatuses: diff --git a/lib/widgets/image_send_button.dart b/lib/widgets/image_send_button.dart deleted file mode 100644 index f1482a5c..00000000 --- a/lib/widgets/image_send_button.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; - -import '../l10n/l10n.dart'; - -class ImageSendButton extends StatelessWidget { - final bool enabled; - final VoidCallback onPressed; - final String? tooltip; - - const ImageSendButton({ - super.key, - required this.enabled, - required this.onPressed, - this.tooltip, - }); - - @override - Widget build(BuildContext context) { - return IconButton( - icon: Icon(enabled ? Icons.image : Icons.image_outlined), - onPressed: enabled ? onPressed : null, - tooltip: tooltip ?? context.l10n.chat_sendImage, - ); - } -} diff --git a/test/helpers/message_url_image_helper_test.dart b/test/helpers/message_url_image_helper_test.dart new file mode 100644 index 00000000..ecb2712b --- /dev/null +++ b/test/helpers/message_url_image_helper_test.dart @@ -0,0 +1,93 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/helpers/message_url_image_helper.dart'; + +void main() { + group('MessageUrlImageHelper', () { + test('parses short pyx ids', () async { + final attachment = await MessageUrlImageHelper.parse( + 'my picture: https://pyx.li/?i=RzmdkTsE text', + ); + + expect(attachment, isNotNull); + expect(attachment, 'https://pyx.li/i/RzmdkTsE.jpg'); + }); + + test('parses direct pyx image urls', () async { + final attachment = await MessageUrlImageHelper.parse( + 'https://pyx.li/?i=Cd1KFiwu', + ); + + expect(attachment, isNotNull); + expect(attachment, 'https://pyx.li/i/Cd1KFiwu.jpg'); + }); + + test('parses provider-hosted ipfs links', () async { + final attachment = await MessageUrlImageHelper.parse( + 'my picture: https://uneven-plum-tarantula.myfilebase.com/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + ); + + expect(attachment, isNotNull); + expect( + attachment, + 'https://uneven-plum-tarantula.myfilebase.com/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + ); + }); + + test('parses direct ipfs cid urls', () async { + final attachment = await MessageUrlImageHelper.parse( + 'my picture: ipfs://bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + ); + + expect(attachment, isNotNull); + expect( + attachment, + 'https://ipfs.io/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + ); + }); + + test('parses direct ipfs cid urls without double slashes', () async { + final attachment = await MessageUrlImageHelper.parse( + 'my picture: ipfs:bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly text', + ); + + expect( + attachment, + 'https://ipfs.io/ipfs/bafybeibq75ws6nwk6wi473dch42wwy6woyj4dwdfy7nfz3buqx2caieoly', + ); + }); + + test('parses http image urls', () async { + final attachment = await MessageUrlImageHelper.parse( + 'see this image https://example.com/picture.png?size=large additional text', + ); + + expect(attachment, isNotNull); + expect(attachment, 'https://example.com/picture.png?size=large'); + }); + + test('returns null for plain text', () async { + expect(await MessageUrlImageHelper.parse('hello world'), isNull); + }); + + test('detects supported image URLs without resolving them', () { + expect( + MessageUrlImageHelper.hasPotentialImageUrl( + 'https://pyx.li/?i=RzmdkTsE', + ), + isTrue, + ); + expect( + MessageUrlImageHelper.hasPotentialImageUrl('hello world'), + isFalse, + ); + }); + + test('returns null for non-image ipfs gateway URL', () async { + final attachment = await MessageUrlImageHelper.parseVerified( + 'https://lime-famous-rat-748.mypinata.cloud/ipfs/bafybeih3jqv36rsxqx7yw3k3ixhganrevrk7xmcxgkr2zuzjegxdytb3nq', + ); + + expect(attachment, isNull); + }); + }); +} diff --git a/untranslated.json b/untranslated.json index 500baa2c..d4525112 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1,80 +1,132 @@ { "bg": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], + "de": [ + "reaction_report" + ], + "es": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "fr": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "hu": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "it": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "ja": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "ko": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "nl": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "pl": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "pt": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "ru": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "sk": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "sl": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "sv": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "uk": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ], "zh": [ + "urlImage_enable", + "urlImage_possible", + "reaction_report", "contactsSettings_evictDiscoveredContactsTitle", "contactsSettings_evictDiscoveredContactsSubtitle" ]