From 296eab20ca6b4655dc9b29b732e7fd95e565540c Mon Sep 17 00:00:00 2001 From: shortwavesurfer2009 Date: Sun, 4 Oct 2026 00:48:51 -0400 Subject: [PATCH 01/16] Add low battery notification channel with threshold alerts --- lib/connector/meshcore_connector.dart | 27 ++++++++ lib/l10n/app_en.arb | 13 ++++ lib/l10n/app_localizations.dart | 12 ++++ lib/l10n/app_localizations_bg.dart | 8 +++ lib/l10n/app_localizations_de.dart | 8 +++ lib/l10n/app_localizations_en.dart | 8 +++ lib/l10n/app_localizations_es.dart | 8 +++ lib/l10n/app_localizations_fr.dart | 8 +++ lib/l10n/app_localizations_hu.dart | 8 +++ lib/l10n/app_localizations_it.dart | 8 +++ lib/l10n/app_localizations_ja.dart | 8 +++ lib/l10n/app_localizations_ko.dart | 8 +++ lib/l10n/app_localizations_nl.dart | 8 +++ lib/l10n/app_localizations_pl.dart | 8 +++ lib/l10n/app_localizations_pt.dart | 8 +++ lib/l10n/app_localizations_ru.dart | 8 +++ lib/l10n/app_localizations_sk.dart | 8 +++ lib/l10n/app_localizations_sl.dart | 8 +++ lib/l10n/app_localizations_sv.dart | 8 +++ lib/l10n/app_localizations_uk.dart | 8 +++ lib/l10n/app_localizations_zh.dart | 8 +++ lib/services/notification_service.dart | 45 +++++++++++++ untranslated.json | 87 +++++++++++++++++++++++++- 23 files changed, 327 insertions(+), 1 deletion(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 7874bc18..5b96b31f 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -266,6 +266,10 @@ class MeshCoreConnector extends ChangeNotifier { Stopwatch? _airtimeBumpStopwatch; int _prevTotalAirSecs = 0; int? _batteryMillivolts; + // Thresholds (percent) that trigger a low-battery notification once per + // crossing, re-arming 5 points above the threshold after recharge. + static const List _lowBatteryThresholds = [25, 10]; + final Set _batteryAlertedThresholds = {}; double? _selfLatitude; double? _selfLongitude; final List _directRepeaters = List.empty(growable: true); @@ -3139,6 +3143,7 @@ class MeshCoreConnector extends ChangeNotifier { _autoAddMaxHops = null; _contactsStorageFull = false; _batteryMillivolts = null; + _batteryAlertedThresholds.clear(); _repeaterBatterySnapshots.clear(); _batteryRequested = false; _awaitingSelfInfo = false; @@ -5357,6 +5362,7 @@ class MeshCoreConnector extends ChangeNotifier { _batteryMillivolts = reader.readUInt16LE(); _storageUsedKb = reader.readUInt32LE(); _storageTotalKb = reader.readUInt32LE(); + _checkLowBatteryThresholds(); final volts = (_batteryMillivolts! / 1000.0).toStringAsFixed(2); _appDebugLogService?.info( 'Pulled battery: $volts V ($_batteryMillivolts mV)', @@ -5371,6 +5377,27 @@ class MeshCoreConnector extends ChangeNotifier { } } + void _checkLowBatteryThresholds() { + final percent = batteryPercent; + if (percent == null) return; + + for (final threshold in _lowBatteryThresholds) { + if (percent <= threshold && + !_batteryAlertedThresholds.contains(threshold)) { + _batteryAlertedThresholds.add(threshold); + NotificationService().showLowBatteryNotification( + batteryPercent: percent, + threshold: threshold, + ); + } else if (percent > threshold + 5 && + _batteryAlertedThresholds.contains(threshold)) { + // Re-arm once the battery recovers 5 points above the threshold, + // so a recharge + discharge cycle alerts again without flapping. + _batteryAlertedThresholds.remove(threshold); + } + } + } + void _checkManualAddContacts() async { // If manual add contacts is enabled, set auto add config and other params. // and disable it after diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 47f2dba6..a8718ea7 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -2573,6 +2573,19 @@ "contacts_contactAdvertCopied": "Advert copied to Clipboard.", "contacts_contactAdvertCopyFailed": "Copying advert to Clipboard failed.", "notification_activityTitle": "MeshCore Activity", + "notification_lowBatteryTitle": "Low battery", + "@notification_lowBatteryTitle": { + "description": "Title of the low battery notification" + }, + "notification_lowBatteryBody": "Device battery is at {percent}%", + "@notification_lowBatteryBody": { + "description": "Body of the low battery notification", + "placeholders": { + "percent": { + "type": "int" + } + } + }, "notification_messagesCount": "{count} {count, plural, =1{message} other{messages}}", "@notification_messagesCount": { "placeholders": { diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 66eedf4c..c5c9e414 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -7924,6 +7924,18 @@ abstract class AppLocalizations { /// **'MeshCore Activity'** String get notification_activityTitle; + /// Title of the low battery notification + /// + /// In en, this message translates to: + /// **'Low battery'** + String get notification_lowBatteryTitle; + + /// Body of the low battery notification + /// + /// In en, this message translates to: + /// **'Device battery is at {percent}%'** + String notification_lowBatteryBody(int percent); + /// No description provided for @notification_messagesCount. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index c54ab2ee..c1c2ac7f 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -4597,6 +4597,14 @@ class AppLocalizationsBg extends AppLocalizations { @override String get notification_activityTitle => 'Активност на MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index ca2ada41..e33166ef 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -4608,6 +4608,14 @@ class AppLocalizationsDe extends AppLocalizations { @override String get notification_activityTitle => 'MeshCore Aktivität'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 70ce610f..b2f769bf 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -4533,6 +4533,14 @@ class AppLocalizationsEn extends AppLocalizations { @override String get notification_activityTitle => 'MeshCore Activity'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index f0c31cb3..1a1f1e81 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -4599,6 +4599,14 @@ class AppLocalizationsEs extends AppLocalizations { @override String get notification_activityTitle => 'Actividad de MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 0385315d..176f8008 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -4619,6 +4619,14 @@ class AppLocalizationsFr extends AppLocalizations { @override String get notification_activityTitle => 'Activité MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 0b909253..e42e58d3 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -4597,6 +4597,14 @@ class AppLocalizationsHu extends AppLocalizations { @override String get notification_activityTitle => 'MeshCore tevékenység'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index e737afdd..d29f0045 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -4604,6 +4604,14 @@ class AppLocalizationsIt extends AppLocalizations { @override String get notification_activityTitle => 'Attività MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 86130828..65f7d04e 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -4373,6 +4373,14 @@ class AppLocalizationsJa extends AppLocalizations { @override String get notification_activityTitle => 'メッシュコアの活動'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 94c0f3bd..c8ca6e2b 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -4384,6 +4384,14 @@ class AppLocalizationsKo extends AppLocalizations { @override String get notification_activityTitle => '메쉬코어 활동'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 0c7a199a..9369eb42 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -4575,6 +4575,14 @@ class AppLocalizationsNl extends AppLocalizations { @override String get notification_activityTitle => 'MeshCore Activiteit'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index fbe65401..42862a06 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -4623,6 +4623,14 @@ class AppLocalizationsPl extends AppLocalizations { @override String get notification_activityTitle => 'Aktywność MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 4c3b7c43..19e4552a 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -4601,6 +4601,14 @@ class AppLocalizationsPt extends AppLocalizations { @override String get notification_activityTitle => 'Atividade MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index b197ce46..1916766f 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -4607,6 +4607,14 @@ class AppLocalizationsRu extends AppLocalizations { @override String get notification_activityTitle => 'Активность MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 2818ab6b..daf8043e 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -4581,6 +4581,14 @@ class AppLocalizationsSk extends AppLocalizations { @override String get notification_activityTitle => 'Aktivita MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index ab8ba209..de74a7b3 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -4579,6 +4579,14 @@ class AppLocalizationsSl extends AppLocalizations { @override String get notification_activityTitle => 'Aktivnost MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index aa6022e0..f5fc9e5e 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -4557,6 +4557,14 @@ class AppLocalizationsSv extends AppLocalizations { @override String get notification_activityTitle => 'MeshCore Aktivitet'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index c3e5f7a0..be816508 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -4607,6 +4607,14 @@ class AppLocalizationsUk extends AppLocalizations { @override String get notification_activityTitle => 'Активність MeshCore'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { String _temp0 = intl.Intl.pluralLogic( diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index d9d7281e..a9f91a99 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -4285,6 +4285,14 @@ class AppLocalizationsZh extends AppLocalizations { @override String get notification_activityTitle => 'MeshCore 活动'; + @override + String get notification_lowBatteryTitle => 'Low battery'; + + @override + String notification_lowBatteryBody(int percent) { + return 'Device battery is at $percent%'; + } + @override String notification_messagesCount(int count) { return '$count 条消息'; diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index 83714cfa..333466e4 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -597,6 +597,51 @@ class NotificationService { } } + /// Posts a low-battery alert for the connected device. + /// + /// Uses a per-threshold notification id so each alert level updates its own + /// notification instead of stacking. Bypasses the rate-limit queue, which + /// only handles message and advert notifications. + Future showLowBatteryNotification({ + required int batteryPercent, + required int threshold, + }) async { + if (!await _ensureCanNotify()) return; + + const androidDetails = AndroidNotificationDetails( + 'low_battery', + 'Low Battery', + channelDescription: 'Low battery alerts for the connected device', + importance: Importance.high, + priority: Priority.high, + icon: '@mipmap/ic_launcher', + ); + + const darwinDetails = DarwinNotificationDetails( + presentAlert: true, + presentBadge: false, + presentSound: true, + ); + + const notificationDetails = NotificationDetails( + android: androidDetails, + iOS: darwinDetails, + macOS: darwinDetails, + ); + + try { + await _notifications.show( + id: 'low_battery:$threshold'.hashCode, + title: _l10n.notification_lowBatteryTitle, + body: _l10n.notification_lowBatteryBody(batteryPercent), + notificationDetails: notificationDetails, + payload: 'low_battery', + ); + } catch (e) { + debugPrint('Failed to show low battery notification: $e'); + } + } + /// Returns a privacy-safe identifier for debug logging. /// - advert: shows device name (body contains contactName) /// - message: shows "from: sender" (avoids logging message content) diff --git a/untranslated.json b/untranslated.json index 9e26dfee..440e93f0 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1,86 @@ -{} \ No newline at end of file +{ + "bg": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "de": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "es": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "fr": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "hu": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "it": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "ja": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "ko": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "nl": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "pl": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "pt": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "ru": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "sk": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "sl": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "sv": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "uk": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ], + + "zh": [ + "notification_lowBatteryTitle", + "notification_lowBatteryBody" + ] +} From c161bffc837adcc12dc38fda8dc6b241f47eddf5 Mon Sep 17 00:00:00 2001 From: shortwavesurfer2009 Date: Mon, 5 Oct 2026 19:19:08 -0400 Subject: [PATCH 02/16] fold path hash size into radio settings --- lib/models/radio_settings.dart | 2 ++ lib/screens/settings_screen.dart | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/models/radio_settings.dart b/lib/models/radio_settings.dart index f7c4709c..6b3eee84 100644 --- a/lib/models/radio_settings.dart +++ b/lib/models/radio_settings.dart @@ -50,6 +50,7 @@ class RadioSettings { final LoRaSpreadingFactor spreadingFactor; final LoRaCodingRate codingRate; final int txPowerDbm; + final int pathHashByteWidth; RadioSettings({ required this.frequencyMHz, @@ -57,6 +58,7 @@ class RadioSettings { required this.spreadingFactor, required this.codingRate, required this.txPowerDbm, + this.pathHashByteWidth = 1, // app default; presets override if needed }); // Regional preset configurations diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 502e0f18..c94e23f2 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -1526,10 +1526,14 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { LoRaCodingRate _codingRate = LoRaCodingRate.cr4_5; final _txPowerController = TextEditingController(text: '20'); bool _clientRepeat = false; + int _pathHashByteWidth = 1; int? _selectedPresetIndex; _RadioSettingsSnapshot? _lastNonRepeatSnapshot; String? _frequencyError; String? _txPowerError; + bool get _supportsPathHashMode => + (widget.connector.firmwareVerCode ?? 0) >= + _minFirmwareVerCodeForPathHashMode; AppDebugLogService get _appLog => Provider.of(context, listen: false); @@ -1583,6 +1587,7 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { _txPowerController.text = widget.connector.currentTxPower.toString(); } + _pathHashByteWidth = widget.connector.pathHashByteWidth; _clientRepeat = widget.connector.clientRepeat ?? false; _selectedPresetIndex = _findMatchingPresetIndex(); if (_clientRepeat) { @@ -1752,6 +1757,7 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { _spreadingFactor = preset.spreadingFactor; _codingRate = preset.codingRate; _txPowerController.text = preset.txPowerDbm.toString(); + _pathHashByteWidth = preset.pathHashByteWidth; _selectedPresetIndex = index; _lastNonRepeatSnapshot = baseSnapshot; } @@ -1911,6 +1917,10 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { return; } await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower)); + if (_supportsPathHashMode && + _pathHashByteWidth != widget.connector.pathHashByteWidth) { + await widget.connector.setPathHashMode(_pathHashByteWidth - 1); + } final selfInfo = widget.connector.receivedFrames .firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo) .timeout(const Duration(seconds: 5)); @@ -2144,6 +2154,34 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { }, ), const SizedBox(height: 16), + if (_supportsPathHashMode) ...[ + DropdownButtonFormField( + initialValue: _pathHashByteWidth, + decoration: InputDecoration( + labelText: l10n.repeater_pathHashMode, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem( + value: 1, + child: Text(l10n.repeater_pathHashModeOption0), + ), + DropdownMenuItem( + value: 2, + child: Text(l10n.repeater_pathHashModeOption1), + ), + DropdownMenuItem( + value: 3, + child: Text(l10n.repeater_pathHashModeOption2), + ), + ], + onChanged: (value) { + if (value == null) return; + setState(() => _pathHashByteWidth = value); + }, + ), + const SizedBox(height: 16), + ], TextField( controller: _txPowerController, onChanged: (_) => _handleManualSettingsChanged('tx power'), From caad3dd7039f9f74b1f7c76d006d6262e3017f7c Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 23 Oct 2026 22:36:11 +0200 Subject: [PATCH 03/16] feat: add per-channel notification modes (all/mentions only/muted) - Add ChannelNotificationMode enum with all, mentionsOnly, muted options - Replace mutedChannels Set with channelNotificationModes Map for per-channel settings - Add mention detection for @username in channel messages - Update channels list and chat UI with notification mode selector - Add localization strings for new notification modes - Automatic migration from old mutedChannels to new system - Update user documentation - Preserve backward compatibility with existing mute/unmute API --- documentation/notifications.md | 20 ++-- lib/connector/meshcore_connector.dart | 32 ++++++- lib/l10n/app_en.arb | 4 + lib/l10n/app_fr.arb | 4 + lib/l10n/app_localizations.dart | 24 +++++ lib/l10n/app_localizations_bg.dart | 12 +++ lib/l10n/app_localizations_de.dart | 12 +++ lib/l10n/app_localizations_en.dart | 12 +++ lib/l10n/app_localizations_es.dart | 12 +++ lib/l10n/app_localizations_fr.dart | 12 +++ lib/l10n/app_localizations_hu.dart | 12 +++ lib/l10n/app_localizations_it.dart | 12 +++ lib/l10n/app_localizations_ja.dart | 12 +++ lib/l10n/app_localizations_ko.dart | 12 +++ lib/l10n/app_localizations_nl.dart | 12 +++ lib/l10n/app_localizations_pl.dart | 12 +++ lib/l10n/app_localizations_pt.dart | 12 +++ lib/l10n/app_localizations_ru.dart | 12 +++ lib/l10n/app_localizations_sk.dart | 12 +++ lib/l10n/app_localizations_sl.dart | 12 +++ lib/l10n/app_localizations_sv.dart | 12 +++ lib/l10n/app_localizations_uk.dart | 12 +++ lib/l10n/app_localizations_zh.dart | 12 +++ lib/models/app_settings.dart | 61 +++++++++--- lib/review_mode/review_mode_storage.dart | 25 +++-- lib/screens/channel_chat_screen.dart | 66 +++++++++++-- lib/screens/channels_screen.dart | 116 ++++++++++++++++++----- lib/services/app_settings_service.dart | 31 ++++-- untranslated.json | 114 +++++++++++++++++++++- 29 files changed, 647 insertions(+), 66 deletions(-) diff --git a/documentation/notifications.md b/documentation/notifications.md index 0f08a095..c84c35d7 100644 --- a/documentation/notifications.md +++ b/documentation/notifications.md @@ -99,15 +99,23 @@ Access via **App Settings → Notifications**: | Channel Message Notifications | On | Channel alerts (greyed out if master is off) | | Advertisement Notifications | On | New node alerts (greyed out if master is off) | -### Per-Channel Muting +### Per-Channel Notification Modes -Mute or unmute a channel from any of these places. Muted channels do not generate OS notifications. +Each channel supports three notification modes: -- The bell icon in the channel chat app bar -- Long-press a channel in the channels list → "Mute channel" / "Unmute channel" -- **Mute channel** on a channel notification (Android) +| Mode | Icon | Behavior | +|---|---|---| +| **All messages** | 🔔 | Receive notifications for every message | +| **Mentions only (@)** | @ | Only notify when someone mentions you with "@yourname" | +| **Muted** | 🔇 | No notifications | -There is no per-contact muting. +Set the mode from: + +- The notifications icon in the channel chat app bar (tap to cycle through modes) +- Long-press a channel in the channels list → **Notification settings** → select mode +- Channel notification actions (Android) + +Mentions are detected by looking for "@" followed by your username at word boundaries. The comparison is case-insensitive. ## Rate Limiting diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 03b03944..783d5061 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -38,7 +38,8 @@ import '../services/image_codec_service.dart'; import '../services/received_image_store.dart'; import '../services/message_retry_service.dart'; import '../services/path_history_service.dart'; -import '../services/app_settings_service.dart'; +import '../services/app_settings_service.dart' + show AppSettingsService, ChannelNotificationMode; import '../services/background_service.dart'; import '../services/timeout_prediction_service.dart'; import '../services/translation_service.dart'; @@ -7353,7 +7354,12 @@ class MeshCoreConnector extends ChangeNotifier { } final label = channelName ?? _channelDisplayName(channelIndex); - if (_appSettingsService!.isChannelMuted(label)) return; + final notificationMode = _appSettingsService!.getChannelNotificationMode( + label, + ); + + // Check if channel is muted + if (notificationMode == ChannelNotificationMode.muted) return; // Reuse translation result only if completed and non-empty; else use original text final resolvedText = @@ -7362,6 +7368,12 @@ class MeshCoreConnector extends ChangeNotifier { translationResult.translatedText.trim().isNotEmpty) ? translationResult.translatedText.trim() : message.text.trim(); + + // If mode is mentionsOnly, check if message mentions us + if (notificationMode == ChannelNotificationMode.mentionsOnly) { + if (!_doesMessageMentionUs(resolvedText)) return; + } + unawaited(() async { await _notificationService.showChannelMessageNotification( channelName: label, @@ -7374,6 +7386,22 @@ class MeshCoreConnector extends ChangeNotifier { }()); } + /// Checks if a message text mentions the current user. + /// Looks for "@username" pattern where username matches our self name. + bool _doesMessageMentionUs(String messageText) { + final selfName = _selfName; + if (selfName == null || selfName.isEmpty) return false; + + // Check for @username at word boundaries (start of message or after whitespace) + // Case-insensitive comparison + final lowerSelfName = selfName.toLowerCase(); + final lowerMessage = messageText.toLowerCase(); + final mentionPattern = RegExp( + r'\b@(' + RegExp.escape(lowerSelfName) + r')\b', + ); + return mentionPattern.hasMatch(lowerMessage); + } + /// Handles RESP_CODE_CHANNEL_DATA_RECV (GRP_DATA). Frames whose dataType is /// not 0xAE1C — or that arrive before an [ImageChunkTransport] is installed — /// are ignored without disturbing any other behaviour. diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f62a038b..820271a3 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -715,6 +715,10 @@ "channels_addSectionCreate": "Create new", "channels_dragToReorder": "Drag to reorder", "channels_editChannel": "Edit channel", + "channels_notificationSettings": "Notification settings", + "channels_notifyAll": "All messages", + "channels_notifyMentionsOnly": "Mentions only (@)", + "channels_notifyNone": "Muted", "channels_muteChannel": "Mute channel", "channels_unmuteChannel": "Unmute channel", "channels_deleteChannel": "Delete channel", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index f42ce6d6..0c37b31b 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -369,6 +369,10 @@ "channels_public": "Public", "channels_private": "Privé", "channels_editChannel": "Modifier le canal", + "channels_notificationSettings": "Paramètres des notifications", + "channels_notifyAll": "Tous les messages", + "channels_notifyMentionsOnly": "Mentions uniquement (@)", + "channels_notifyNone": "Désactivé", "channels_muteChannel": "Désactiver les notifications du canal", "channels_unmuteChannel": "Réactiver les notifications du canal", "channels_deleteChannel": "Supprimer le canal", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index b5e7efc5..3596db1a 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -2620,6 +2620,30 @@ abstract class AppLocalizations { /// **'Edit channel'** String get channels_editChannel; + /// No description provided for @channels_notificationSettings. + /// + /// In en, this message translates to: + /// **'Notification settings'** + String get channels_notificationSettings; + + /// No description provided for @channels_notifyAll. + /// + /// In en, this message translates to: + /// **'All messages'** + String get channels_notifyAll; + + /// No description provided for @channels_notifyMentionsOnly. + /// + /// In en, this message translates to: + /// **'Mentions only (@)'** + String get channels_notifyMentionsOnly; + + /// No description provided for @channels_notifyNone. + /// + /// In en, this message translates to: + /// **'Muted'** + String get channels_notifyNone; + /// No description provided for @channels_muteChannel. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index b9f79a6f..6f260891 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -1464,6 +1464,18 @@ class AppLocalizationsBg extends AppLocalizations { @override String get channels_editChannel => 'Редактирай канал'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Заглуши канала'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index d7893ccf..ddf10b8c 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1458,6 +1458,18 @@ class AppLocalizationsDe extends AppLocalizations { @override String get channels_editChannel => 'Kanal bearbeiten'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Kanal stummschalten'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 0265ac8b..4bf9b610 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1438,6 +1438,18 @@ class AppLocalizationsEn extends AppLocalizations { @override String get channels_editChannel => 'Edit channel'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Mute channel'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 75c2ab0e..2345ac55 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1457,6 +1457,18 @@ class AppLocalizationsEs extends AppLocalizations { @override String get channels_editChannel => 'Editar canal'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Silenciar canal'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 85de8bbb..bed96b71 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1462,6 +1462,18 @@ class AppLocalizationsFr extends AppLocalizations { @override String get channels_editChannel => 'Modifier le canal'; + @override + String get channels_notificationSettings => 'Paramètres des notifications'; + + @override + String get channels_notifyAll => 'Tous les messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions uniquement (@)'; + + @override + String get channels_notifyNone => 'Désactivé'; + @override String get channels_muteChannel => 'Désactiver les notifications du canal'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index ef4b3d9b..9e81cf47 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1453,6 +1453,18 @@ class AppLocalizationsHu extends AppLocalizations { @override String get channels_editChannel => 'Csatorna szerkesztése'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Csatorna némítása'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 50bb49d9..5fec4210 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1461,6 +1461,18 @@ class AppLocalizationsIt extends AppLocalizations { @override String get channels_editChannel => 'Modifica canale'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Silenzia canale'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 2aabf56e..57da4dfc 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1385,6 +1385,18 @@ class AppLocalizationsJa extends AppLocalizations { @override String get channels_editChannel => 'チャンネルを編集'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'チャンネルをミュート'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 98a81ac1..1221475f 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1390,6 +1390,18 @@ class AppLocalizationsKo extends AppLocalizations { @override String get channels_editChannel => '채널 편집'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => '음소거 채널'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 082f2a18..84075f13 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1449,6 +1449,18 @@ class AppLocalizationsNl extends AppLocalizations { @override String get channels_editChannel => 'Kanaal bewerken'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Kanaal dempen'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 3db02722..71700e5d 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1475,6 +1475,18 @@ class AppLocalizationsPl extends AppLocalizations { @override String get channels_editChannel => 'Edytuj kanał'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Wycisz kanał'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 9b89ff31..1b9305f1 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1460,6 +1460,18 @@ class AppLocalizationsPt extends AppLocalizations { @override String get channels_editChannel => 'Editar canal'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Silenciar canal'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index a1686804..57080935 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1464,6 +1464,18 @@ class AppLocalizationsRu extends AppLocalizations { @override String get channels_editChannel => 'Изменить канал'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Отключить уведомления канала'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 9cd7cc6d..0491a952 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1452,6 +1452,18 @@ class AppLocalizationsSk extends AppLocalizations { @override String get channels_editChannel => 'Upraviť kanál'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Stlmiť kanál'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 8602eb0d..9b247612 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1450,6 +1450,18 @@ class AppLocalizationsSl extends AppLocalizations { @override String get channels_editChannel => 'Uredi kanal'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Utišaj kanal'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 1d87483d..ac13e6aa 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1439,6 +1439,18 @@ class AppLocalizationsSv extends AppLocalizations { @override String get channels_editChannel => 'Redigera kanal'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Tysta kanal'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index ebd6d5eb..c4aa6b8f 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1455,6 +1455,18 @@ class AppLocalizationsUk extends AppLocalizations { @override String get channels_editChannel => 'Редагувати канал'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => 'Вимкнути сповіщення каналу'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 703a27fe..825f7954 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1367,6 +1367,18 @@ class AppLocalizationsZh extends AppLocalizations { @override String get channels_editChannel => '编辑频道'; + @override + String get channels_notificationSettings => 'Notification settings'; + + @override + String get channels_notifyAll => 'All messages'; + + @override + String get channels_notifyMentionsOnly => 'Mentions only (@)'; + + @override + String get channels_notifyNone => 'Muted'; + @override String get channels_muteChannel => '静音频道'; diff --git a/lib/models/app_settings.dart b/lib/models/app_settings.dart index b3632585..612905ec 100644 --- a/lib/models/app_settings.dart +++ b/lib/models/app_settings.dart @@ -3,6 +3,8 @@ import 'translation_support.dart'; enum UnitSystem { metric, imperial } +enum ChannelNotificationMode { all, mentionsOnly, muted } + extension UnitSystemValue on UnitSystem { String get value { switch (this) { @@ -123,7 +125,7 @@ class AppSettings { final Map batteryChemistryByDeviceId; final Map batteryChemistryByRepeaterId; final UnitSystem unitSystem; - final Set mutedChannels; + final Map channelNotificationModes; final bool mapShowDiscoveryContacts; final bool evictDiscoveredContactsEnabled; final String tcpServerAddress; @@ -196,6 +198,12 @@ class AppSettings { return profile.charMap; } + // Backward compatibility: returns true if channel is muted (mode == muted) + bool isChannelMuted(String channelName) { + return channelNotificationModes[channelName] == + ChannelNotificationMode.muted; + } + AppSettings({ this.clearPathOnMaxRetry = false, this.mapShowRepeaters = true, @@ -238,7 +246,7 @@ class AppSettings { Map? batteryChemistryByDeviceId, Map? batteryChemistryByRepeaterId, this.unitSystem = UnitSystem.metric, - Set? mutedChannels, + Map? channelNotificationModes, this.mapShowDiscoveryContacts = true, this.evictDiscoveredContactsEnabled = true, this.tcpServerAddress = '', @@ -264,7 +272,7 @@ class AppSettings { String? selectedCyr2latProfileId, }) : batteryChemistryByDeviceId = batteryChemistryByDeviceId ?? {}, batteryChemistryByRepeaterId = batteryChemistryByRepeaterId ?? {}, - mutedChannels = mutedChannels ?? {}, + channelNotificationModes = channelNotificationModes ?? {}, imageCodecDownloadedModels = imageCodecDownloadedModels ?? const [], translationDownloadedModels = translationDownloadedModels ?? const [], cyr2latProfiles = @@ -322,7 +330,9 @@ class AppSettings { 'battery_chemistry_by_device_id': batteryChemistryByDeviceId, 'battery_chemistry_by_repeater_id': batteryChemistryByRepeaterId, 'unit_system': unitSystem.value, - 'muted_channels': mutedChannels.toList(), + 'channel_notification_modes': channelNotificationModes.map( + (key, value) => MapEntry(key, value.index), + ), 'map_show_discovery_contacts': mapShowDiscoveryContacts, 'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled, 'tcp_server_address': tcpServerAddress, @@ -363,6 +373,38 @@ class AppSettings { return UnitSystem.metric; } + Map parseChannelNotificationModes( + Map json, + ) { + // Migration from old muted_channels (Set) to new system + final mutedList = json['muted_channels'] as List?; + final newModes = json['channel_notification_modes'] as Map?; + + final result = {}; + + // Migrate old muted channels + if (mutedList != null) { + for (final channelName in mutedList) { + result[channelName.toString()] = ChannelNotificationMode.muted; + } + } + + // Load new modes (overrides old muted channels if present) + if (newModes != null) { + for (final entry in newModes.entries) { + final channelName = entry.key; + final modeIndex = entry.value as int?; + if (modeIndex != null && + modeIndex >= 0 && + modeIndex < ChannelNotificationMode.values.length) { + result[channelName] = ChannelNotificationMode.values[modeIndex]; + } + } + } + + return result; + } + return AppSettings( clearPathOnMaxRetry: json['clear_path_on_max_retry'] as bool? ?? false, mapShowRepeaters: json['map_show_repeaters'] as bool? ?? true, @@ -425,11 +467,7 @@ class AppSettings { ) ?? {}, unitSystem: parseUnitSystem(json['unit_system']), - mutedChannels: - ((json['muted_channels'] as List?) - ?.map((e) => e.toString()) - .toSet()) ?? - {}, + channelNotificationModes: parseChannelNotificationModes(json), mapShowDiscoveryContacts: json['map_show_discovery_contacts'] as bool? ?? true, evictDiscoveredContactsEnabled: @@ -554,7 +592,7 @@ class AppSettings { Map? batteryChemistryByDeviceId, Map? batteryChemistryByRepeaterId, UnitSystem? unitSystem, - Set? mutedChannels, + Map? channelNotificationModes, bool? mapShowDiscoveryContacts, bool? evictDiscoveredContactsEnabled, String? tcpServerAddress, @@ -639,7 +677,8 @@ class AppSettings { batteryChemistryByRepeaterId: batteryChemistryByRepeaterId ?? this.batteryChemistryByRepeaterId, unitSystem: unitSystem ?? this.unitSystem, - mutedChannels: mutedChannels ?? this.mutedChannels, + channelNotificationModes: + channelNotificationModes ?? this.channelNotificationModes, mapShowDiscoveryContacts: mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts, evictDiscoveredContactsEnabled: diff --git a/lib/review_mode/review_mode_storage.dart b/lib/review_mode/review_mode_storage.dart index 2ccfc569..e0a02bb4 100644 --- a/lib/review_mode/review_mode_storage.dart +++ b/lib/review_mode/review_mode_storage.dart @@ -1,4 +1,5 @@ -import '../services/app_settings_service.dart'; +import '../services/app_settings_service.dart' + show AppSettingsService, ChannelNotificationMode; import '../services/storage_service.dart'; import '../services/timeout_prediction_service.dart'; import '../storage/legacy_key_migration.dart'; @@ -48,10 +49,13 @@ Future beginReviewModeSession(AppSettingsService? settings) async { } // An earlier interrupted session's record holds the real pre-review state. if (settings != null && !prefs.containsKey(_savedMutedChannelsKey)) { - await prefs.setStringList( - _savedMutedChannelsKey, - settings.settings.mutedChannels.toList(), - ); + // Save all channel notification modes + final channelModes = settings.settings.channelNotificationModes; + final mutedChannels = channelModes.entries + .where((e) => e.value == ChannelNotificationMode.muted) + .map((e) => e.key) + .toList(); + await prefs.setStringList(_savedMutedChannelsKey, mutedChannels); } } @@ -75,8 +79,17 @@ Future endReviewModeSession(AppSettingsService? settings) async { } final savedMutes = prefs.getStringList(_savedMutedChannelsKey); if (savedMutes == null || settings == null) return; + final updatedModes = Map.from( + settings.settings.channelNotificationModes, + ); + updatedModes.removeWhere( + (key, value) => value == ChannelNotificationMode.muted, + ); + for (final channelName in savedMutes) { + updatedModes[channelName] = ChannelNotificationMode.muted; + } await settings.updateSettings( - settings.settings.copyWith(mutedChannels: savedMutes.toSet()), + settings.settings.copyWith(channelNotificationModes: updatedModes), ); await prefs.remove(_savedMutedChannelsKey); } diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 358ea298..a71e7cce 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -26,7 +26,8 @@ import '../l10n/l10n.dart'; import '../models/channel.dart'; import '../models/channel_message.dart'; import '../models/image_codec_support.dart' show aeicRatePointForUi; -import '../services/app_settings_service.dart'; +import '../services/app_settings_service.dart' + show AppSettingsService, ChannelNotificationMode; import '../services/chat_text_scale_service.dart'; import '../services/image_chunk_transport.dart'; import '../services/image_codec_service.dart'; @@ -403,19 +404,64 @@ class _ChannelChatScreenState extends State { Consumer( builder: (context, settings, _) { final muteKey = widget.channel.muteKey; - final muted = settings.isChannelMuted(muteKey); - return IconButton( - tooltip: muted - ? context.l10n.channels_unmuteChannel - : context.l10n.channels_muteChannel, + final notificationMode = settings.getChannelNotificationMode( + muteKey, + ); + return PopupMenuButton( + tooltip: context.l10n.channels_notificationSettings, icon: Icon( - muted + notificationMode == ChannelNotificationMode.muted ? Icons.notifications_off_outlined + : notificationMode == ChannelNotificationMode.mentionsOnly + ? Icons.alternate_email : Icons.notifications_outlined, ), - onPressed: () => muted - ? settings.unmuteChannel(muteKey) - : settings.muteChannel(muteKey), + onSelected: (mode) { + settings.setChannelNotificationMode(muteKey, mode); + }, + itemBuilder: (context) => [ + PopupMenuItem( + value: ChannelNotificationMode.all, + child: Row( + children: [ + Icon( + Icons.notifications_active, + color: notificationMode == ChannelNotificationMode.all + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(width: 8), + Text(context.l10n.channels_notifyAll), + ], + ), + ), + PopupMenuItem( + value: ChannelNotificationMode.mentionsOnly, + child: Row( + children: [ + const Icon(Icons.alternate_email), + const SizedBox(width: 8), + Text(context.l10n.channels_notifyMentionsOnly), + ], + ), + ), + PopupMenuItem( + value: ChannelNotificationMode.muted, + child: Row( + children: [ + Icon( + Icons.notifications_off, + color: + notificationMode == ChannelNotificationMode.muted + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(width: 8), + Text(context.l10n.channels_notifyNone), + ], + ), + ), + ], ); }, ), diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index f0c0bb35..8e03112e 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -10,7 +10,8 @@ import 'package:uuid/uuid.dart'; import '../connector/meshcore_connector.dart'; import '../l10n/l10n.dart'; -import '../services/app_settings_service.dart'; +import '../services/app_settings_service.dart' + show AppSettingsService, ChannelNotificationMode; import '../services/ui_view_state_service.dart'; import '../models/channel.dart'; import '../models/community.dart'; @@ -372,9 +373,9 @@ class _ChannelsScreenState extends State int listIndex = 0, }) { final unreadCount = connector.getUnreadCountForChannel(channel); - final isMuted = context.watch().isChannelMuted( - channel.muteKey, - ); + final notificationMode = context + .watch() + .getChannelNotificationMode(channel.muteKey); final scheme = Theme.of(context).colorScheme; // Determine icon and colors based on channel type @@ -580,9 +581,11 @@ class _ChannelsScreenState extends State Row( mainAxisSize: MainAxisSize.min, children: [ - if (isMuted) ...[ + if (notificationMode != ChannelNotificationMode.all) ...[ Icon( - Icons.notifications_off, + notificationMode == ChannelNotificationMode.muted + ? Icons.notifications_off + : Icons.alternate_email, size: 18, color: scheme.onSurfaceVariant, ), @@ -625,8 +628,6 @@ class _ChannelsScreenState extends State Channel channel, ) { final parentContext = context; - final settingsService = context.read(); - final isMuted = settingsService.isChannelMuted(channel.muteKey); showMeshSheet( parentContext, @@ -645,24 +646,14 @@ class _ChannelsScreenState extends State } }, ), + // Notification mode selection ListTile( - leading: Icon( - isMuted - ? Icons.notifications_outlined - : Icons.notifications_off_outlined, - ), - title: Text( - isMuted - ? sheetContext.l10n.channels_unmuteChannel - : sheetContext.l10n.channels_muteChannel, - ), - onTap: () async { + leading: const Icon(Icons.notifications_outlined), + title: Text(sheetContext.l10n.channels_notificationSettings), + trailing: const Icon(Icons.chevron_right), + onTap: () { Navigator.pop(sheetContext); - if (isMuted) { - await settingsService.unmuteChannel(channel.muteKey); - } else { - await settingsService.muteChannel(channel.muteKey); - } + _showNotificationModeDialog(sheetContext, connector, channel); }, ), ListTile( @@ -690,6 +681,83 @@ class _ChannelsScreenState extends State ); } + void _showNotificationModeDialog( + BuildContext context, + MeshCoreConnector connector, + Channel channel, + ) { + final settingsService = context.read(); + final currentMode = settingsService.getChannelNotificationMode( + channel.muteKey, + ); + + showMeshSheet( + context, + builder: (sheetContext) => SafeArea( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + // All notifications + ListTile( + leading: Icon( + Icons.notifications_active, + color: currentMode == ChannelNotificationMode.all + ? Theme.of(sheetContext).colorScheme.primary + : Theme.of(sheetContext).colorScheme.onSurfaceVariant, + ), + title: Text(sheetContext.l10n.channels_notifyAll), + trailing: currentMode == ChannelNotificationMode.all + ? const Icon(Icons.check) + : null, + onTap: () async { + Navigator.pop(sheetContext); + await settingsService.setChannelNotificationMode( + channel.muteKey, + ChannelNotificationMode.all, + ); + }, + ), + // Mentions only + ListTile( + leading: const Icon(Icons.alternate_email), + title: Text(sheetContext.l10n.channels_notifyMentionsOnly), + trailing: currentMode == ChannelNotificationMode.mentionsOnly + ? const Icon(Icons.check) + : null, + onTap: () async { + Navigator.pop(sheetContext); + await settingsService.setChannelNotificationMode( + channel.muteKey, + ChannelNotificationMode.mentionsOnly, + ); + }, + ), + // Muted + ListTile( + leading: Icon( + Icons.notifications_off, + color: currentMode == ChannelNotificationMode.muted + ? Theme.of(sheetContext).colorScheme.primary + : Theme.of(sheetContext).colorScheme.onSurfaceVariant, + ), + title: Text(sheetContext.l10n.channels_notifyNone), + trailing: currentMode == ChannelNotificationMode.muted + ? const Icon(Icons.check) + : null, + onTap: () async { + Navigator.pop(sheetContext); + await settingsService.setChannelNotificationMode( + channel.muteKey, + ChannelNotificationMode.muted, + ); + }, + ), + ], + ), + ), + ); + } + void _handleQuickSwitch(int index, BuildContext context) { if (index == 1) return; switch (index) { diff --git a/lib/services/app_settings_service.dart b/lib/services/app_settings_service.dart index 3cf9e7d9..5bddabae 100644 --- a/lib/services/app_settings_service.dart +++ b/lib/services/app_settings_service.dart @@ -3,6 +3,8 @@ import 'package:flutter/foundation.dart'; import '../models/app_settings.dart'; import '../models/image_codec_support.dart'; import '../models/translation_support.dart'; + +export '../models/app_settings.dart' show ChannelNotificationMode; import '../storage/prefs_manager.dart'; import '../utils/app_logger.dart'; import '../helpers/cyr2lat.dart'; @@ -286,19 +288,36 @@ class AppSettingsService extends ChangeNotifier { await updateSettings(_settings.copyWith(unitSystem: value)); } + // Backward compatibility: delegates to AppSettings.isChannelMuted bool isChannelMuted(String channelName) { - return _settings.mutedChannels.contains(channelName); + return _settings.isChannelMuted(channelName); + } + + ChannelNotificationMode getChannelNotificationMode(String channelName) { + return _settings.channelNotificationModes[channelName] ?? + ChannelNotificationMode.all; + } + + Future setChannelNotificationMode( + String channelName, + ChannelNotificationMode mode, + ) async { + final updated = Map.from( + _settings.channelNotificationModes, + ); + updated[channelName] = mode; + await updateSettings(_settings.copyWith(channelNotificationModes: updated)); } Future muteChannel(String channelName) async { - final updated = Set.from(_settings.mutedChannels)..add(channelName); - await updateSettings(_settings.copyWith(mutedChannels: updated)); + await setChannelNotificationMode( + channelName, + ChannelNotificationMode.muted, + ); } Future unmuteChannel(String channelName) async { - final updated = Set.from(_settings.mutedChannels) - ..remove(channelName); - await updateSettings(_settings.copyWith(mutedChannels: updated)); + await setChannelNotificationMode(channelName, ChannelNotificationMode.all); } Future setTcpServerAddress(String value) async { diff --git a/untranslated.json b/untranslated.json index 9e26dfee..a2f434b5 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1,113 @@ -{} \ No newline at end of file +{ + "bg": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "de": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "es": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "hu": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "it": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "ja": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "ko": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "nl": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "pl": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "pt": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "ru": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "sk": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "sl": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "sv": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "uk": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ], + + "zh": [ + "channels_notificationSettings", + "channels_notifyAll", + "channels_notifyMentionsOnly", + "channels_notifyNone" + ] +} From 09e9208108563d843404dc22053b4cd4963ebaf1 Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 23 Oct 2026 23:31:11 +0200 Subject: [PATCH 04/16] Update notification mode strings with verified translations - Add channels_notifyAll, channels_notifyMentionsOnly, channels_notifyNone to all 18 language ARB files - Add channels_notificationSettings to all ARB files for consistency (was missing in 16 languages) - Remove redundant "(@)" suffix from mentions only mode - All translations verified for accuracy - Special fix: Slovak "Iba spomienky" -> "Iba zmienky" (mentions, not memories) - Update all localization Dart files via flutter gen-l10n - Update documentation table with proper icons - Update untranslated.json --- documentation/notifications.md | 6 +- lib/connector/meshcore_connector.dart | 51 ++++++++---- lib/l10n/app_bg.arb | 4 + lib/l10n/app_de.arb | 4 + lib/l10n/app_en.arb | 2 +- lib/l10n/app_es.arb | 4 + lib/l10n/app_fr.arb | 2 +- lib/l10n/app_hu.arb | 4 + lib/l10n/app_it.arb | 4 + lib/l10n/app_ja.arb | 4 + lib/l10n/app_ko.arb | 4 + lib/l10n/app_localizations.dart | 2 +- lib/l10n/app_localizations_bg.dart | 8 +- lib/l10n/app_localizations_de.dart | 8 +- lib/l10n/app_localizations_en.dart | 2 +- lib/l10n/app_localizations_es.dart | 8 +- lib/l10n/app_localizations_fr.dart | 2 +- lib/l10n/app_localizations_hu.dart | 8 +- lib/l10n/app_localizations_it.dart | 8 +- lib/l10n/app_localizations_ja.dart | 8 +- lib/l10n/app_localizations_ko.dart | 8 +- lib/l10n/app_localizations_nl.dart | 8 +- lib/l10n/app_localizations_pl.dart | 8 +- lib/l10n/app_localizations_pt.dart | 8 +- lib/l10n/app_localizations_ru.dart | 8 +- lib/l10n/app_localizations_sk.dart | 8 +- lib/l10n/app_localizations_sl.dart | 8 +- lib/l10n/app_localizations_sv.dart | 8 +- lib/l10n/app_localizations_uk.dart | 8 +- lib/l10n/app_localizations_zh.dart | 8 +- lib/l10n/app_nl.arb | 4 + lib/l10n/app_pl.arb | 4 + lib/l10n/app_pt.arb | 4 + lib/l10n/app_ru.arb | 4 + lib/l10n/app_sk.arb | 4 + lib/l10n/app_sl.arb | 4 + lib/l10n/app_sv.arb | 4 + lib/l10n/app_uk.arb | 4 + lib/l10n/app_zh.arb | 4 + lib/screens/channel_chat_screen.dart | 4 +- lib/screens/channels_screen.dart | 4 +- untranslated.json | 114 +------------------------- 42 files changed, 178 insertions(+), 203 deletions(-) diff --git a/documentation/notifications.md b/documentation/notifications.md index c84c35d7..d6f3f903 100644 --- a/documentation/notifications.md +++ b/documentation/notifications.md @@ -106,8 +106,8 @@ Each channel supports three notification modes: | Mode | Icon | Behavior | |---|---|---| | **All messages** | 🔔 | Receive notifications for every message | -| **Mentions only (@)** | @ | Only notify when someone mentions you with "@yourname" | -| **Muted** | 🔇 | No notifications | +| **Mentions only** | 🔔 | Only notify when someone mentions you with "@yourname" or replies to your messages | +| **Muted** | 🔕 | No notifications | Set the mode from: @@ -115,7 +115,7 @@ Set the mode from: - Long-press a channel in the channels list → **Notification settings** → select mode - Channel notification actions (Android) -Mentions are detected by looking for "@" followed by your username at word boundaries. The comparison is case-insensitive. +Mentions are detected by looking for "@" followed by your username at word boundaries (case-insensitive), or when someone replies to one of your messages. Reply detection checks if the message is a direct reply to a message you sent. ## Rate Limiting diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 783d5061..7e96a3a3 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -7369,9 +7369,9 @@ class MeshCoreConnector extends ChangeNotifier { ? translationResult.translatedText.trim() : message.text.trim(); - // If mode is mentionsOnly, check if message mentions us + // If mode is mentionsOnly, check if message mentions us or is a reply to us if (notificationMode == ChannelNotificationMode.mentionsOnly) { - if (!_doesMessageMentionUs(resolvedText)) return; + if (!_doesMessageMentionUs(resolvedText, message)) return; } unawaited(() async { @@ -7386,20 +7386,43 @@ class MeshCoreConnector extends ChangeNotifier { }()); } - /// Checks if a message text mentions the current user. - /// Looks for "@username" pattern where username matches our self name. - bool _doesMessageMentionUs(String messageText) { + /// Checks if a message mentions the current user. + /// Detects: @username, @1234 (last 4 hex chars of node ID), or replies to our messages. + bool _doesMessageMentionUs(String messageText, ChannelMessage message) { final selfName = _selfName; - if (selfName == null || selfName.isEmpty) return false; - + final selfPubKeyHex = selfPublicKeyHex; + + // Check if this is a reply to our message + if (message.replyToSenderName != null) { + final lowerSelfName = selfName?.toLowerCase(); + final lowerReplyToSender = message.replyToSenderName!.toLowerCase(); + if (lowerSelfName != null && lowerSelfName.isNotEmpty && + lowerReplyToSender == lowerSelfName) { + return true; + } + } + // Check for @username at word boundaries (start of message or after whitespace) - // Case-insensitive comparison - final lowerSelfName = selfName.toLowerCase(); - final lowerMessage = messageText.toLowerCase(); - final mentionPattern = RegExp( - r'\b@(' + RegExp.escape(lowerSelfName) + r')\b', - ); - return mentionPattern.hasMatch(lowerMessage); + if (selfName != null && selfName.isNotEmpty) { + final lowerSelfName = selfName.toLowerCase(); + final lowerMessage = messageText.toLowerCase(); + final mentionPattern = RegExp( + r'\b@(' + RegExp.escape(lowerSelfName) + r')\b', + ); + if (mentionPattern.hasMatch(lowerMessage)) return true; + } + + // Check for @1234 pattern (last 4 hex chars of public key) + if (selfPubKeyHex.length >= 4) { + final last4Hex = selfPubKeyHex.substring(selfPubKeyHex.length - 4); + final lowerMessage = messageText.toLowerCase(); + final hexMentionPattern = RegExp( + r'\b@(' + RegExp.escape(last4Hex.toLowerCase()) + r')\b', + ); + if (hexMentionPattern.hasMatch(lowerMessage)) return true; + } + + return false; } /// Handles RESP_CODE_CHANNEL_DATA_RECV (GRP_DATA). Frames whose dataType is diff --git a/lib/l10n/app_bg.arb b/lib/l10n/app_bg.arb index 2c4dde5b..9eaa12e8 100644 --- a/lib/l10n/app_bg.arb +++ b/lib/l10n/app_bg.arb @@ -359,6 +359,10 @@ "channels_public": "Публично", "channels_private": "Частен", "channels_editChannel": "Редактирай канал", + "channels_notificationSettings": "Настройки за известия", + "channels_notifyAll": "Всички съобщения", + "channels_notifyMentionsOnly": "Само споменавания", + "channels_notifyNone": "Заглушено", "channels_muteChannel": "Заглуши канала", "channels_unmuteChannel": "Включи известията на канала", "channels_deleteChannel": "Изтрий канала", diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 1d12ad59..01e6b3b9 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -369,6 +369,10 @@ "channels_public": "Öffentlich", "channels_private": "Privat", "channels_editChannel": "Kanal bearbeiten", + "channels_notificationSettings": "Benachrichtigungseinstellungen", + "channels_notifyAll": "Alle Nachrichten", + "channels_notifyMentionsOnly": "Nur Erwähnungen", + "channels_notifyNone": "Stummgeschaltet", "channels_muteChannel": "Kanal stummschalten", "channels_unmuteChannel": "Kanal Stummschaltung aufheben", "channels_deleteChannel": "Kanal löschen", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 820271a3..2b28c76d 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -717,7 +717,7 @@ "channels_editChannel": "Edit channel", "channels_notificationSettings": "Notification settings", "channels_notifyAll": "All messages", - "channels_notifyMentionsOnly": "Mentions only (@)", + "channels_notifyMentionsOnly": "Mentions only", "channels_notifyNone": "Muted", "channels_muteChannel": "Mute channel", "channels_unmuteChannel": "Unmute channel", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 9023e268..7db9569c 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -369,6 +369,10 @@ "channels_public": "Público", "channels_private": "Privado", "channels_editChannel": "Editar canal", + "channels_notificationSettings": "Configuración de notificaciones", + "channels_notifyAll": "Todos los mensajes", + "channels_notifyMentionsOnly": "Solo menciones", + "channels_notifyNone": "Silenciado", "channels_muteChannel": "Silenciar canal", "channels_unmuteChannel": "Activar canal", "channels_deleteChannel": "Eliminar canal", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 0c37b31b..c297db56 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -371,7 +371,7 @@ "channels_editChannel": "Modifier le canal", "channels_notificationSettings": "Paramètres des notifications", "channels_notifyAll": "Tous les messages", - "channels_notifyMentionsOnly": "Mentions uniquement (@)", + "channels_notifyMentionsOnly": "Mentions uniquement", "channels_notifyNone": "Désactivé", "channels_muteChannel": "Désactiver les notifications du canal", "channels_unmuteChannel": "Réactiver les notifications du canal", diff --git a/lib/l10n/app_hu.arb b/lib/l10n/app_hu.arb index 9f0bfee3..3e26d1b1 100644 --- a/lib/l10n/app_hu.arb +++ b/lib/l10n/app_hu.arb @@ -511,6 +511,10 @@ "channels_public": "Nyilvános", "channels_private": "Magán", "channels_editChannel": "Csatorna szerkesztése", + "channels_notificationSettings": "Értesítési beállítások", + "channels_notifyAll": "Összes üzenet", + "channels_notifyMentionsOnly": "Csak említések", + "channels_notifyNone": "Némít", "channels_muteChannel": "Csatorna némítása", "channels_unmuteChannel": "Csatorna némításának feloldása", "channels_deleteChannel": "Csatorna törlése", diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 89a86aad..dcc3e998 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -414,6 +414,10 @@ "channels_public": "Pubblico", "channels_private": "Privato", "channels_editChannel": "Modifica canale", + "channels_notificationSettings": "Impostazioni notifiche", + "channels_notifyAll": "Tutti i messaggi", + "channels_notifyMentionsOnly": "Solo menzioni", + "channels_notifyNone": "Silenziato", "channels_muteChannel": "Silenzia canale", "channels_unmuteChannel": "Attiva notifiche canale", "channels_deleteChannel": "Elimina canale", diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index 468d0d16..117555c3 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -517,6 +517,10 @@ "channels_public": "公開", "channels_private": "非公開", "channels_editChannel": "チャンネルを編集", + "channels_notificationSettings": "通知設定", + "channels_notifyAll": "すべてのメッセージ", + "channels_notifyMentionsOnly": "メンションのみ", + "channels_notifyNone": "ミュート", "channels_muteChannel": "チャンネルをミュート", "channels_unmuteChannel": "チャンネルのミュートを解除", "channels_deleteChannel": "チャンネルを削除", diff --git a/lib/l10n/app_ko.arb b/lib/l10n/app_ko.arb index 38869f9a..62ab3ad4 100644 --- a/lib/l10n/app_ko.arb +++ b/lib/l10n/app_ko.arb @@ -511,6 +511,10 @@ "channels_public": "대중의", "channels_private": "사립", "channels_editChannel": "채널 편집", + "channels_notificationSettings": "알림 설정", + "channels_notifyAll": "모든 메시지", + "channels_notifyMentionsOnly": "언급만", + "channels_notifyNone": "음소거", "channels_muteChannel": "음소거 채널", "channels_unmuteChannel": "채널 음소거 해제", "channels_deleteChannel": "채널 삭제", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 3596db1a..b4168cc6 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -2635,7 +2635,7 @@ abstract class AppLocalizations { /// No description provided for @channels_notifyMentionsOnly. /// /// In en, this message translates to: - /// **'Mentions only (@)'** + /// **'Mentions only'** String get channels_notifyMentionsOnly; /// No description provided for @channels_notifyNone. diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 6f260891..e4fea0e2 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -1465,16 +1465,16 @@ class AppLocalizationsBg extends AppLocalizations { String get channels_editChannel => 'Редактирай канал'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Настройки за известия'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Всички съобщения'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Само споменавания'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Заглушено'; @override String get channels_muteChannel => 'Заглуши канала'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index ddf10b8c..9d7a3f43 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1459,16 +1459,16 @@ class AppLocalizationsDe extends AppLocalizations { String get channels_editChannel => 'Kanal bearbeiten'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Benachrichtigungseinstellungen'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Alle Nachrichten'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Nur Erwähnungen'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Stummgeschaltet'; @override String get channels_muteChannel => 'Kanal stummschalten'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 4bf9b610..fb20008b 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1445,7 +1445,7 @@ class AppLocalizationsEn extends AppLocalizations { String get channels_notifyAll => 'All messages'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Mentions only'; @override String get channels_notifyNone => 'Muted'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 2345ac55..e1ad4fa2 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1458,16 +1458,16 @@ class AppLocalizationsEs extends AppLocalizations { String get channels_editChannel => 'Editar canal'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Configuración de notificaciones'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Todos los mensajes'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Solo menciones'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Silenciado'; @override String get channels_muteChannel => 'Silenciar canal'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index bed96b71..f3318265 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1469,7 +1469,7 @@ class AppLocalizationsFr extends AppLocalizations { String get channels_notifyAll => 'Tous les messages'; @override - String get channels_notifyMentionsOnly => 'Mentions uniquement (@)'; + String get channels_notifyMentionsOnly => 'Mentions uniquement'; @override String get channels_notifyNone => 'Désactivé'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 9e81cf47..21d40309 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1454,16 +1454,16 @@ class AppLocalizationsHu extends AppLocalizations { String get channels_editChannel => 'Csatorna szerkesztése'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Értesítési beállítások'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Összes üzenet'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Csak említések'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Némít'; @override String get channels_muteChannel => 'Csatorna némítása'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 5fec4210..fdc44f4a 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1462,16 +1462,16 @@ class AppLocalizationsIt extends AppLocalizations { String get channels_editChannel => 'Modifica canale'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Impostazioni notifiche'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Tutti i messaggi'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Solo menzioni'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Silenziato'; @override String get channels_muteChannel => 'Silenzia canale'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 57da4dfc..80aa0c8d 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1386,16 +1386,16 @@ class AppLocalizationsJa extends AppLocalizations { String get channels_editChannel => 'チャンネルを編集'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => '通知設定'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'すべてのメッセージ'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'メンションのみ'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'ミュート'; @override String get channels_muteChannel => 'チャンネルをミュート'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 1221475f..90181a0c 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1391,16 +1391,16 @@ class AppLocalizationsKo extends AppLocalizations { String get channels_editChannel => '채널 편집'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => '알림 설정'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => '모든 메시지'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => '언급만'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => '음소거'; @override String get channels_muteChannel => '음소거 채널'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 84075f13..b4c40d64 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1450,16 +1450,16 @@ class AppLocalizationsNl extends AppLocalizations { String get channels_editChannel => 'Kanaal bewerken'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Meldingsinstellingen'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Alle berichten'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Alleen vermeldingen'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Gedempt'; @override String get channels_muteChannel => 'Kanaal dempen'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 71700e5d..10fe2d7f 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1476,16 +1476,16 @@ class AppLocalizationsPl extends AppLocalizations { String get channels_editChannel => 'Edytuj kanał'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Ustawienia powiadomień'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Wszystkie wiadomości'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Tylko wzmianki'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Wyciszone'; @override String get channels_muteChannel => 'Wycisz kanał'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 1b9305f1..2a9ceae6 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1461,16 +1461,16 @@ class AppLocalizationsPt extends AppLocalizations { String get channels_editChannel => 'Editar canal'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Configurações de notificação'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Todas as mensagens'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Apenas menções'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Silenciado'; @override String get channels_muteChannel => 'Silenciar canal'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 57080935..f8eb322b 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1465,16 +1465,16 @@ class AppLocalizationsRu extends AppLocalizations { String get channels_editChannel => 'Изменить канал'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Настройки уведомлений'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Все сообщения'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Только упоминания'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Без звука'; @override String get channels_muteChannel => 'Отключить уведомления канала'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 0491a952..46b074bd 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1453,16 +1453,16 @@ class AppLocalizationsSk extends AppLocalizations { String get channels_editChannel => 'Upraviť kanál'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Nastavenia notifikácií'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Všetky správy'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Iba zmienky'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Stíšené'; @override String get channels_muteChannel => 'Stlmiť kanál'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 9b247612..696b59f9 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1451,16 +1451,16 @@ class AppLocalizationsSl extends AppLocalizations { String get channels_editChannel => 'Uredi kanal'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Nastavitve obvestil'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Vsa sporočila'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Samo omembe'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Utišano'; @override String get channels_muteChannel => 'Utišaj kanal'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index ac13e6aa..1593d3de 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1440,16 +1440,16 @@ class AppLocalizationsSv extends AppLocalizations { String get channels_editChannel => 'Redigera kanal'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Aviseringsinställningar'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Alla meddelanden'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Endast omnämnanden'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Tyst'; @override String get channels_muteChannel => 'Tysta kanal'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index c4aa6b8f..369dda90 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1456,16 +1456,16 @@ class AppLocalizationsUk extends AppLocalizations { String get channels_editChannel => 'Редагувати канал'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => 'Налаштування сповіщень'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => 'Усі повідомлення'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => 'Лише згадки'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => 'Вимкнено'; @override String get channels_muteChannel => 'Вимкнути сповіщення каналу'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 825f7954..ac397a39 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1368,16 +1368,16 @@ class AppLocalizationsZh extends AppLocalizations { String get channels_editChannel => '编辑频道'; @override - String get channels_notificationSettings => 'Notification settings'; + String get channels_notificationSettings => '通知设置'; @override - String get channels_notifyAll => 'All messages'; + String get channels_notifyAll => '所有消息'; @override - String get channels_notifyMentionsOnly => 'Mentions only (@)'; + String get channels_notifyMentionsOnly => '仅提及'; @override - String get channels_notifyNone => 'Muted'; + String get channels_notifyNone => '静音'; @override String get channels_muteChannel => '静音频道'; diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index 4f7d8d61..3cbd275f 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -375,6 +375,10 @@ "channels_addSectionCreate": "Nieuw aanmaken", "channels_dragToReorder": "Sleep om te herschikken", "channels_editChannel": "Kanaal bewerken", + "channels_notificationSettings": "Meldingsinstellingen", + "channels_notifyAll": "Alle berichten", + "channels_notifyMentionsOnly": "Alleen vermeldingen", + "channels_notifyNone": "Gedempt", "channels_muteChannel": "Kanaal dempen", "channels_unmuteChannel": "Kanaal dempen opheffen", "channels_deleteChannel": "Kanaal verwijderen", diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index 77ca42b7..eb429796 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -369,6 +369,10 @@ "channels_public": "Publiczny", "channels_private": "Prywatny", "channels_editChannel": "Edytuj kanał", + "channels_notificationSettings": "Ustawienia powiadomień", + "channels_notifyAll": "Wszystkie wiadomości", + "channels_notifyMentionsOnly": "Tylko wzmianki", + "channels_notifyNone": "Wyciszone", "channels_muteChannel": "Wycisz kanał", "channels_unmuteChannel": "Wyłącz wyciszenie kanału", "channels_deleteChannel": "Usuń kanał", diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index d211e265..997bd295 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -359,6 +359,10 @@ "channels_public": "Público", "channels_private": "Privado", "channels_editChannel": "Editar canal", + "channels_notificationSettings": "Configurações de notificação", + "channels_notifyAll": "Todas as mensagens", + "channels_notifyMentionsOnly": "Apenas menções", + "channels_notifyNone": "Silenciado", "channels_muteChannel": "Silenciar canal", "channels_unmuteChannel": "Ativar canal", "channels_deleteChannel": "Excluir canal", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index f2d3baeb..d8b9ff79 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -251,6 +251,10 @@ "channels_public": "Публичный", "channels_private": "Приватный", "channels_editChannel": "Изменить канал", + "channels_notificationSettings": "Настройки уведомлений", + "channels_notifyAll": "Все сообщения", + "channels_notifyMentionsOnly": "Только упоминания", + "channels_notifyNone": "Без звука", "channels_muteChannel": "Отключить уведомления канала", "channels_unmuteChannel": "Включить уведомления канала", "channels_deleteChannel": "Удалить канал", diff --git a/lib/l10n/app_sk.arb b/lib/l10n/app_sk.arb index d2525a42..58454b8b 100644 --- a/lib/l10n/app_sk.arb +++ b/lib/l10n/app_sk.arb @@ -359,6 +359,10 @@ "channels_public": "Veľké verejné", "channels_private": "Osobné", "channels_editChannel": "Upraviť kanál", + "channels_notificationSettings": "Nastavenia notifikácií", + "channels_notifyAll": "Všetky správy", + "channels_notifyMentionsOnly": "Iba zmienky", + "channels_notifyNone": "Stíšené", "channels_muteChannel": "Stlmiť kanál", "channels_unmuteChannel": "Zrušiť stlmenie kanála", "channels_deleteChannel": "Odstrániť kanál", diff --git a/lib/l10n/app_sl.arb b/lib/l10n/app_sl.arb index 5bc612a0..2e9fcdc0 100644 --- a/lib/l10n/app_sl.arb +++ b/lib/l10n/app_sl.arb @@ -359,6 +359,10 @@ "channels_public": "Javni", "channels_private": "Zasebni", "channels_editChannel": "Uredi kanal", + "channels_notificationSettings": "Nastavitve obvestil", + "channels_notifyAll": "Vsa sporočila", + "channels_notifyMentionsOnly": "Samo omembe", + "channels_notifyNone": "Utišano", "channels_muteChannel": "Utišaj kanal", "channels_unmuteChannel": "Vklopi obvestila kanala", "channels_deleteChannel": "Pošlji kanal", diff --git a/lib/l10n/app_sv.arb b/lib/l10n/app_sv.arb index 1857b8a5..a138085a 100644 --- a/lib/l10n/app_sv.arb +++ b/lib/l10n/app_sv.arb @@ -359,6 +359,10 @@ "channels_public": "Publik", "channels_private": "Privat", "channels_editChannel": "Redigera kanal", + "channels_notificationSettings": "Aviseringsinställningar", + "channels_notifyAll": "Alla meddelanden", + "channels_notifyMentionsOnly": "Endast omnämnanden", + "channels_notifyNone": "Tyst", "channels_muteChannel": "Tysta kanal", "channels_unmuteChannel": "Slå på ljud för kanal", "channels_deleteChannel": "Ta bort kanal", diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index d8d3b7db..d7cee3fc 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -362,6 +362,10 @@ "channels_via": "через {path}", "channels_private": "Приватний", "channels_editChannel": "Редагувати канал", + "channels_notificationSettings": "Налаштування сповіщень", + "channels_notifyAll": "Усі повідомлення", + "channels_notifyMentionsOnly": "Лише згадки", + "channels_notifyNone": "Вимкнено", "channels_muteChannel": "Вимкнути сповіщення каналу", "channels_unmuteChannel": "Увімкнути сповіщення каналу", "channels_deleteChannel": "Видалити канал", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 410b3a42..644435c8 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -374,6 +374,10 @@ "channels_public": "公共", "channels_private": "私有", "channels_editChannel": "编辑频道", + "channels_notificationSettings": "通知设置", + "channels_notifyAll": "所有消息", + "channels_notifyMentionsOnly": "仅提及", + "channels_notifyNone": "静音", "channels_muteChannel": "静音频道", "channels_unmuteChannel": "取消静音频道", "channels_deleteChannel": "删除频道", diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index a71e7cce..e39bb5f5 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -413,7 +413,7 @@ class _ChannelChatScreenState extends State { notificationMode == ChannelNotificationMode.muted ? Icons.notifications_off_outlined : notificationMode == ChannelNotificationMode.mentionsOnly - ? Icons.alternate_email + ? Icons.notification_important : Icons.notifications_outlined, ), onSelected: (mode) { @@ -439,7 +439,7 @@ class _ChannelChatScreenState extends State { value: ChannelNotificationMode.mentionsOnly, child: Row( children: [ - const Icon(Icons.alternate_email), + const Icon(Icons.notification_important), const SizedBox(width: 8), Text(context.l10n.channels_notifyMentionsOnly), ], diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index 8e03112e..a16be11d 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -585,7 +585,7 @@ class _ChannelsScreenState extends State Icon( notificationMode == ChannelNotificationMode.muted ? Icons.notifications_off - : Icons.alternate_email, + : Icons.notification_important, size: 18, color: scheme.onSurfaceVariant, ), @@ -719,7 +719,7 @@ class _ChannelsScreenState extends State ), // Mentions only ListTile( - leading: const Icon(Icons.alternate_email), + leading: const Icon(Icons.notification_important), title: Text(sheetContext.l10n.channels_notifyMentionsOnly), trailing: currentMode == ChannelNotificationMode.mentionsOnly ? const Icon(Icons.check) diff --git a/untranslated.json b/untranslated.json index a2f434b5..9e26dfee 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1,113 +1 @@ -{ - "bg": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "de": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "es": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "hu": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "it": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "ja": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "ko": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "nl": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "pl": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "pt": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "ru": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "sk": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "sl": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "sv": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "uk": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ], - - "zh": [ - "channels_notificationSettings", - "channels_notifyAll", - "channels_notifyMentionsOnly", - "channels_notifyNone" - ] -} +{} \ No newline at end of file From 363c413717c6690af809bfd9dc71e0e88a51614d Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 04:57:23 +0200 Subject: [PATCH 05/16] Update notification icons for consistency - Use outlined icons for buttons (PopupMenuButton) - Use normal icons for menu items (PopupMenuItem/ListTile) - Ensure icon consistency across all notification mode displays - Verify no regressions in existing functionality --- lib/screens/channel_chat_screen.dart | 4 ++-- lib/screens/channels_screen.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index e39bb5f5..7da13af4 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -413,7 +413,7 @@ class _ChannelChatScreenState extends State { notificationMode == ChannelNotificationMode.muted ? Icons.notifications_off_outlined : notificationMode == ChannelNotificationMode.mentionsOnly - ? Icons.notification_important + ? Icons.notification_important_outlined : Icons.notifications_outlined, ), onSelected: (mode) { @@ -425,7 +425,7 @@ class _ChannelChatScreenState extends State { child: Row( children: [ Icon( - Icons.notifications_active, + Icons.notifications, color: notificationMode == ChannelNotificationMode.all ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onSurfaceVariant, diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index a16be11d..beaac2cc 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -700,7 +700,7 @@ class _ChannelsScreenState extends State // All notifications ListTile( leading: Icon( - Icons.notifications_active, + Icons.notifications, color: currentMode == ChannelNotificationMode.all ? Theme.of(sheetContext).colorScheme.primary : Theme.of(sheetContext).colorScheme.onSurfaceVariant, From 14230952c95a5be0f4f8340a3c30fa308af834c9 Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 05:07:28 +0200 Subject: [PATCH 06/16] Update notifications icons for better clarity and interface look and coherence --- lib/screens/channel_chat_screen.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 7da13af4..647c5508 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -411,10 +411,10 @@ class _ChannelChatScreenState extends State { tooltip: context.l10n.channels_notificationSettings, icon: Icon( notificationMode == ChannelNotificationMode.muted - ? Icons.notifications_off_outlined + ? Icons.notifications_off : notificationMode == ChannelNotificationMode.mentionsOnly - ? Icons.notification_important_outlined - : Icons.notifications_outlined, + ? Icons.notification_important + : Icons.notifications, ), onSelected: (mode) { settings.setChannelNotificationMode(muteKey, mode); From f77c959e4ad4f7183e2a6f298929cf28a622cd02 Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 06:14:18 +0200 Subject: [PATCH 07/16] UI: Replace notification menu with toggle button in channel chat --- lib/screens/channel_chat_screen.dart | 58 ++++++---------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 647c5508..80818747 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -407,7 +407,7 @@ class _ChannelChatScreenState extends State { final notificationMode = settings.getChannelNotificationMode( muteKey, ); - return PopupMenuButton( + return IconButton( tooltip: context.l10n.channels_notificationSettings, icon: Icon( notificationMode == ChannelNotificationMode.muted @@ -416,52 +416,18 @@ class _ChannelChatScreenState extends State { ? Icons.notification_important : Icons.notifications, ), - onSelected: (mode) { - settings.setChannelNotificationMode(muteKey, mode); + onPressed: () { + final currentMode = settings.getChannelNotificationMode(muteKey); + ChannelNotificationMode newMode; + if (currentMode == ChannelNotificationMode.all) { + newMode = ChannelNotificationMode.mentionsOnly; + } else if (currentMode == ChannelNotificationMode.mentionsOnly) { + newMode = ChannelNotificationMode.muted; + } else { + newMode = ChannelNotificationMode.all; + } + settings.setChannelNotificationMode(muteKey, newMode); }, - itemBuilder: (context) => [ - PopupMenuItem( - value: ChannelNotificationMode.all, - child: Row( - children: [ - Icon( - Icons.notifications, - color: notificationMode == ChannelNotificationMode.all - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.onSurfaceVariant, - ), - const SizedBox(width: 8), - Text(context.l10n.channels_notifyAll), - ], - ), - ), - PopupMenuItem( - value: ChannelNotificationMode.mentionsOnly, - child: Row( - children: [ - const Icon(Icons.notification_important), - const SizedBox(width: 8), - Text(context.l10n.channels_notifyMentionsOnly), - ], - ), - ), - PopupMenuItem( - value: ChannelNotificationMode.muted, - child: Row( - children: [ - Icon( - Icons.notifications_off, - color: - notificationMode == ChannelNotificationMode.muted - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.onSurfaceVariant, - ), - const SizedBox(width: 8), - Text(context.l10n.channels_notifyNone), - ], - ), - ), - ], ); }, ), From 401b81475a2d209851abc2a5f1088a2ae357c525 Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 06:14:36 +0200 Subject: [PATCH 08/16] =?UTF-8?q?Fix=20documentation=20table=20to=20use=20?= =?UTF-8?q?distinct=20icons=20(=F0=9F=94=94/=F0=9F=94=94!/=F0=9F=94=95)=20?= =?UTF-8?q?for=20the=203=20modes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/notifications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/notifications.md b/documentation/notifications.md index d6f3f903..ee2aca91 100644 --- a/documentation/notifications.md +++ b/documentation/notifications.md @@ -106,7 +106,7 @@ Each channel supports three notification modes: | Mode | Icon | Behavior | |---|---|---| | **All messages** | 🔔 | Receive notifications for every message | -| **Mentions only** | 🔔 | Only notify when someone mentions you with "@yourname" or replies to your messages | +| **Mentions only** | 🔔! | Only notify when someone mentions you with "@yourname" or replies to your messages | | **Muted** | 🔕 | No notifications | Set the mode from: From 1c3fc7c2ecb7853f83ad92d0603effcf08105021 Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 08:34:46 +0200 Subject: [PATCH 09/16] fix mention detection to match @[pseudo] --- lib/connector/meshcore_connector.dart | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 7e96a3a3..2432b31a 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -7387,10 +7387,9 @@ class MeshCoreConnector extends ChangeNotifier { } /// Checks if a message mentions the current user. - /// Detects: @username, @1234 (last 4 hex chars of node ID), or replies to our messages. + /// Detects: @[username] format only. bool _doesMessageMentionUs(String messageText, ChannelMessage message) { final selfName = _selfName; - final selfPubKeyHex = selfPublicKeyHex; // Check if this is a reply to our message if (message.replyToSenderName != null) { @@ -7402,24 +7401,15 @@ class MeshCoreConnector extends ChangeNotifier { } } - // Check for @username at word boundaries (start of message or after whitespace) + final lowerMessage = messageText.toLowerCase(); + + // Check for @[username] pattern (bracketed mention format) if (selfName != null && selfName.isNotEmpty) { final lowerSelfName = selfName.toLowerCase(); - final lowerMessage = messageText.toLowerCase(); - final mentionPattern = RegExp( - r'\b@(' + RegExp.escape(lowerSelfName) + r')\b', + final bracketedMentionPattern = RegExp( + r'@\[(' + RegExp.escape(lowerSelfName) + r')\]', ); - if (mentionPattern.hasMatch(lowerMessage)) return true; - } - - // Check for @1234 pattern (last 4 hex chars of public key) - if (selfPubKeyHex.length >= 4) { - final last4Hex = selfPubKeyHex.substring(selfPubKeyHex.length - 4); - final lowerMessage = messageText.toLowerCase(); - final hexMentionPattern = RegExp( - r'\b@(' + RegExp.escape(last4Hex.toLowerCase()) + r')\b', - ); - if (hexMentionPattern.hasMatch(lowerMessage)) return true; + if (bracketedMentionPattern.hasMatch(lowerMessage)) return true; } return false; From e0ce8dc6b801056cca070d66139c2bc23310e79f Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 08:35:31 +0200 Subject: [PATCH 10/16] update mention detection pattern --- documentation/notifications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/notifications.md b/documentation/notifications.md index ee2aca91..47447f5a 100644 --- a/documentation/notifications.md +++ b/documentation/notifications.md @@ -106,7 +106,7 @@ Each channel supports three notification modes: | Mode | Icon | Behavior | |---|---|---| | **All messages** | 🔔 | Receive notifications for every message | -| **Mentions only** | 🔔! | Only notify when someone mentions you with "@yourname" or replies to your messages | +| **Mentions only** | 🔔! | Only notify when someone mentions you with "@[yourname]" or replies to your messages | | **Muted** | 🔕 | No notifications | Set the mode from: @@ -115,7 +115,7 @@ Set the mode from: - Long-press a channel in the channels list → **Notification settings** → select mode - Channel notification actions (Android) -Mentions are detected by looking for "@" followed by your username at word boundaries (case-insensitive), or when someone replies to one of your messages. Reply detection checks if the message is a direct reply to a message you sent. +Mentions are detected by looking for "@[yourname]" (username in brackets, case-insensitive), or when someone replies to one of your messages. Reply detection checks if the message is a direct reply to a message you sent. ## Rate Limiting From 2e1c871ef1beb45336c3a2616b1da6a1fc9adb92 Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 15:20:27 +0200 Subject: [PATCH 11/16] remove useless reply detection pattern becose both app @[pseudo] by default on reply --- lib/connector/meshcore_connector.dart | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 2432b31a..9e9bbdfe 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -7369,7 +7369,7 @@ class MeshCoreConnector extends ChangeNotifier { ? translationResult.translatedText.trim() : message.text.trim(); - // If mode is mentionsOnly, check if message mentions us or is a reply to us + // If mode is mentionsOnly, check if message mentions us if (notificationMode == ChannelNotificationMode.mentionsOnly) { if (!_doesMessageMentionUs(resolvedText, message)) return; } @@ -7390,17 +7390,6 @@ class MeshCoreConnector extends ChangeNotifier { /// Detects: @[username] format only. bool _doesMessageMentionUs(String messageText, ChannelMessage message) { final selfName = _selfName; - - // Check if this is a reply to our message - if (message.replyToSenderName != null) { - final lowerSelfName = selfName?.toLowerCase(); - final lowerReplyToSender = message.replyToSenderName!.toLowerCase(); - if (lowerSelfName != null && lowerSelfName.isNotEmpty && - lowerReplyToSender == lowerSelfName) { - return true; - } - } - final lowerMessage = messageText.toLowerCase(); // Check for @[username] pattern (bracketed mention format) From 9f358461e79d44becb7c827b99bb84bef1a5645c Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 15:23:52 +0200 Subject: [PATCH 12/16] update notif docs becose of deleted specific ans redundant reply detection --- documentation/notifications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/notifications.md b/documentation/notifications.md index 47447f5a..8bdc5d6c 100644 --- a/documentation/notifications.md +++ b/documentation/notifications.md @@ -106,7 +106,7 @@ Each channel supports three notification modes: | Mode | Icon | Behavior | |---|---|---| | **All messages** | 🔔 | Receive notifications for every message | -| **Mentions only** | 🔔! | Only notify when someone mentions you with "@[yourname]" or replies to your messages | +| **Mentions only** | 🔔! | Only notify when someone mentions you with "@[yourname]" | | **Muted** | 🔕 | No notifications | Set the mode from: @@ -115,7 +115,7 @@ Set the mode from: - Long-press a channel in the channels list → **Notification settings** → select mode - Channel notification actions (Android) -Mentions are detected by looking for "@[yourname]" (username in brackets, case-insensitive), or when someone replies to one of your messages. Reply detection checks if the message is a direct reply to a message you sent. +Mentions are detected by looking for "@[yourname]" (username in brackets, case-insensitive). ## Rate Limiting From 705bff2f1553d558285d60767612363c857cb3b7 Mon Sep 17 00:00:00 2001 From: edouard Date: Sat, 24 Oct 2026 15:26:43 +0200 Subject: [PATCH 13/16] format code --- lib/connector/meshcore_connector.dart | 4 ++-- lib/screens/channel_chat_screen.dart | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 9e9bbdfe..7777d60f 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -7391,7 +7391,7 @@ class MeshCoreConnector extends ChangeNotifier { bool _doesMessageMentionUs(String messageText, ChannelMessage message) { final selfName = _selfName; final lowerMessage = messageText.toLowerCase(); - + // Check for @[username] pattern (bracketed mention format) if (selfName != null && selfName.isNotEmpty) { final lowerSelfName = selfName.toLowerCase(); @@ -7400,7 +7400,7 @@ class MeshCoreConnector extends ChangeNotifier { ); if (bracketedMentionPattern.hasMatch(lowerMessage)) return true; } - + return false; } diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 80818747..0a8238b8 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -417,11 +417,14 @@ class _ChannelChatScreenState extends State { : Icons.notifications, ), onPressed: () { - final currentMode = settings.getChannelNotificationMode(muteKey); + final currentMode = settings.getChannelNotificationMode( + muteKey, + ); ChannelNotificationMode newMode; if (currentMode == ChannelNotificationMode.all) { newMode = ChannelNotificationMode.mentionsOnly; - } else if (currentMode == ChannelNotificationMode.mentionsOnly) { + } else if (currentMode == + ChannelNotificationMode.mentionsOnly) { newMode = ChannelNotificationMode.muted; } else { newMode = ChannelNotificationMode.all; From 143ca57279596261e9a34e6187f7041d45cb63d2 Mon Sep 17 00:00:00 2001 From: zjs81 Date: Sat, 24 Oct 2026 20:43:00 -0700 Subject: [PATCH 14/16] Fix review findings in radio settings path hash size - Presets no longer reset the path hash size; the unused preset field is gone - Confirm the new path hash size from the refreshed DEVICE_INFO and show a specific error when the radio does not apply it - Log path hash size with the other radio settings and on manual edits - Add MeshCoreConnector.supportsPathHashMode and use it in both screens - Use the same 0-2 mode values and helper text as the other selectors --- lib/connector/meshcore_connector.dart | 3 ++ lib/l10n/app_en.arb | 1 + lib/l10n/app_localizations.dart | 6 +++ lib/l10n/app_localizations_bg.dart | 4 ++ lib/l10n/app_localizations_de.dart | 4 ++ lib/l10n/app_localizations_en.dart | 4 ++ lib/l10n/app_localizations_es.dart | 4 ++ lib/l10n/app_localizations_fr.dart | 4 ++ lib/l10n/app_localizations_hu.dart | 4 ++ lib/l10n/app_localizations_it.dart | 4 ++ lib/l10n/app_localizations_ja.dart | 4 ++ lib/l10n/app_localizations_ko.dart | 4 ++ lib/l10n/app_localizations_nl.dart | 4 ++ lib/l10n/app_localizations_pl.dart | 4 ++ lib/l10n/app_localizations_pt.dart | 4 ++ lib/l10n/app_localizations_ru.dart | 4 ++ lib/l10n/app_localizations_sk.dart | 4 ++ lib/l10n/app_localizations_sl.dart | 4 ++ lib/l10n/app_localizations_sv.dart | 4 ++ lib/l10n/app_localizations_uk.dart | 4 ++ lib/l10n/app_localizations_zh.dart | 4 ++ lib/models/radio_settings.dart | 2 - lib/screens/settings_screen.dart | 11 +--- lib/widgets/radio_settings_dialog.dart | 72 +++++++++++++++++++------- untranslated.json | 70 ++++++++++++++++++++++++- 25 files changed, 205 insertions(+), 32 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 03b03944..1d7dfa0a 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -681,6 +681,9 @@ class MeshCoreConnector extends ChangeNotifier { /// from ver code 8. bool get supportsNodeDiscover => (_firmwareVerCode ?? 0) >= 8; + /// CMD_SET_PATH_HASH_MODE exists from ver code 10 (v1.14.0). + bool get supportsPathHashMode => (_firmwareVerCode ?? 0) >= 10; + /// CMD_GET/SET_DEFAULT_FLOOD_SCOPE exist from ver code 11 (v1.15.0). bool get supportsDefaultFloodScope => (_firmwareVerCode ?? 0) >= 11; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f62a038b..6d29965a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -198,6 +198,7 @@ "settings_radioSettingsSubtitle": "Frequency, power, spreading factor", "settings_radioSettingsUpdated": "Radio settings updated", "settings_radioSettingsNotApplied": "The radio did not apply these settings", + "settings_pathHashModeNotApplied": "Radio settings were applied, but the radio did not confirm the new path hash size", "settings_regionSettings": "Regions", "settings_regionSettingsSubtitle": "Limit channel floods to an area", "settings_regionEmptyExplanation": "Regions limit flood messages to repeaters in an area. Fetch them from nearby repeaters or add one by name.", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index b5e7efc5..b7d98c28 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -862,6 +862,12 @@ abstract class AppLocalizations { /// **'The radio did not apply these settings'** String get settings_radioSettingsNotApplied; + /// No description provided for @settings_pathHashModeNotApplied. + /// + /// In en, this message translates to: + /// **'Radio settings were applied, but the radio did not confirm the new path hash size'** + String get settings_pathHashModeNotApplied; + /// No description provided for @settings_regionSettings. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index b9f79a6f..62a52ade 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -425,6 +425,10 @@ class AppLocalizationsBg extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Радиото не приложи тези настройки'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Региони'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index d7893ccf..3b45ccb5 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -427,6 +427,10 @@ class AppLocalizationsDe extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Das Funkgerät hat diese Einstellungen nicht übernommen'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regionen'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 0265ac8b..da8144d5 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -421,6 +421,10 @@ class AppLocalizationsEn extends AppLocalizations { String get settings_radioSettingsNotApplied => 'The radio did not apply these settings'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regions'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 75c2ab0e..e40f0fa2 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -425,6 +425,10 @@ class AppLocalizationsEs extends AppLocalizations { String get settings_radioSettingsNotApplied => 'La radio no aplicó esta configuración'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regiones'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 85de8bbb..3c6ee155 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -427,6 +427,10 @@ class AppLocalizationsFr extends AppLocalizations { String get settings_radioSettingsNotApplied => 'La radio n\'a pas appliqué ces paramètres'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Régions'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index ef4b3d9b..5bf2522a 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -423,6 +423,10 @@ class AppLocalizationsHu extends AppLocalizations { String get settings_radioSettingsNotApplied => 'A rádió nem alkalmazta ezeket a beállításokat'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Tájak'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 50bb49d9..bcb282ef 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -427,6 +427,10 @@ class AppLocalizationsIt extends AppLocalizations { String get settings_radioSettingsNotApplied => 'La radio non ha applicato queste impostazioni'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regioni'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 2aabf56e..7d98b2a7 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -407,6 +407,10 @@ class AppLocalizationsJa extends AppLocalizations { @override String get settings_radioSettingsNotApplied => 'ラジオがこれらの設定を適用しませんでした'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => '地域'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 98a81ac1..c2a268f9 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -407,6 +407,10 @@ class AppLocalizationsKo extends AppLocalizations { @override String get settings_radioSettingsNotApplied => '라디오가 이 설정을 적용하지 않았습니다'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => '지역'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 082f2a18..edadc900 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -423,6 +423,10 @@ class AppLocalizationsNl extends AppLocalizations { String get settings_radioSettingsNotApplied => 'De radio heeft deze instellingen niet toegepast'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regio\'s'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 3db02722..6662f4e0 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -431,6 +431,10 @@ class AppLocalizationsPl extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Radio nie zastosowało tych ustawień'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regiony'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 9b89ff31..f1943007 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -427,6 +427,10 @@ class AppLocalizationsPt extends AppLocalizations { String get settings_radioSettingsNotApplied => 'O rádio não aplicou estas configurações'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regiões'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index a1686804..c1a8ed10 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -426,6 +426,10 @@ class AppLocalizationsRu extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Радиомодуль не применил эти настройки'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Регионы'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 9cd7cc6d..a8d0887b 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -426,6 +426,10 @@ class AppLocalizationsSk extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Rádio tieto nastavenia neuplatnilo'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regiony'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 8602eb0d..2fd1903a 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -425,6 +425,10 @@ class AppLocalizationsSl extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Radio teh nastavitev ni uveljavil'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regioni'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 1d87483d..face6140 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -423,6 +423,10 @@ class AppLocalizationsSv extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Radion tillämpade inte dessa inställningar'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Regioner'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index ebd6d5eb..47888b9e 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -425,6 +425,10 @@ class AppLocalizationsUk extends AppLocalizations { String get settings_radioSettingsNotApplied => 'Радіомодуль не застосував ці налаштування'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => 'Ріси'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 703a27fe..1ab063c1 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -401,6 +401,10 @@ class AppLocalizationsZh extends AppLocalizations { @override String get settings_radioSettingsNotApplied => '收音机未应用这些设置'; + @override + String get settings_pathHashModeNotApplied => + 'Radio settings were applied, but the radio did not confirm the new path hash size'; + @override String get settings_regionSettings => '地区'; diff --git a/lib/models/radio_settings.dart b/lib/models/radio_settings.dart index 6b3eee84..f7c4709c 100644 --- a/lib/models/radio_settings.dart +++ b/lib/models/radio_settings.dart @@ -50,7 +50,6 @@ class RadioSettings { final LoRaSpreadingFactor spreadingFactor; final LoRaCodingRate codingRate; final int txPowerDbm; - final int pathHashByteWidth; RadioSettings({ required this.frequencyMHz, @@ -58,7 +57,6 @@ class RadioSettings { required this.spreadingFactor, required this.codingRate, required this.txPowerDbm, - this.pathHashByteWidth = 1, // app default; presets override if needed }); // Regional preset configurations diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index dff41c0b..74ca3e2c 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -25,9 +25,6 @@ import '../widgets/sync_progress_overlay.dart'; import 'region_management_screen.dart'; import '../utils/share_origin.dart'; -/// Companion firmware version that added CMD_SET_PATH_HASH_MODE (v1.14.0). -const int _minFirmwareVerCodeForPathHashMode = 10; - class SettingsScreen extends StatefulWidget { const SettingsScreen({super.key}); @@ -566,14 +563,10 @@ class _SettingsScreenState extends State { title: l10n.repeater_pathHashMode, subtitle: !connected ? offline - : (connector.firmwareVerCode ?? 0) < - _minFirmwareVerCodeForPathHashMode + : !connector.supportsPathHashMode ? l10n.settings_requiresFirmware('v1.14') : _pathHashModeSubtitle(context, connector.pathHashByteWidth), - onTap: - connector.isConnected && - (connector.firmwareVerCode ?? 0) >= - _minFirmwareVerCodeForPathHashMode + onTap: connector.isConnected && connector.supportsPathHashMode ? () => _editPathHashMode(context, connector) : null, ), diff --git a/lib/widgets/radio_settings_dialog.dart b/lib/widgets/radio_settings_dialog.dart index 7f9834ab..aa00e3d9 100644 --- a/lib/widgets/radio_settings_dialog.dart +++ b/lib/widgets/radio_settings_dialog.dart @@ -30,12 +30,9 @@ bool _isAllowedRepeatFreqKHz(MeshCoreConnector connector, int freqKHz) { /// Lowest TX power companion firmware accepts (CMD_SET_RADIO_TX_POWER). const int _minTxPowerDbm = -9; -/// Companion firmware version that added CMD_SET_PATH_HASH_MODE (v1.14.0). -const int _minFirmwareVerCodeForPathHashMode = 10; - -/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power and -/// off-grid client repeat). Stays open when the radio rejects or fails to -/// apply the settings so the user's edits are not lost. +/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power, +/// path-hash size and off-grid client repeat). Stays open when the radio +/// rejects or fails to apply the settings so the user's edits are not lost. class RadioSettingsDialog extends StatefulWidget { final MeshCoreConnector connector; @@ -58,9 +55,7 @@ class _RadioSettingsDialogState extends State { String? _frequencyError; String? _txPowerError; - bool get _supportsPathHashMode => - (widget.connector.firmwareVerCode ?? 0) >= - _minFirmwareVerCodeForPathHashMode; + bool get _supportsPathHashMode => widget.connector.supportsPathHashMode; AppDebugLogService get _appLog => Provider.of(context, listen: false); @@ -284,7 +279,6 @@ class _RadioSettingsDialogState extends State { _spreadingFactor = preset.spreadingFactor; _codingRate = preset.codingRate; _txPowerController.text = preset.txPowerDbm.toString(); - _pathHashByteWidth = preset.pathHashByteWidth; _selectedPresetIndex = index; _lastNonRepeatSnapshot = baseSnapshot; // Programmatic writes skip TextField.onChanged, so clear any stale @@ -449,15 +443,34 @@ class _RadioSettingsDialogState extends State { return; } await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower)); - if (_supportsPathHashMode && - _pathHashByteWidth != widget.connector.pathHashByteWidth) { - await widget.connector.setPathHashMode(_pathHashByteWidth - 1); + // setPathHashMode updates the local width optimistically; the refreshed + // DEVICE_INFO below overwrites it with what the radio actually stored. + final requestedPathHashWidth = + _supportsPathHashMode && + _pathHashByteWidth != widget.connector.pathHashByteWidth + ? _pathHashByteWidth + : null; + if (requestedPathHashWidth != null) { + await widget.connector.setPathHashMode(requestedPathHashWidth - 1); } final selfInfo = widget.connector.receivedFrames .firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo) .timeout(const Duration(seconds: 5)); + final deviceInfo = requestedPathHashWidth == null + ? null + : widget.connector.receivedFrames + .firstWhere((f) => f.isNotEmpty && f[0] == respCodeDeviceInfo) + .timeout(const Duration(seconds: 5)); await widget.connector.refreshDeviceInfo(); - final applied = await selfInfo.then( + // Without a refreshed DEVICE_INFO the path hash change is unconfirmed + // (this also covers setPathHashMode skipping a disconnected radio). + final pathHashApplied = + deviceInfo == null || + await deviceInfo.then( + (_) => widget.connector.pathHashByteWidth == requestedPathHashWidth, + onError: (_) => false, + ); + final radioApplied = await selfInfo.then( (_) => _deviceMatches( freqHz: freqHz, bwHz: bwHz, @@ -468,7 +481,7 @@ class _RadioSettingsDialogState extends State { ), onError: (_) => true, ); - if (!applied) { + if (!radioApplied) { _logRadioSettingsState('Radio did not apply requested settings'); if (!mounted) return; showDismissibleSnackBar( @@ -477,6 +490,17 @@ class _RadioSettingsDialogState extends State { ); return; } + if (!pathHashApplied) { + // Radio params and TX power were already applied; only the path + // hash size is outstanding, so say that rather than a generic error. + _logRadioSettingsState('Radio did not apply requested path hash size'); + if (!mounted) return; + showDismissibleSnackBar( + context, + content: Text(l10n.settings_pathHashModeNotApplied), + ); + return; + } final rememberedSnapshot = _clientRepeat ? _lastNonRepeatSnapshot : _currentSnapshot(); @@ -553,6 +577,7 @@ class _RadioSettingsDialogState extends State { 'sf=${_spreadingFactor.label} ' 'cr=${_codingRate.label} ' 'tx=${_txPowerController.text}dBm ' + 'pathHash=${_pathHashByteWidth}B ' 'repeat=$_clientRepeat ' 'preset=${_presetLabel(_selectedPresetIndex)} ' 'lastNonRepeat=${_formatSnapshot(_lastNonRepeatSnapshot)}', @@ -688,29 +713,36 @@ class _RadioSettingsDialogState extends State { ), const SizedBox(height: 16), if (_supportsPathHashMode) ...[ + // Values are path hash modes (0-2, byte width - 1), matching + // the selectors in settings_screen and repeater_settings_screen. DropdownButtonFormField( - initialValue: _pathHashByteWidth, + initialValue: (_pathHashByteWidth - 1).clamp(0, 2).toInt(), decoration: InputDecoration( labelText: l10n.repeater_pathHashMode, + helperText: l10n.settings_pathHashModeHelper, + helperMaxLines: 5, border: const OutlineInputBorder(), ), items: [ DropdownMenuItem( - value: 1, + value: 0, child: Text(l10n.repeater_pathHashModeOption0), ), DropdownMenuItem( - value: 2, + value: 1, child: Text(l10n.repeater_pathHashModeOption1), ), DropdownMenuItem( - value: 3, + value: 2, child: Text(l10n.repeater_pathHashModeOption2), ), ], onChanged: (value) { if (value == null) return; - setState(() => _pathHashByteWidth = value); + setState(() => _pathHashByteWidth = value + 1); + _logRadioSettingsState( + 'Manual settings edit: path hash size', + ); }, ), const SizedBox(height: 16), diff --git a/untranslated.json b/untranslated.json index 9e26dfee..648cd980 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1,69 @@ -{} \ No newline at end of file +{ + "bg": [ + "settings_pathHashModeNotApplied" + ], + + "de": [ + "settings_pathHashModeNotApplied" + ], + + "es": [ + "settings_pathHashModeNotApplied" + ], + + "fr": [ + "settings_pathHashModeNotApplied" + ], + + "hu": [ + "settings_pathHashModeNotApplied" + ], + + "it": [ + "settings_pathHashModeNotApplied" + ], + + "ja": [ + "settings_pathHashModeNotApplied" + ], + + "ko": [ + "settings_pathHashModeNotApplied" + ], + + "nl": [ + "settings_pathHashModeNotApplied" + ], + + "pl": [ + "settings_pathHashModeNotApplied" + ], + + "pt": [ + "settings_pathHashModeNotApplied" + ], + + "ru": [ + "settings_pathHashModeNotApplied" + ], + + "sk": [ + "settings_pathHashModeNotApplied" + ], + + "sl": [ + "settings_pathHashModeNotApplied" + ], + + "sv": [ + "settings_pathHashModeNotApplied" + ], + + "uk": [ + "settings_pathHashModeNotApplied" + ], + + "zh": [ + "settings_pathHashModeNotApplied" + ] +} From b6c1d73bf0f8830cdac97db71d22feedf7d0c31a Mon Sep 17 00:00:00 2001 From: zjs81 Date: Sat, 24 Oct 2026 20:45:14 -0700 Subject: [PATCH 15/16] Fix review findings in low battery alerts - Respect the notifications-enabled setting - Notify only the lowest newly crossed threshold - Ignore implausible readings (boards without a battery sensor report 0 mV) - Wait for the device identity so the saved chemistry is used - Require two consecutive low readings before alerting - Re-arm and clear alerts on any link reset, not just explicit disconnect - Cancel stale notifications on re-arm and link reset - Scope notification ids per device and name the device in the body - Use the connector's shared NotificationService --- lib/connector/meshcore_connector.dart | 72 +++++++++++++++++++++++--- lib/l10n/app_en.arb | 7 ++- lib/l10n/app_localizations.dart | 6 +-- lib/l10n/app_localizations_bg.dart | 4 +- lib/l10n/app_localizations_de.dart | 4 +- lib/l10n/app_localizations_en.dart | 4 +- lib/l10n/app_localizations_es.dart | 4 +- lib/l10n/app_localizations_fr.dart | 4 +- lib/l10n/app_localizations_hu.dart | 4 +- lib/l10n/app_localizations_it.dart | 4 +- lib/l10n/app_localizations_ja.dart | 4 +- lib/l10n/app_localizations_ko.dart | 4 +- lib/l10n/app_localizations_nl.dart | 4 +- lib/l10n/app_localizations_pl.dart | 4 +- lib/l10n/app_localizations_pt.dart | 4 +- lib/l10n/app_localizations_ru.dart | 4 +- lib/l10n/app_localizations_sk.dart | 4 +- lib/l10n/app_localizations_sl.dart | 4 +- lib/l10n/app_localizations_sv.dart | 4 +- lib/l10n/app_localizations_uk.dart | 4 +- lib/l10n/app_localizations_zh.dart | 4 +- lib/services/notification_service.dart | 33 ++++++++++-- 22 files changed, 138 insertions(+), 52 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 4a09067b..fbdd914c 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -302,6 +302,18 @@ class MeshCoreConnector extends ChangeNotifier { // crossing, re-arming 5 points above the threshold after recharge. static const List _lowBatteryThresholds = [25, 10]; final Set _batteryAlertedThresholds = {}; + // Consecutive readings that newly crossed a threshold. Alerts need + // [_lowBatteryConfirmReadings] in a row so a single TX-load voltage sag + // doesn't notify. + int _lowBatteryReadingStreak = 0; + // Device key the posted low-battery notifications were scoped to, kept so + // they can still be cancelled after the session's identity is cleared. + String? _lowBatteryAlertDeviceKey; + static const int _lowBatteryConfirmReadings = 2; + // Readings below this are treated as "no battery sensor" (boards without + // one report 0 mV). Any single Li cell, including LiFePO4 (2600 mV empty), + // is protection-cut well above 2 V, so lower values are not real readings. + static const int _minPlausibleBatteryMillivolts = 2000; double? _selfLatitude; double? _selfLongitude; final List _directRepeaters = List.empty(growable: true); @@ -3722,7 +3734,6 @@ class MeshCoreConnector extends ChangeNotifier { _allowedRepeatFreqRanges = null; _autoAddMaxHops = null; _contactsStorageFull = false; - _batteryAlertedThresholds.clear(); _repeaterBatterySnapshots.clear(); _activeTransport = MeshCoreTransportType.bluetooth; @@ -6492,24 +6503,61 @@ class MeshCoreConnector extends ChangeNotifier { } void _checkLowBatteryThresholds() { + final millivolts = _batteryMillivolts; + if (millivolts == null || millivolts < _minPlausibleBatteryMillivolts) { + return; + } + // Until the device identity (and so its saved chemistry) is known, the + // percentage falls back to NMC and can read low for e.g. LiFePO4 packs. + // Skip evaluation; the next battery poll re-checks once identity is set. + if (batteryDeviceKey == null || _appSettingsService == null) return; final percent = batteryPercent; if (percent == null) return; + // Only the lowest newly crossed threshold notifies; higher ones crossed + // in the same reading are marked as alerted silently. + final newlyCrossed = []; for (final threshold in _lowBatteryThresholds) { if (percent <= threshold && !_batteryAlertedThresholds.contains(threshold)) { - _batteryAlertedThresholds.add(threshold); - NotificationService().showLowBatteryNotification( - batteryPercent: percent, - threshold: threshold, - ); + newlyCrossed.add(threshold); } else if (percent > threshold + 5 && _batteryAlertedThresholds.contains(threshold)) { // Re-arm once the battery recovers 5 points above the threshold, // so a recharge + discharge cycle alerts again without flapping. _batteryAlertedThresholds.remove(threshold); + final alertDeviceKey = _lowBatteryAlertDeviceKey; + if (alertDeviceKey != null) { + unawaited( + _notificationService.clearLowBatteryNotifications(alertDeviceKey, [ + threshold, + ]), + ); + } } } + if (newlyCrossed.isEmpty) { + _lowBatteryReadingStreak = 0; + return; + } + // Debounce: wait for consecutive low readings before alerting. + if (++_lowBatteryReadingStreak < _lowBatteryConfirmReadings) return; + _lowBatteryReadingStreak = 0; + _batteryAlertedThresholds.addAll(newlyCrossed); + final deviceKey = batteryDeviceKey!; + _lowBatteryAlertDeviceKey = deviceKey; + final lowestNewlyCrossed = newlyCrossed.reduce((a, b) => a < b ? a : b); + if (!(_appSettingsService?.settings.notificationsEnabled ?? false)) { + return; + } + unawaited( + _notificationService.showLowBatteryNotification( + deviceKey: deviceKey, + deviceName: deviceDisplayName, + batteryPercent: percent, + threshold: lowestNewlyCrossed, + ), + ); } void _checkManualAddContacts() async { @@ -8595,6 +8643,18 @@ class MeshCoreConnector extends ChangeNotifier { _hasReceivedDeviceInfo = false; _batteryMillivolts = null; _batteryRequested = false; + final alertDeviceKey = _lowBatteryAlertDeviceKey; + if (alertDeviceKey != null && _batteryAlertedThresholds.isNotEmpty) { + unawaited( + _notificationService.clearLowBatteryNotifications( + alertDeviceKey, + _batteryAlertedThresholds.toList(), + ), + ); + } + _batteryAlertedThresholds.clear(); + _lowBatteryAlertDeviceKey = null; + _lowBatteryReadingStreak = 0; _pathHashByteWidth = 1; _maxContacts = _defaultMaxContacts; _maxChannels = _defaultMaxChannels; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 96ee02c8..8e949cab 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -2682,10 +2682,13 @@ "@notification_lowBatteryTitle": { "description": "Title of the low battery notification" }, - "notification_lowBatteryBody": "Device battery is at {percent}%", + "notification_lowBatteryBody": "{deviceName} battery is at {percent}%", "@notification_lowBatteryBody": { - "description": "Body of the low battery notification", + "description": "Body of the low battery notification; deviceName is the connected radio's node name", "placeholders": { + "deviceName": { + "type": "String" + }, "percent": { "type": "int" } diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index cfcb4347..58630f96 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -8114,11 +8114,11 @@ abstract class AppLocalizations { /// **'Low battery'** String get notification_lowBatteryTitle; - /// Body of the low battery notification + /// Body of the low battery notification; deviceName is the connected radio's node name /// /// In en, this message translates to: - /// **'Device battery is at {percent}%'** - String notification_lowBatteryBody(int percent); + /// **'{deviceName} battery is at {percent}%'** + String notification_lowBatteryBody(String deviceName, int percent); /// No description provided for @notification_messagesCount. /// diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index b0f3efc8..d8bec52f 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -4731,8 +4731,8 @@ class AppLocalizationsBg extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index fa451134..a03829e6 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -4742,8 +4742,8 @@ class AppLocalizationsDe extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 61785365..8a4cea69 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -4666,8 +4666,8 @@ class AppLocalizationsEn extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 11483e01..dc0b28be 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -4733,8 +4733,8 @@ class AppLocalizationsEs extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 4430c9b1..f55984f5 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -4752,8 +4752,8 @@ class AppLocalizationsFr extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 0da9db3e..e35c1981 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -4730,8 +4730,8 @@ class AppLocalizationsHu extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 11c3a4df..c4a97a49 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -4739,8 +4739,8 @@ class AppLocalizationsIt extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index e409ad80..8066f4ec 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -4502,8 +4502,8 @@ class AppLocalizationsJa extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 82667ffe..db66d010 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -4513,8 +4513,8 @@ class AppLocalizationsKo extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index c31460d2..470c6646 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -4708,8 +4708,8 @@ class AppLocalizationsNl extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 27ef631c..96f15d50 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -4759,8 +4759,8 @@ class AppLocalizationsPl extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index f51d5bb3..9358590b 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -4735,8 +4735,8 @@ class AppLocalizationsPt extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index b1e9018c..f808604f 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -4743,8 +4743,8 @@ class AppLocalizationsRu extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 00202f9c..12977b44 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -4716,8 +4716,8 @@ class AppLocalizationsSk extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 8956df64..9b629d4a 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -4714,8 +4714,8 @@ class AppLocalizationsSl extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 4f8d8f1f..129ddf72 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -4690,8 +4690,8 @@ class AppLocalizationsSv extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 84d0c651..1d425252 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -4742,8 +4742,8 @@ class AppLocalizationsUk extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index d0eb24b2..fa67ef7d 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -4410,8 +4410,8 @@ class AppLocalizationsZh extends AppLocalizations { String get notification_lowBatteryTitle => 'Low battery'; @override - String notification_lowBatteryBody(int percent) { - return 'Device battery is at $percent%'; + String notification_lowBatteryBody(String deviceName, int percent) { + return '$deviceName battery is at $percent%'; } @override diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index 62802917..334240c6 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -600,10 +600,13 @@ class NotificationService { /// Posts a low-battery alert for the connected device. /// - /// Uses a per-threshold notification id so each alert level updates its own - /// notification instead of stacking. Bypasses the rate-limit queue, which - /// only handles message and advert notifications. + /// Uses a per-device, per-threshold notification id so each alert level + /// updates its own notification instead of stacking, and alerts for + /// different radios don't overwrite each other. Bypasses the rate-limit + /// queue, which only handles message and advert notifications. Future showLowBatteryNotification({ + required String deviceKey, + required String deviceName, required int batteryPercent, required int threshold, }) async { @@ -632,9 +635,9 @@ class NotificationService { try { await _notifications.show( - id: 'low_battery:$threshold'.hashCode, + id: _lowBatteryNotificationId(deviceKey, threshold), title: _l10n.notification_lowBatteryTitle, - body: _l10n.notification_lowBatteryBody(batteryPercent), + body: _l10n.notification_lowBatteryBody(deviceName, batteryPercent), notificationDetails: notificationDetails, payload: 'low_battery', ); @@ -699,6 +702,26 @@ class NotificationService { await _updateBadge(totalUnreadCount); } + static int _lowBatteryNotificationId(String deviceKey, int threshold) => + 'low_battery:$deviceKey:$threshold'.hashCode; + + /// Cancel a device's low-battery notifications for the given thresholds. + Future clearLowBatteryNotifications( + String deviceKey, + Iterable thresholds, + ) async { + if (!await _ensureInitialized()) return; + for (final threshold in thresholds) { + try { + await _notifications.cancel( + id: _lowBatteryNotificationId(deviceKey, threshold), + ); + } catch (e) { + debugPrint('Failed to clear low battery notification: $e'); + } + } + } + /// Cancel advert notifications for the given contact public key hexes. Future clearAdvertNotifications(List contactIds) async { if (!await _ensureInitialized()) return; From f66732060888b1baa38346cf8c2cdd6a7d2eac88 Mon Sep 17 00:00:00 2001 From: zjs81 Date: Sat, 24 Oct 2026 20:46:49 -0700 Subject: [PATCH 16/16] Fix review findings in channel notification modes - Detect mentions on the original text, as @[name] or a whole-word @name - Save and restore the full mode map in review mode - Open the mode picker from the chat bell and show the mode in its tooltip - Share one mode picker sheet; fix the stale sheet context - Persist modes by name and skip unknown entries - Keep writing muted_channels so older builds keep the user's mutes - Remove the muteChannel/unmuteChannel/isChannelMuted shims - Update notifications docs to match the behaviour --- documentation/notifications.md | 11 +- lib/connector/meshcore_connector.dart | 39 +++--- lib/l10n/app_en.arb | 8 ++ lib/l10n/app_localizations.dart | 6 + lib/l10n/app_localizations_bg.dart | 5 + lib/l10n/app_localizations_de.dart | 5 + lib/l10n/app_localizations_en.dart | 5 + lib/l10n/app_localizations_es.dart | 5 + lib/l10n/app_localizations_fr.dart | 5 + lib/l10n/app_localizations_hu.dart | 5 + lib/l10n/app_localizations_it.dart | 5 + lib/l10n/app_localizations_ja.dart | 5 + lib/l10n/app_localizations_ko.dart | 5 + lib/l10n/app_localizations_nl.dart | 5 + lib/l10n/app_localizations_pl.dart | 5 + lib/l10n/app_localizations_pt.dart | 5 + lib/l10n/app_localizations_ru.dart | 5 + lib/l10n/app_localizations_sk.dart | 5 + lib/l10n/app_localizations_sl.dart | 5 + lib/l10n/app_localizations_sv.dart | 5 + lib/l10n/app_localizations_uk.dart | 5 + lib/l10n/app_localizations_zh.dart | 5 + lib/models/app_settings.dart | 24 ++-- lib/review_mode/review_mode_storage.dart | 59 ++++----- lib/screens/channel_chat_screen.dart | 22 +--- lib/screens/channels_screen.dart | 92 ++------------ lib/services/app_settings_service.dart | 22 +--- .../channel_notification_mode_sheet.dart | 65 ++++++++++ test/connector/mention_detection_test.dart | 33 +++++ .../channel_notification_modes_json_test.dart | 37 ++++++ .../review_mode_settings_revert_test.dart | 120 ++++++++++++++++-- untranslated.json | 70 +++++++++- 32 files changed, 502 insertions(+), 196 deletions(-) create mode 100644 lib/widgets/channel_notification_mode_sheet.dart create mode 100644 test/connector/mention_detection_test.dart create mode 100644 test/models/channel_notification_modes_json_test.dart diff --git a/documentation/notifications.md b/documentation/notifications.md index 8bdc5d6c..12c44f6c 100644 --- a/documentation/notifications.md +++ b/documentation/notifications.md @@ -42,7 +42,7 @@ Message notifications can be answered without opening the app, from the notifica - **Reply** sends through the connected radio exactly like the chat screen: same length limits, SMAZ and Cyr2Lat handling, and retries. Your reply is then added to the notification. - **Replies over the message limit** are split at word boundaries into up to 3 messages. Longer replies are not sent; a "Reply not sent" notification asks you to open the app. - **Mark as read** clears the unread count on the phone only. MeshCore has no read receipts, so nothing is sent over the mesh. -- **Mute channel** (phone and watch) mutes that channel, the same as the bell icon in the channel chat. +- **Mute channel** (phone and watch) sets that channel to **Muted**, the same as choosing Muted from the bell icon in the channel chat. - If the radio is disconnected, the conversation is no longer on the radio, the radio reports a send error, or the app isn't running, a "Reply not sent" notification explains why. The reply is not queued. If a split reply fails partway, earlier parts may already have been sent. - Replies are sent as typed; composer translation is not applied. @@ -106,16 +106,17 @@ Each channel supports three notification modes: | Mode | Icon | Behavior | |---|---|---| | **All messages** | 🔔 | Receive notifications for every message | -| **Mentions only** | 🔔! | Only notify when someone mentions you with "@[yourname]" | +| **Mentions only** | 🔔! | Only notify when a message mentions your name (see below) | | **Muted** | 🔕 | No notifications | Set the mode from: -- The notifications icon in the channel chat app bar (tap to cycle through modes) +- The notifications icon in the channel chat app bar (tap to open the mode picker) - Long-press a channel in the channels list → **Notification settings** → select mode -- Channel notification actions (Android) -Mentions are detected by looking for "@[yourname]" (username in brackets, case-insensitive). +The Android **Mute channel** notification action sets the channel to **Muted**; it cannot choose another mode. + +A message mentions you if it contains `@[yourname]` or `@yourname`, case-insensitively. The plain `@yourname` form must stand alone as a word, so `@bobby` does not mention `bob` and `x@bob.com` is not a mention; names with spaces must be written in full. Detection (`MeshCoreConnector.textMentionsName`) runs on the original text, before any automatic translation. ## Rate Limiting diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 7777d60f..e17864b3 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -1247,8 +1247,9 @@ class MeshCoreConnector extends ChangeNotifier { /// (notification shade, watch, or Android Auto). Future handleNotificationReply(NotificationReply reply) async { if (reply.action == NotificationReplyAction.mute) { - await _appSettingsService?.muteChannel( + await _appSettingsService?.setChannelNotificationMode( _channelDisplayName(reply.channelIndex!), + ChannelNotificationMode.muted, ); await _notificationService.clearChannelNotification( reply.channelIndex!, @@ -7369,9 +7370,11 @@ class MeshCoreConnector extends ChangeNotifier { ? translationResult.translatedText.trim() : message.text.trim(); - // If mode is mentionsOnly, check if message mentions us + // Mentions are matched on the untranslated text. if (notificationMode == ChannelNotificationMode.mentionsOnly) { - if (!_doesMessageMentionUs(resolvedText, message)) return; + if (!textMentionsName(message.originalText ?? message.text, _selfName)) { + return; + } } unawaited(() async { @@ -7386,22 +7389,20 @@ class MeshCoreConnector extends ChangeNotifier { }()); } - /// Checks if a message mentions the current user. - /// Detects: @[username] format only. - bool _doesMessageMentionUs(String messageText, ChannelMessage message) { - final selfName = _selfName; - final lowerMessage = messageText.toLowerCase(); - - // Check for @[username] pattern (bracketed mention format) - if (selfName != null && selfName.isNotEmpty) { - final lowerSelfName = selfName.toLowerCase(); - final bracketedMentionPattern = RegExp( - r'@\[(' + RegExp.escape(lowerSelfName) + r')\]', - ); - if (bracketedMentionPattern.hasMatch(lowerMessage)) return true; - } - - return false; + /// Whether [text] mentions [name], case-insensitively, as either + /// `@[name]` (the reply/mention prefix the app sends) or a plain `@name`. + /// The plain form needs a word boundary on both sides, so `@bobby` does + /// not mention `bob` and `x@bob.com` is not a mention. Names containing + /// spaces must be written out in full. + @visibleForTesting + static bool textMentionsName(String text, String? name) { + if (name == null || name.isEmpty) return false; + final escaped = RegExp.escape(name); + return RegExp( + '@\\[$escaped\\]|(? 'Заглушено'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Заглуши канала'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 9d7a3f43..c4f916bc 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -1470,6 +1470,11 @@ class AppLocalizationsDe extends AppLocalizations { @override String get channels_notifyNone => 'Stummgeschaltet'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Kanal stummschalten'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index fb20008b..d025517b 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1450,6 +1450,11 @@ class AppLocalizationsEn extends AppLocalizations { @override String get channels_notifyNone => 'Muted'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Mute channel'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index e1ad4fa2..dc83cb6d 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -1469,6 +1469,11 @@ class AppLocalizationsEs extends AppLocalizations { @override String get channels_notifyNone => 'Silenciado'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Silenciar canal'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index f3318265..5b58c565 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -1474,6 +1474,11 @@ class AppLocalizationsFr extends AppLocalizations { @override String get channels_notifyNone => 'Désactivé'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Désactiver les notifications du canal'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 21d40309..e5860865 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -1465,6 +1465,11 @@ class AppLocalizationsHu extends AppLocalizations { @override String get channels_notifyNone => 'Némít'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Csatorna némítása'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index fdc44f4a..1f69f454 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -1473,6 +1473,11 @@ class AppLocalizationsIt extends AppLocalizations { @override String get channels_notifyNone => 'Silenziato'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Silenzia canale'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 80aa0c8d..ec3494d3 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1397,6 +1397,11 @@ class AppLocalizationsJa extends AppLocalizations { @override String get channels_notifyNone => 'ミュート'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'チャンネルをミュート'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 90181a0c..b7dc254d 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1402,6 +1402,11 @@ class AppLocalizationsKo extends AppLocalizations { @override String get channels_notifyNone => '음소거'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => '음소거 채널'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index b4c40d64..aed45fff 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -1461,6 +1461,11 @@ class AppLocalizationsNl extends AppLocalizations { @override String get channels_notifyNone => 'Gedempt'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Kanaal dempen'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 10fe2d7f..02747e57 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -1487,6 +1487,11 @@ class AppLocalizationsPl extends AppLocalizations { @override String get channels_notifyNone => 'Wyciszone'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Wycisz kanał'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 2a9ceae6..b248889c 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -1472,6 +1472,11 @@ class AppLocalizationsPt extends AppLocalizations { @override String get channels_notifyNone => 'Silenciado'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Silenciar canal'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index f8eb322b..1f53e6f7 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -1476,6 +1476,11 @@ class AppLocalizationsRu extends AppLocalizations { @override String get channels_notifyNone => 'Без звука'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Отключить уведомления канала'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 46b074bd..159f6751 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -1464,6 +1464,11 @@ class AppLocalizationsSk extends AppLocalizations { @override String get channels_notifyNone => 'Stíšené'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Stlmiť kanál'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 696b59f9..2dc95d5d 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -1462,6 +1462,11 @@ class AppLocalizationsSl extends AppLocalizations { @override String get channels_notifyNone => 'Utišano'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Utišaj kanal'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 1593d3de..7e18cea8 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1451,6 +1451,11 @@ class AppLocalizationsSv extends AppLocalizations { @override String get channels_notifyNone => 'Tyst'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Tysta kanal'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 369dda90..4eef0bb5 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -1467,6 +1467,11 @@ class AppLocalizationsUk extends AppLocalizations { @override String get channels_notifyNone => 'Вимкнено'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => 'Вимкнути сповіщення каналу'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index ac397a39..b2b407f6 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1379,6 +1379,11 @@ class AppLocalizationsZh extends AppLocalizations { @override String get channels_notifyNone => '静音'; + @override + String channels_notificationModeTooltip(String mode) { + return 'Notifications: $mode'; + } + @override String get channels_muteChannel => '静音频道'; diff --git a/lib/models/app_settings.dart b/lib/models/app_settings.dart index 612905ec..f664f083 100644 --- a/lib/models/app_settings.dart +++ b/lib/models/app_settings.dart @@ -198,12 +198,6 @@ class AppSettings { return profile.charMap; } - // Backward compatibility: returns true if channel is muted (mode == muted) - bool isChannelMuted(String channelName) { - return channelNotificationModes[channelName] == - ChannelNotificationMode.muted; - } - AppSettings({ this.clearPathOnMaxRetry = false, this.mapShowRepeaters = true, @@ -330,8 +324,13 @@ class AppSettings { 'battery_chemistry_by_device_id': batteryChemistryByDeviceId, 'battery_chemistry_by_repeater_id': batteryChemistryByRepeaterId, 'unit_system': unitSystem.value, + // Written for older builds that only read the muted set. + 'muted_channels': [ + for (final entry in channelNotificationModes.entries) + if (entry.value == ChannelNotificationMode.muted) entry.key, + ], 'channel_notification_modes': channelNotificationModes.map( - (key, value) => MapEntry(key, value.index), + (key, value) => MapEntry(key, value.name), ), 'map_show_discovery_contacts': mapShowDiscoveryContacts, 'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled, @@ -392,13 +391,10 @@ class AppSettings { // Load new modes (overrides old muted channels if present) if (newModes != null) { for (final entry in newModes.entries) { - final channelName = entry.key; - final modeIndex = entry.value as int?; - if (modeIndex != null && - modeIndex >= 0 && - modeIndex < ChannelNotificationMode.values.length) { - result[channelName] = ChannelNotificationMode.values[modeIndex]; - } + final value = entry.value; + if (value is! String) continue; + final mode = ChannelNotificationMode.values.asNameMap()[value]; + if (mode != null) result[entry.key.toString()] = mode; } } diff --git a/lib/review_mode/review_mode_storage.dart b/lib/review_mode/review_mode_storage.dart index e0a02bb4..de787edb 100644 --- a/lib/review_mode/review_mode_storage.dart +++ b/lib/review_mode/review_mode_storage.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import '../services/app_settings_service.dart' show AppSettingsService, ChannelNotificationMode; import '../services/storage_service.dart'; @@ -6,9 +8,10 @@ import '../storage/legacy_key_migration.dart'; import '../storage/prefs_manager.dart'; import 'review_radio.dart'; -/// Muted channel names as they were when review mode started. Persisted so an -/// interrupted session (crash, app killed) is still undone on the next launch. -const _savedMutedChannelsKey = 'review_mode_saved_muted_channels'; +/// Channel notification modes (JSON map of channel name to mode name) as they +/// were when review mode started. Persisted so an interrupted session (crash, +/// app killed) is still undone on the next launch. +const _savedChannelModesKey = 'review_mode_saved_channel_modes'; /// Prefix for snapshots of app-wide repeater keys (saved passwords, clock sync /// toggles) taken when review mode starts. An empty snapshot means the key did @@ -32,10 +35,11 @@ Future clearReviewModeData() async { /// Starts a review session from a clean slate. /// /// The simulated radio's scope never adopts legacy unscoped keys, so real -/// radio data cannot be pulled into it. Channel mutes are app-wide and keyed -/// by channel name (muting the simulated "Public" would mute the real one), -/// so the current mutes are saved for [endReviewModeSession] to put back, as -/// are the app-wide repeater keys. Delivery timing is not recorded meanwhile. +/// radio data cannot be pulled into it. Channel notification modes are +/// app-wide and keyed by channel name (muting the simulated "Public" would +/// mute the real one), so the current modes are saved for +/// [endReviewModeSession] to put back, as are the app-wide repeater keys. +/// Delivery timing is not recorded meanwhile. Future beginReviewModeSession(AppSettingsService? settings) async { scopesWithoutLegacyMigration.add(ReviewRadio.storagePrefix); TimeoutPredictionService.recordingSuspended = true; @@ -48,19 +52,16 @@ Future beginReviewModeSession(AppSettingsService? settings) async { await prefs.setString(savedKey, prefs.getString(key) ?? ''); } // An earlier interrupted session's record holds the real pre-review state. - if (settings != null && !prefs.containsKey(_savedMutedChannelsKey)) { - // Save all channel notification modes - final channelModes = settings.settings.channelNotificationModes; - final mutedChannels = channelModes.entries - .where((e) => e.value == ChannelNotificationMode.muted) - .map((e) => e.key) - .toList(); - await prefs.setStringList(_savedMutedChannelsKey, mutedChannels); + if (settings != null && !prefs.containsKey(_savedChannelModesKey)) { + final modes = settings.settings.channelNotificationModes.map( + (channel, mode) => MapEntry(channel, mode.name), + ); + await prefs.setString(_savedChannelModesKey, jsonEncode(modes)); } } -/// Deletes the review session's data and restores the channel mutes and -/// repeater keys saved by [beginReviewModeSession]. Also called at startup to finish a session that +/// Deletes the review session's data and restores the channel notification +/// modes and repeater keys saved by [beginReviewModeSession]. Also called at startup to finish a session that /// was interrupted; it does nothing when no session was left behind. Future endReviewModeSession(AppSettingsService? settings) async { TimeoutPredictionService.recordingSuspended = false; @@ -77,19 +78,19 @@ Future endReviewModeSession(AppSettingsService? settings) async { } await prefs.remove(savedKey); } - final savedMutes = prefs.getStringList(_savedMutedChannelsKey); - if (savedMutes == null || settings == null) return; - final updatedModes = Map.from( - settings.settings.channelNotificationModes, - ); - updatedModes.removeWhere( - (key, value) => value == ChannelNotificationMode.muted, - ); - for (final channelName in savedMutes) { - updatedModes[channelName] = ChannelNotificationMode.muted; + final savedModes = prefs.getString(_savedChannelModesKey); + if (savedModes == null || settings == null) return; + final restored = {}; + final decoded = jsonDecode(savedModes); + if (decoded is Map) { + final byName = ChannelNotificationMode.values.asNameMap(); + for (final entry in decoded.entries) { + final mode = byName[entry.value]; + if (mode != null) restored[entry.key.toString()] = mode; + } } await settings.updateSettings( - settings.settings.copyWith(channelNotificationModes: updatedModes), + settings.settings.copyWith(channelNotificationModes: restored), ); - await prefs.remove(_savedMutedChannelsKey); + await prefs.remove(_savedChannelModesKey); } diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 0a8238b8..7f5049dd 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -37,6 +37,7 @@ import '../utils/image_save.dart'; import '../utils/lora_airtime.dart'; import '../widgets/marker_label_dialog.dart'; import '../widgets/received_image_message.dart'; +import '../widgets/channel_notification_mode_sheet.dart'; import '../widgets/chat_day_separator.dart'; import '../widgets/empty_state.dart'; @@ -408,7 +409,9 @@ class _ChannelChatScreenState extends State { muteKey, ); return IconButton( - tooltip: context.l10n.channels_notificationSettings, + tooltip: context.l10n.channels_notificationModeTooltip( + channelNotificationModeLabel(context, notificationMode), + ), icon: Icon( notificationMode == ChannelNotificationMode.muted ? Icons.notifications_off @@ -416,21 +419,8 @@ class _ChannelChatScreenState extends State { ? Icons.notification_important : Icons.notifications, ), - onPressed: () { - final currentMode = settings.getChannelNotificationMode( - muteKey, - ); - ChannelNotificationMode newMode; - if (currentMode == ChannelNotificationMode.all) { - newMode = ChannelNotificationMode.mentionsOnly; - } else if (currentMode == - ChannelNotificationMode.mentionsOnly) { - newMode = ChannelNotificationMode.muted; - } else { - newMode = ChannelNotificationMode.all; - } - settings.setChannelNotificationMode(muteKey, newMode); - }, + onPressed: () => + showChannelNotificationModeSheet(context, muteKey), ); }, ), diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index beaac2cc..53d561ac 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -20,6 +20,7 @@ import '../theme/mesh_theme.dart'; import '../utils/dialog_utils.dart'; import '../utils/disconnect_navigation_mixin.dart'; import '../utils/route_transitions.dart'; +import '../widgets/channel_notification_mode_sheet.dart'; import '../widgets/list_filter_widget.dart'; import '../widgets/empty_state.dart'; import '../widgets/mesh_ui.dart'; @@ -583,9 +584,7 @@ class _ChannelsScreenState extends State children: [ if (notificationMode != ChannelNotificationMode.all) ...[ Icon( - notificationMode == ChannelNotificationMode.muted - ? Icons.notifications_off - : Icons.notification_important, + channelNotificationModeIcon(notificationMode), size: 18, color: scheme.onSurfaceVariant, ), @@ -651,9 +650,15 @@ class _ChannelsScreenState extends State leading: const Icon(Icons.notifications_outlined), title: Text(sheetContext.l10n.channels_notificationSettings), trailing: const Icon(Icons.chevron_right), - onTap: () { + onTap: () async { Navigator.pop(sheetContext); - _showNotificationModeDialog(sheetContext, connector, channel); + await Future.delayed(const Duration(milliseconds: 100)); + if (parentContext.mounted) { + showChannelNotificationModeSheet( + parentContext, + channel.muteKey, + ); + } }, ), ListTile( @@ -681,83 +686,6 @@ class _ChannelsScreenState extends State ); } - void _showNotificationModeDialog( - BuildContext context, - MeshCoreConnector connector, - Channel channel, - ) { - final settingsService = context.read(); - final currentMode = settingsService.getChannelNotificationMode( - channel.muteKey, - ); - - showMeshSheet( - context, - builder: (sheetContext) => SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // All notifications - ListTile( - leading: Icon( - Icons.notifications, - color: currentMode == ChannelNotificationMode.all - ? Theme.of(sheetContext).colorScheme.primary - : Theme.of(sheetContext).colorScheme.onSurfaceVariant, - ), - title: Text(sheetContext.l10n.channels_notifyAll), - trailing: currentMode == ChannelNotificationMode.all - ? const Icon(Icons.check) - : null, - onTap: () async { - Navigator.pop(sheetContext); - await settingsService.setChannelNotificationMode( - channel.muteKey, - ChannelNotificationMode.all, - ); - }, - ), - // Mentions only - ListTile( - leading: const Icon(Icons.notification_important), - title: Text(sheetContext.l10n.channels_notifyMentionsOnly), - trailing: currentMode == ChannelNotificationMode.mentionsOnly - ? const Icon(Icons.check) - : null, - onTap: () async { - Navigator.pop(sheetContext); - await settingsService.setChannelNotificationMode( - channel.muteKey, - ChannelNotificationMode.mentionsOnly, - ); - }, - ), - // Muted - ListTile( - leading: Icon( - Icons.notifications_off, - color: currentMode == ChannelNotificationMode.muted - ? Theme.of(sheetContext).colorScheme.primary - : Theme.of(sheetContext).colorScheme.onSurfaceVariant, - ), - title: Text(sheetContext.l10n.channels_notifyNone), - trailing: currentMode == ChannelNotificationMode.muted - ? const Icon(Icons.check) - : null, - onTap: () async { - Navigator.pop(sheetContext); - await settingsService.setChannelNotificationMode( - channel.muteKey, - ChannelNotificationMode.muted, - ); - }, - ), - ], - ), - ), - ); - } - void _handleQuickSwitch(int index, BuildContext context) { if (index == 1) return; switch (index) { diff --git a/lib/services/app_settings_service.dart b/lib/services/app_settings_service.dart index 5bddabae..d5d4b433 100644 --- a/lib/services/app_settings_service.dart +++ b/lib/services/app_settings_service.dart @@ -288,11 +288,6 @@ class AppSettingsService extends ChangeNotifier { await updateSettings(_settings.copyWith(unitSystem: value)); } - // Backward compatibility: delegates to AppSettings.isChannelMuted - bool isChannelMuted(String channelName) { - return _settings.isChannelMuted(channelName); - } - ChannelNotificationMode getChannelNotificationMode(String channelName) { return _settings.channelNotificationModes[channelName] ?? ChannelNotificationMode.all; @@ -305,21 +300,14 @@ class AppSettingsService extends ChangeNotifier { final updated = Map.from( _settings.channelNotificationModes, ); - updated[channelName] = mode; + if (mode == ChannelNotificationMode.all) { + updated.remove(channelName); + } else { + updated[channelName] = mode; + } await updateSettings(_settings.copyWith(channelNotificationModes: updated)); } - Future muteChannel(String channelName) async { - await setChannelNotificationMode( - channelName, - ChannelNotificationMode.muted, - ); - } - - Future unmuteChannel(String channelName) async { - await setChannelNotificationMode(channelName, ChannelNotificationMode.all); - } - Future setTcpServerAddress(String value) async { await updateSettings(_settings.copyWith(tcpServerAddress: value)); } diff --git a/lib/widgets/channel_notification_mode_sheet.dart b/lib/widgets/channel_notification_mode_sheet.dart new file mode 100644 index 00000000..9239aff2 --- /dev/null +++ b/lib/widgets/channel_notification_mode_sheet.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../l10n/l10n.dart'; +import '../services/app_settings_service.dart' + show AppSettingsService, ChannelNotificationMode; +import 'mesh_ui.dart'; + +/// Localized label for a channel notification [mode]. +String channelNotificationModeLabel( + BuildContext context, + ChannelNotificationMode mode, +) => switch (mode) { + ChannelNotificationMode.all => context.l10n.channels_notifyAll, + ChannelNotificationMode.mentionsOnly => + context.l10n.channels_notifyMentionsOnly, + ChannelNotificationMode.muted => context.l10n.channels_notifyNone, +}; + +/// Icon for a channel notification [mode]. +IconData channelNotificationModeIcon(ChannelNotificationMode mode) => + switch (mode) { + ChannelNotificationMode.all => Icons.notifications, + ChannelNotificationMode.mentionsOnly => Icons.notification_important, + ChannelNotificationMode.muted => Icons.notifications_off, + }; + +/// Shows the per-channel notification mode picker (all / mentions only / +/// muted) for the channel identified by [muteKey]. +void showChannelNotificationModeSheet(BuildContext context, String muteKey) { + final settingsService = context.read(); + final currentMode = settingsService.getChannelNotificationMode(muteKey); + + showMeshSheet( + context, + builder: (sheetContext) { + final scheme = Theme.of(sheetContext).colorScheme; + return SafeArea( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + for (final mode in ChannelNotificationMode.values) + ListTile( + leading: Icon( + channelNotificationModeIcon(mode), + color: mode == currentMode + ? scheme.primary + : scheme.onSurfaceVariant, + ), + title: Text(channelNotificationModeLabel(sheetContext, mode)), + trailing: mode == currentMode ? const Icon(Icons.check) : null, + onTap: () async { + Navigator.pop(sheetContext); + await settingsService.setChannelNotificationMode( + muteKey, + mode, + ); + }, + ), + ], + ), + ); + }, + ); +} diff --git a/test/connector/mention_detection_test.dart b/test/connector/mention_detection_test.dart new file mode 100644 index 00000000..91e84e54 --- /dev/null +++ b/test/connector/mention_detection_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_connector.dart'; + +void main() { + bool mentions(String text, String? name) => + MeshCoreConnector.textMentionsName(text, name); + + test('matches bracketed and plain mentions case-insensitively', () { + expect(mentions('@[Bob] hello', 'Bob'), isTrue); + expect(mentions('hey @[bob]', 'Bob'), isTrue); + expect(mentions('hey @bob, look', 'Bob'), isTrue); + expect(mentions('@BOB', 'Bob'), isTrue); + expect(mentions('ping @Иван!', 'иван'), isTrue); + }); + + test('requires a word boundary for plain mentions', () { + expect(mentions('hey @bobby', 'Bob'), isFalse); + expect(mentions('mail x@bob.com', 'Bob'), isFalse); + expect(mentions('hey bob', 'Bob'), isFalse); + }); + + test('names with spaces or regex characters must match in full', () { + expect(mentions('hi @Bob Smith', 'Bob Smith'), isTrue); + expect(mentions('hi @Bob', 'Bob Smith'), isFalse); + expect(mentions('@[Node (1)] ok', 'Node (1)'), isTrue); + expect(mentions('@[Node 1] ok', 'Node (1)'), isFalse); + }); + + test('no self name never matches', () { + expect(mentions('@[Bob] hi', null), isFalse); + expect(mentions('@ hi', ''), isFalse); + }); +} diff --git a/test/models/channel_notification_modes_json_test.dart b/test/models/channel_notification_modes_json_test.dart new file mode 100644 index 00000000..abd2bbef --- /dev/null +++ b/test/models/channel_notification_modes_json_test.dart @@ -0,0 +1,37 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/models/app_settings.dart'; + +void main() { + test('channel notification modes round-trip by name', () { + final settings = AppSettings( + channelNotificationModes: { + 'a': ChannelNotificationMode.mentionsOnly, + 'b': ChannelNotificationMode.muted, + }, + ); + final json = settings.toJson(); + expect(json['channel_notification_modes'], { + 'a': 'mentionsOnly', + 'b': 'muted', + }); + expect(json['muted_channels'], ['b']); + expect( + AppSettings.fromJson(json).channelNotificationModes, + settings.channelNotificationModes, + ); + }); + + test('invalid channel notification mode entries are skipped', () { + final settings = AppSettings.fromJson({ + 'channel_notification_modes': { + 'ok': 'muted', + 'unknown': 'loud', + 'int': 2, + 'null': null, + }, + }); + expect(settings.channelNotificationModes, { + 'ok': ChannelNotificationMode.muted, + }); + }); +} diff --git a/test/review_mode/review_mode_settings_revert_test.dart b/test/review_mode/review_mode_settings_revert_test.dart index fcd6ce3c..493163dd 100644 --- a/test/review_mode/review_mode_settings_revert_test.dart +++ b/test/review_mode/review_mode_settings_revert_test.dart @@ -24,7 +24,10 @@ void main() { test('channel mutes made in review mode are undone on exit', () async { final settings = AppSettingsService(); await settings.loadSettings(); - await settings.muteChannel('Hiking Group'); + await settings.setChannelNotificationMode( + 'Hiking Group', + ChannelNotificationMode.muted, + ); final connector = MeshCoreConnector(); addTearDown(connector.dispose); final retryService = MessageRetryService(); @@ -39,23 +42,41 @@ void main() { await connector.connectReview(); // Mutes are keyed by channel name, so these would leak into real radios. - await settings.muteChannel('Public'); - await settings.unmuteChannel('Hiking Group'); + await settings.setChannelNotificationMode( + 'Public', + ChannelNotificationMode.muted, + ); + await settings.setChannelNotificationMode( + 'Hiking Group', + ChannelNotificationMode.all, + ); // Other app preferences are the user's to change, even while reviewing. await PrefsManager.instance.setString('unrelated_key', 'changed'); await connector.disconnect(manual: true); - expect(settings.isChannelMuted('Public'), isFalse); - expect(settings.isChannelMuted('Hiking Group'), isTrue); + expect( + settings.getChannelNotificationMode('Public'), + ChannelNotificationMode.all, + ); + expect( + settings.getChannelNotificationMode('Hiking Group'), + ChannelNotificationMode.muted, + ); expect(PrefsManager.instance.getString('unrelated_key'), 'changed'); // A fresh launch has nothing left to undo. final relaunched = AppSettingsService(); await relaunched.loadSettings(); await endReviewModeSession(relaunched); - expect(relaunched.isChannelMuted('Public'), isFalse); - expect(relaunched.isChannelMuted('Hiking Group'), isTrue); + expect( + relaunched.getChannelNotificationMode('Public'), + ChannelNotificationMode.all, + ); + expect( + relaunched.getChannelNotificationMode('Hiking Group'), + ChannelNotificationMode.muted, + ); }); test( @@ -63,11 +84,20 @@ void main() { () async { final settings = AppSettingsService(); await settings.loadSettings(); - await settings.muteChannel('Hiking Group'); + await settings.setChannelNotificationMode( + 'Hiking Group', + ChannelNotificationMode.muted, + ); await beginReviewModeSession(settings); - await settings.muteChannel('Public'); - await settings.unmuteChannel('Hiking Group'); + await settings.setChannelNotificationMode( + 'Public', + ChannelNotificationMode.muted, + ); + await settings.setChannelNotificationMode( + 'Hiking Group', + ChannelNotificationMode.all, + ); await PrefsManager.instance.setString( 'contacts${ReviewRadio.storagePrefix}', '[]', @@ -76,11 +106,20 @@ void main() { final relaunched = AppSettingsService(); await relaunched.loadSettings(); - expect(relaunched.isChannelMuted('Public'), isTrue); + expect( + relaunched.getChannelNotificationMode('Public'), + ChannelNotificationMode.muted, + ); await endReviewModeSession(relaunched); - expect(relaunched.isChannelMuted('Public'), isFalse); - expect(relaunched.isChannelMuted('Hiking Group'), isTrue); + expect( + relaunched.getChannelNotificationMode('Public'), + ChannelNotificationMode.all, + ); + expect( + relaunched.getChannelNotificationMode('Hiking Group'), + ChannelNotificationMode.muted, + ); expect( PrefsManager.instance.getKeys().where( (k) => k.contains(ReviewRadio.storagePrefix), @@ -90,6 +129,61 @@ void main() { }, ); + test('every channel notification mode is restored on exit', () async { + final settings = AppSettingsService(); + await settings.loadSettings(); + await settings.setChannelNotificationMode( + 'Hiking Group', + ChannelNotificationMode.mentionsOnly, + ); + await settings.setChannelNotificationMode( + 'Noisy', + ChannelNotificationMode.muted, + ); + + await beginReviewModeSession(settings); + await settings.setChannelNotificationMode( + 'Hiking Group', + ChannelNotificationMode.all, + ); + await settings.setChannelNotificationMode( + 'Noisy', + ChannelNotificationMode.mentionsOnly, + ); + await settings.setChannelNotificationMode( + 'Public', + ChannelNotificationMode.mentionsOnly, + ); + await endReviewModeSession(settings); + + expect( + settings.getChannelNotificationMode('Hiking Group'), + ChannelNotificationMode.mentionsOnly, + ); + expect( + settings.getChannelNotificationMode('Noisy'), + ChannelNotificationMode.muted, + ); + expect( + settings.getChannelNotificationMode('Public'), + ChannelNotificationMode.all, + ); + }); + + test('setting a channel back to all drops its stored mode', () async { + final settings = AppSettingsService(); + await settings.loadSettings(); + await settings.setChannelNotificationMode( + 'Public', + ChannelNotificationMode.muted, + ); + await settings.setChannelNotificationMode( + 'Public', + ChannelNotificationMode.all, + ); + expect(settings.settings.channelNotificationModes, isEmpty); + }); + test('the review scope never adopts legacy unscoped data', () async { await PrefsManager.instance.setString('contacts', '[]'); await beginReviewModeSession(null); diff --git a/untranslated.json b/untranslated.json index 9e26dfee..f140f78b 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1,69 @@ -{} \ No newline at end of file +{ + "bg": [ + "channels_notificationModeTooltip" + ], + + "de": [ + "channels_notificationModeTooltip" + ], + + "es": [ + "channels_notificationModeTooltip" + ], + + "fr": [ + "channels_notificationModeTooltip" + ], + + "hu": [ + "channels_notificationModeTooltip" + ], + + "it": [ + "channels_notificationModeTooltip" + ], + + "ja": [ + "channels_notificationModeTooltip" + ], + + "ko": [ + "channels_notificationModeTooltip" + ], + + "nl": [ + "channels_notificationModeTooltip" + ], + + "pl": [ + "channels_notificationModeTooltip" + ], + + "pt": [ + "channels_notificationModeTooltip" + ], + + "ru": [ + "channels_notificationModeTooltip" + ], + + "sk": [ + "channels_notificationModeTooltip" + ], + + "sl": [ + "channels_notificationModeTooltip" + ], + + "sv": [ + "channels_notificationModeTooltip" + ], + + "uk": [ + "channels_notificationModeTooltip" + ], + + "zh": [ + "channels_notificationModeTooltip" + ] +}