From 6a5d15209bd978d8aa37d7fbbbab7757ef9c1e54 Mon Sep 17 00:00:00 2001 From: celsoazevedo Date: Mon, 23 Nov 2026 22:12:10 +0000 Subject: [PATCH 1/2] Contact Settings: add Hop limit Sets the companion firmware's autoadd_max_hops (optional third byte of CMD_SET_AUTOADD_CONFIG). The radio only auto-adds contacts heard in fewer hops than the limit; 0 means no limit. Shown only when the radio reports the value. Review mode stores it like the firmware. Co-Authored-By: Claude Opus 5.5 --- documentation/design.md | 1 + documentation/settings.md | 1 + lib/l10n/app_bg.arb | 3 + lib/l10n/app_cs.arb | 3 + lib/l10n/app_de.arb | 3 + lib/l10n/app_en.arb | 10 +++ lib/l10n/app_es.arb | 3 + lib/l10n/app_fr.arb | 3 + lib/l10n/app_hu.arb | 3 + lib/l10n/app_it.arb | 3 + lib/l10n/app_ja.arb | 3 + lib/l10n/app_ko.arb | 3 + lib/l10n/app_localizations.dart | 18 +++++ lib/l10n/app_localizations_bg.dart | 19 +++++ lib/l10n/app_localizations_cs.dart | 19 +++++ lib/l10n/app_localizations_de.dart | 19 +++++ lib/l10n/app_localizations_en.dart | 19 +++++ lib/l10n/app_localizations_es.dart | 19 +++++ lib/l10n/app_localizations_fr.dart | 19 +++++ lib/l10n/app_localizations_hu.dart | 19 +++++ lib/l10n/app_localizations_it.dart | 19 +++++ lib/l10n/app_localizations_ja.dart | 19 +++++ lib/l10n/app_localizations_ko.dart | 19 +++++ lib/l10n/app_localizations_nl.dart | 19 +++++ lib/l10n/app_localizations_pl.dart | 19 +++++ lib/l10n/app_localizations_pt.dart | 38 ++++++++++ lib/l10n/app_localizations_ru.dart | 19 +++++ lib/l10n/app_localizations_sk.dart | 19 +++++ lib/l10n/app_localizations_sl.dart | 19 +++++ lib/l10n/app_localizations_sv.dart | 19 +++++ lib/l10n/app_localizations_uk.dart | 19 +++++ lib/l10n/app_localizations_zh.dart | 19 +++++ lib/l10n/app_nl.arb | 3 + lib/l10n/app_pl.arb | 3 + lib/l10n/app_pt.arb | 3 + lib/l10n/app_pt_PT.arb | 3 + lib/l10n/app_ru.arb | 3 + lib/l10n/app_sk.arb | 3 + lib/l10n/app_sl.arb | 3 + lib/l10n/app_sv.arb | 3 + lib/l10n/app_uk.arb | 3 + lib/l10n/app_zh.arb | 3 + lib/review_mode/review_radio.dart | 11 ++- lib/screens/contact_settings_screen.dart | 45 ++++++++++++ .../connector/auto_add_config_frame_test.dart | 33 +++++++++ test/screens/settings_pages_test.dart | 73 +++++++++++++++++++ 46 files changed, 628 insertions(+), 1 deletion(-) create mode 100644 test/connector/auto_add_config_frame_test.dart diff --git a/documentation/design.md b/documentation/design.md index 6d1443dd..9ee05c93 100644 --- a/documentation/design.md +++ b/documentation/design.md @@ -124,6 +124,7 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act | Switch that reveals more controls | `SettingsReveal` | 200ms height ease, `surfaceContainerHighest`, 16px start indent. See [Reveal on enable](#reveal-on-enable) | | Settings slider | `SettingsValueSlider` | Requires a 24px `icon` (`ListTile.leading`). The title includes the selected number, so it stays visible. The drag bubble repeats it | | Read-only value in a settings row | 24px `onSurfaceVariant` icon, title (`meshTileTitleStyle`), the value on its own line in `MeshTheme.mono` 15 w500 `onSurface`, subtitle `bodyMedium` `onSurfaceVariant` | Same value style as the Settings device info card; not `StatTile`, which is for status screens (Node Name message length) | +| Settings choice from a long list | `ListTile` with a 24px `leading` icon, title and subtitle, and a `DropdownButtonFormField` under the subtitle | Same row shape as `SettingsValueSlider`; no label or helper inside the field (Hop limit in Contact Settings) | | Settings saved to a radio | `SaveToRadioPage(title:, hasChanges:, onSave:, children:)` | See [Settings pages](#settings-pages). A custom scaffold uses `UnsavedChangesGuard` + `SaveChangesAction` | | Section explanation | `SectionHeader(label, description:)` | One or two short sentences in `bodyMedium` `onSurfaceVariant` under the label, for a note that belongs to one section (Node Name, Location) | | Option that needs a longer explanation | `MeshCard(padding: EdgeInsets.zero)`: explanation text, `Divider(height: 1, indent: 16, endIndent: 16)`, the switch row, divider, optional note | Text in `bodyMedium` `onSurfaceVariant`, padding 16 / 14, so it reads like tile subtitles. The dividers are inset on both sides to match the text (Off-Grid Repeat Mode) | diff --git a/documentation/settings.md b/documentation/settings.md index 5bb31f73..0bb7a47c 100644 --- a/documentation/settings.md +++ b/documentation/settings.md @@ -92,6 +92,7 @@ The location is shown on the map, used when you share your location, and sent in - **Auto-add contacts**: users, repeaters, room servers and sensors. Newly heard nodes of the enabled types are added to the radio's contacts; others can be added later from Discovered Contacts - **Contact List Limits**: - **Overwrite oldest** (radio): when the radio's contact list is full, the oldest non-favorited contact is replaced + - **Hop limit** (radio): dropdown with No limit (default), 1 (direct only) and 2-64. The radio only auto-adds contacts heard in fewer hops than this; contacts beyond it still appear in Discovered Contacts. Only shown when the firmware reports the setting - **Limit discovered contacts** (app, not the radio; saved with the rest): keeps up to 500 discovered contacts, removing the ones heard longest ago. When off, there's no limit ### Privacy diff --git a/lib/l10n/app_bg.arb b/lib/l10n/app_bg.arb index ea97fbda..90b8c6fe 100644 --- a/lib/l10n/app_bg.arb +++ b/lib/l10n/app_bg.arb @@ -2142,6 +2142,9 @@ "discoveredContacts_importSummary": "Импортирани: {imported}, пропуснати вече известни: {skipped}, нечетими записи: {invalid}.", "discoveredContacts_importTooLarge": "Файлът за импортиране е твърде голям (максимум {maxMb} MB).", "contactsSettings_overwriteOldestSubtitle": "Когато списъкът с контакти на радиото е пълен, най-старият контакт извън любимите се заменя.", + "contactsSettings_hopLimit": "Ограничение на скоковете", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Без ограничение} =1{1 (само директно)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Радиото добавя автоматично само контакти с по-малко скокове от тази стойност. В „Открити контакти“ пак се запазват всички.", "contactsSettings_evictDiscoveredContactsTitle": "Ограничаване на откритите контакти", "contactsSettings_evictDiscoveredContactsSubtitle": "Приложението ограничава списъка „Открити контакти“ до {limit} записа. При достигане на лимита по-старите контакти се премахват. Изключете, за да премахнете ограничението.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index 899b0710..507e4a3e 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -2975,6 +2975,9 @@ "contactsSettings_autoAddSensorsTitle": "Senzory", "contactsSettings_overwriteOldestTitle": "Přepisovat nejstarší", "contactsSettings_overwriteOldestSubtitle": "Když je seznam kontaktů v rádiu plný, nahradí se nejstarší kontakt, který není oblíbený.", + "contactsSettings_hopLimit": "Limit skoků", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Bez omezení} =1{1 (pouze přímo)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Rádio automaticky přidá jen kontakty s menším počtem skoků, než je tato hodnota. Seznam „Objevené kontakty“ přesto uloží všechny.", "contactsSettings_evictDiscoveredContactsTitle": "Omezit objevené kontakty", "contactsSettings_evictDiscoveredContactsSubtitle": "Aplikace omezuje seznam „Objevené kontakty“ na {limit} položek. Po dosažení limitu jsou starší kontakty odstraněny. Vypněte pro zrušení limitu.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 57c2f44b..19fd6939 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -2231,6 +2231,9 @@ "discoveredContacts_copyContact": "Kontakt in die Zwischenablage kopieren", "contactsSettings_overwriteOldestTitle": "Ältesten überschreiben", "contactsSettings_overwriteOldestSubtitle": "Wenn die Kontaktliste des Funkgeräts voll ist, den ältesten Kontakt ersetzen, der kein Favorit ist.", + "contactsSettings_hopLimit": "Sprunglimit", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Kein Limit} =1{1 (nur direkt)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Das Funkgerät fügt nur Kontakte mit weniger Sprüngen als diesem Wert automatisch hinzu. Unter „Entdeckte Kontakte“ werden trotzdem alle gespeichert.", "contactsSettings_evictDiscoveredContactsTitle": "Entdeckte Kontakte begrenzen", "contactsSettings_evictDiscoveredContactsSubtitle": "Die App begrenzt die Liste „Entdeckte Kontakte“ auf {limit} Einträge. Ist das Limit erreicht, werden ältere Kontakte entfernt. Deaktivieren, um das Limit aufzuheben.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 642d7f16..08a22c0f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -3287,6 +3287,16 @@ "contactsSettings_autoAddSensorsTitle": "Sensors", "contactsSettings_overwriteOldestTitle": "Overwrite oldest", "contactsSettings_overwriteOldestSubtitle": "Replace the oldest non-favorited contact when the radio's contact list is full.", + "contactsSettings_hopLimit": "Hop limit", + "contactsSettings_hopLimitOption": "{hops, plural, =0{No limit} =1{1 (direct only)} other{{hops}}}", + "@contactsSettings_hopLimitOption": { + "placeholders": { + "hops": { + "type": "int" + } + } + }, + "contactsSettings_hopLimitSubtitle": "The radio only auto-adds contacts under this many hops. Discovered Contacts still saves them all.", "contactsSettings_evictDiscoveredContactsTitle": "Limit discovered contacts", "contactsSettings_evictDiscoveredContactsSubtitle": "The app sets a {limit} entry limit to the discovered contacts list, older contacts are evicted when the limit is reached. Disable to have no limits.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index e04d9993..ff107824 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -2162,6 +2162,9 @@ "discoveredContacts_searchHint": "Buscar contactos descubiertos", "discoveredContacts_addContact": "Agregar contacto", "contactsSettings_overwriteOldestSubtitle": "Cuando la lista de contactos de la radio esté llena, reemplaza el contacto no favorito más antiguo.", + "contactsSettings_hopLimit": "Límite de saltos", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Sin límite} =1{1 (solo directo)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "La radio solo añade automáticamente contactos con menos saltos que este valor. En Contactos descubiertos se siguen guardando todos.", "contactsSettings_evictDiscoveredContactsTitle": "Limitar contactos descubiertos", "contactsSettings_evictDiscoveredContactsSubtitle": "La app limita la lista \"Contactos descubiertos\" a {limit} entradas. Al alcanzar el límite, se eliminan los contactos más antiguos. Desactivar para quitar el límite.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index dd0f5e45..393797fb 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -2155,6 +2155,9 @@ "discoveredContacts_Title": "Contacts découverts", "discoveredContacts_searchHint": "Rechercher des contacts découverts", "contactsSettings_overwriteOldestSubtitle": "Lorsque la liste de contacts de la radio est pleine, remplace le plus ancien contact non favori.", + "contactsSettings_hopLimit": "Limite de sauts", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Aucune limite} =1{1 (direct uniquement)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "La radio n'ajoute automatiquement que les contacts situés à moins de sauts que cette valeur. Ils sont quand même tous enregistrés dans Contacts découverts.", "contactsSettings_evictDiscoveredContactsTitle": "Limiter les contacts découverts", "contactsSettings_evictDiscoveredContactsSubtitle": "L'application limite la liste « Contacts découverts » à {limit} entrées. Une fois la limite atteinte, les contacts les plus anciens sont supprimés. Désactivez pour supprimer la limite.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_hu.arb b/lib/l10n/app_hu.arb index 81cb437b..d1db6dc5 100644 --- a/lib/l10n/app_hu.arb +++ b/lib/l10n/app_hu.arb @@ -2227,6 +2227,9 @@ "contactsSettings_autoAddSensorsTitle": "Érzékelők", "contactsSettings_overwriteOldestTitle": "A legrégebbi felülírása", "contactsSettings_overwriteOldestSubtitle": "Ha a rádió kapcsolatlistája megtelt, a legrégebbi, nem kedvenc kapcsolat lecserélődik.", + "contactsSettings_hopLimit": "Ugráskorlát", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Nincs korlát} =1{1 (csak közvetlen)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "A rádió csak az ennél kevesebb ugrásra lévő kapcsolatokat adja hozzá automatikusan. A „Felfedezett kapcsolatok” lista továbbra is mindet elmenti.", "contactsSettings_evictDiscoveredContactsTitle": "Felfedezett kapcsolatok korlátozása", "contactsSettings_evictDiscoveredContactsSubtitle": "Az alkalmazás a „Felfedezett kapcsolatok” listát {limit} bejegyzésre korlátozza. A korlát elérésekor a régebbi kapcsolatok törlődnek. Kikapcsolva nincs korlát.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 131b24b1..12366623 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -2204,6 +2204,9 @@ } }, "contactsSettings_overwriteOldestSubtitle": "Quando l'elenco dei contatti della radio è pieno, sostituisce il contatto più vecchio non tra i preferiti.", + "contactsSettings_hopLimit": "Limite di salti", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Nessun limite} =1{1 (solo diretto)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "La radio aggiunge automaticamente solo i contatti con meno salti di questo valore. In Contatti scoperti vengono comunque salvati tutti.", "contactsSettings_evictDiscoveredContactsTitle": "Limita i contatti scoperti", "contactsSettings_evictDiscoveredContactsSubtitle": "L'app limita l'elenco \"Contatti scoperti\" a {limit} voci. Al raggiungimento del limite, i contatti più vecchi vengono rimossi. Disattiva per rimuovere il limite.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index 36c9c25f..b49fe02d 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -2237,6 +2237,9 @@ "contactsSettings_autoAddSensorsTitle": "センサー", "contactsSettings_overwriteOldestTitle": "最も古い連絡先を上書き", "contactsSettings_overwriteOldestSubtitle": "ラジオの連絡先リストが満杯になったら、お気に入り以外で最も古い連絡先を置き換えます。", + "contactsSettings_hopLimit": "ホップ数の上限", + "contactsSettings_hopLimitOption": "{hops, plural, =0{制限なし} =1{1(直接のみ)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "ラジオはこの値より少ないホップ数の連絡先のみ自動追加します。「連絡先が見つかった」にはすべて保存されます。", "contactsSettings_evictDiscoveredContactsTitle": "発見された連絡先を制限", "contactsSettings_evictDiscoveredContactsSubtitle": "アプリは「連絡先が見つかった」リストを {limit} 件に制限します。上限に達すると古い連絡先から削除されます。オフにすると上限はなくなります。", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_ko.arb b/lib/l10n/app_ko.arb index dfed602f..9e9b84d1 100644 --- a/lib/l10n/app_ko.arb +++ b/lib/l10n/app_ko.arb @@ -2142,6 +2142,9 @@ "contactsSettings_autoAddSensorsTitle": "센서", "contactsSettings_overwriteOldestTitle": "가장 오래된 연락처 덮어쓰기", "contactsSettings_overwriteOldestSubtitle": "라디오의 연락처 목록이 가득 차면 즐겨찾기가 아닌 가장 오래된 연락처를 교체합니다.", + "contactsSettings_hopLimit": "홉 수 제한", + "contactsSettings_hopLimitOption": "{hops, plural, =0{제한 없음} =1{1 (직접 연결만)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "라디오는 이 값보다 적은 홉의 연락처만 자동 추가합니다. '연락처 찾기'에는 모두 저장됩니다.", "contactsSettings_evictDiscoveredContactsTitle": "발견된 연락처 제한", "contactsSettings_evictDiscoveredContactsSubtitle": "앱은 \"연락처 찾기\" 목록을 {limit}개 항목으로 제한합니다. 한도에 도달하면 오래된 연락처부터 삭제됩니다. 끄면 제한이 없습니다.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index b5c8ad8e..6757c170 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -10025,6 +10025,24 @@ abstract class AppLocalizations { /// **'Replace the oldest non-favorited contact when the radio\'s contact list is full.'** String get contactsSettings_overwriteOldestSubtitle; + /// No description provided for @contactsSettings_hopLimit. + /// + /// In en, this message translates to: + /// **'Hop limit'** + String get contactsSettings_hopLimit; + + /// No description provided for @contactsSettings_hopLimitOption. + /// + /// In en, this message translates to: + /// **'{hops, plural, =0{No limit} =1{1 (direct only)} other{{hops}}}'** + String contactsSettings_hopLimitOption(int hops); + + /// No description provided for @contactsSettings_hopLimitSubtitle. + /// + /// In en, this message translates to: + /// **'The radio only auto-adds contacts under this many hops. Discovered Contacts still saves them all.'** + String get contactsSettings_hopLimitSubtitle; + /// No description provided for @contactsSettings_evictDiscoveredContactsTitle. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 3871cf1b..4e90dfce 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -5909,6 +5909,25 @@ class AppLocalizationsBg extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Когато списъкът с контакти на радиото е пълен, най-старият контакт извън любимите се заменя.'; + @override + String get contactsSettings_hopLimit => 'Ограничение на скоковете'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (само директно)', + zero: 'Без ограничение', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Радиото добавя автоматично само контакти с по-малко скокове от тази стойност. В „Открити контакти“ пак се запазват всички.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Ограничаване на откритите контакти'; diff --git a/lib/l10n/app_localizations_cs.dart b/lib/l10n/app_localizations_cs.dart index 14acd0b7..8f122774 100644 --- a/lib/l10n/app_localizations_cs.dart +++ b/lib/l10n/app_localizations_cs.dart @@ -5888,6 +5888,25 @@ class AppLocalizationsCs extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Když je seznam kontaktů v rádiu plný, nahradí se nejstarší kontakt, který není oblíbený.'; + @override + String get contactsSettings_hopLimit => 'Limit skoků'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (pouze přímo)', + zero: 'Bez omezení', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Rádio automaticky přidá jen kontakty s menším počtem skoků, než je tato hodnota. Seznam „Objevené kontakty“ přesto uloží všechny.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Omezit objevené kontakty'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 7769c0e0..00ea0146 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -5920,6 +5920,25 @@ class AppLocalizationsDe extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Wenn die Kontaktliste des Funkgeräts voll ist, den ältesten Kontakt ersetzen, der kein Favorit ist.'; + @override + String get contactsSettings_hopLimit => 'Sprunglimit'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (nur direkt)', + zero: 'Kein Limit', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Das Funkgerät fügt nur Kontakte mit weniger Sprüngen als diesem Wert automatisch hinzu. Unter „Entdeckte Kontakte“ werden trotzdem alle gespeichert.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Entdeckte Kontakte begrenzen'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 3b50a918..85445801 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -5828,6 +5828,25 @@ class AppLocalizationsEn extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Replace the oldest non-favorited contact when the radio\'s contact list is full.'; + @override + String get contactsSettings_hopLimit => 'Hop limit'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (direct only)', + zero: 'No limit', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'The radio only auto-adds contacts under this many hops. Discovered Contacts still saves them all.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Limit discovered contacts'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 901e76e5..6924ff52 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -5909,6 +5909,25 @@ class AppLocalizationsEs extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Cuando la lista de contactos de la radio esté llena, reemplaza el contacto no favorito más antiguo.'; + @override + String get contactsSettings_hopLimit => 'Límite de saltos'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (solo directo)', + zero: 'Sin límite', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'La radio solo añade automáticamente contactos con menos saltos que este valor. En Contactos descubiertos se siguen guardando todos.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Limitar contactos descubiertos'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 2bfc5046..bc4ea3ab 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -5923,6 +5923,25 @@ class AppLocalizationsFr extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Lorsque la liste de contacts de la radio est pleine, remplace le plus ancien contact non favori.'; + @override + String get contactsSettings_hopLimit => 'Limite de sauts'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (direct uniquement)', + zero: 'Aucune limite', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'La radio n\'ajoute automatiquement que les contacts situés à moins de sauts que cette valeur. Ils sont quand même tous enregistrés dans Contacts découverts.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Limiter les contacts découverts'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 97888e91..72f63f08 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -5907,6 +5907,25 @@ class AppLocalizationsHu extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Ha a rádió kapcsolatlistája megtelt, a legrégebbi, nem kedvenc kapcsolat lecserélődik.'; + @override + String get contactsSettings_hopLimit => 'Ugráskorlát'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (csak közvetlen)', + zero: 'Nincs korlát', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'A rádió csak az ennél kevesebb ugrásra lévő kapcsolatokat adja hozzá automatikusan. A „Felfedezett kapcsolatok” lista továbbra is mindet elmenti.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Felfedezett kapcsolatok korlátozása'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index e757cc1d..53c3c755 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -5914,6 +5914,25 @@ class AppLocalizationsIt extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Quando l\'elenco dei contatti della radio è pieno, sostituisce il contatto più vecchio non tra i preferiti.'; + @override + String get contactsSettings_hopLimit => 'Limite di salti'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (solo diretto)', + zero: 'Nessun limite', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'La radio aggiunge automaticamente solo i contatti con meno salti di questo valore. In Contatti scoperti vengono comunque salvati tutti.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Limita i contatti scoperti'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index eec2a32e..832a7be0 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -5632,6 +5632,25 @@ class AppLocalizationsJa extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'ラジオの連絡先リストが満杯になったら、お気に入り以外で最も古い連絡先を置き換えます。'; + @override + String get contactsSettings_hopLimit => 'ホップ数の上限'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1(直接のみ)', + zero: '制限なし', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'ラジオはこの値より少ないホップ数の連絡先のみ自動追加します。「連絡先が見つかった」にはすべて保存されます。'; + @override String get contactsSettings_evictDiscoveredContactsTitle => '発見された連絡先を制限'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index ebf3c99f..404c7e55 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -5642,6 +5642,25 @@ class AppLocalizationsKo extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => '라디오의 연락처 목록이 가득 차면 즐겨찾기가 아닌 가장 오래된 연락처를 교체합니다.'; + @override + String get contactsSettings_hopLimit => '홉 수 제한'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (직접 연결만)', + zero: '제한 없음', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + '라디오는 이 값보다 적은 홉의 연락처만 자동 추가합니다. \'연락처 찾기\'에는 모두 저장됩니다.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => '발견된 연락처 제한'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 84d423dc..97b8d1d2 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -5880,6 +5880,25 @@ class AppLocalizationsNl extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Als de contactenlijst van de radio vol is, het oudste contact vervangen dat geen favoriet is.'; + @override + String get contactsSettings_hopLimit => 'Hoplimiet'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (alleen direct)', + zero: 'Geen limiet', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'De radio voegt alleen contacten met minder hops dan deze waarde automatisch toe. In Ontdekte contacten worden ze nog steeds allemaal opgeslagen.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Ontdekte contacten beperken'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 0c24139c..b1570dd3 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -5950,6 +5950,25 @@ class AppLocalizationsPl extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Gdy lista kontaktów w radiu jest pełna, najstarszy kontakt spoza ulubionych zostanie zastąpiony.'; + @override + String get contactsSettings_hopLimit => 'Limit skoków'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (tylko bezpośrednio)', + zero: 'Bez limitu', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Radio automatycznie dodaje tylko kontakty z mniejszą liczbą skoków niż ta wartość. Lista „Odkryte Kontakty” nadal zapisuje wszystkie.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Ogranicz odkryte kontakty'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index e0e1b7b0..4bb3ed5f 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -5905,6 +5905,25 @@ class AppLocalizationsPt extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Quando a lista de contatos do rádio estiver cheia, substitui o contato mais antigo que não seja favorito.'; + @override + String get contactsSettings_hopLimit => 'Limite de saltos'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (somente direto)', + zero: 'Sem limite', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'O rádio só adiciona automaticamente contatos com menos saltos que este valor. Todos continuam sendo salvos em Contatos Descobertos.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Limitar contatos descobertos'; @@ -14151,6 +14170,25 @@ class AppLocalizationsPtPt extends AppLocalizationsPt { String get contactsSettings_overwriteOldestSubtitle => 'Quando a lista de contactos do rádio estiver cheia, substitui o contacto mais antigo que não seja favorito.'; + @override + String get contactsSettings_hopLimit => 'Limite de hops'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (apenas direto)', + zero: 'Sem limite', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'O rádio só adiciona automaticamente contactos com menos hops do que este valor. Todos continuam a ser guardados em Contactos descobertos.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Limitar contactos descobertos'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 0fe4cebb..ad13d760 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -5926,6 +5926,25 @@ class AppLocalizationsRu extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Когда список контактов радио заполнен, заменяется самый старый контакт не из избранного.'; + @override + String get contactsSettings_hopLimit => 'Лимит хопов'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (только напрямую)', + zero: 'Без лимита', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Радио автоматически добавляет только контакты, до которых меньше хопов, чем это значение. В списке «Обнаруженные контакты» по-прежнему сохраняются все.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Ограничивать обнаруженные контакты'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 94b88ee8..2845ae8e 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -5903,6 +5903,25 @@ class AppLocalizationsSk extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Keď je zoznam kontaktov v rádiu plný, nahradí sa najstarší kontakt, ktorý nie je obľúbený.'; + @override + String get contactsSettings_hopLimit => 'Limit skokov'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (iba priamo)', + zero: 'Bez obmedzenia', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Rádio automaticky pridá iba kontakty s menším počtom skokov, než je táto hodnota. Zoznam „Objavené kontakty“ aj tak uloží všetky.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Obmedziť objavené kontakty'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 4a656e3e..746f2330 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -5893,6 +5893,25 @@ class AppLocalizationsSl extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Ko je seznam stikov v radiu poln, se zamenja najstarejši stik, ki ni med priljubljenimi.'; + @override + String get contactsSettings_hopLimit => 'Omejitev skokov'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (samo neposredno)', + zero: 'Brez omejitve', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Radio avtomatsko doda le stike z manj skoki od te vrednosti. Seznam »Odkriti stiki« še vedno shrani vse.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Omeji odkrite stike'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index b5982c31..991d0330 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -5861,6 +5861,25 @@ class AppLocalizationsSv extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'När radions kontaktlista är full ersätts den äldsta kontakten som inte är en favorit.'; + @override + String get contactsSettings_hopLimit => 'Hoppgräns'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (endast direkt)', + zero: 'Ingen gräns', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Radion lägger bara till kontakter automatiskt om de har färre hopp än detta värde. Alla sparas ändå i Upptäckta kontakter.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Begränsa upptäckta kontakter'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 624c5c27..65ba94d5 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -5931,6 +5931,25 @@ class AppLocalizationsUk extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => 'Коли список контактів радіо заповнений, замінюється найстаріший контакт, якого немає в улюблених.'; + @override + String get contactsSettings_hopLimit => 'Ліміт переходів'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1 (лише напряму)', + zero: 'Без ліміту', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + 'Радіо автоматично додає лише контакти, до яких менше переходів, ніж це значення. У списку «Виявлені контакти» й надалі зберігаються всі.'; + @override String get contactsSettings_evictDiscoveredContactsTitle => 'Обмежувати виявлені контакти'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index da104381..a39e115a 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -5504,6 +5504,25 @@ class AppLocalizationsZh extends AppLocalizations { String get contactsSettings_overwriteOldestSubtitle => '无线电的联系人列表已满时,替换最旧的非收藏联系人。'; + @override + String get contactsSettings_hopLimit => '跳数限制'; + + @override + String contactsSettings_hopLimitOption(int hops) { + String _temp0 = intl.Intl.pluralLogic( + hops, + locale: localeName, + other: '$hops', + one: '1(仅直连)', + zero: '不限', + ); + return '$_temp0'; + } + + @override + String get contactsSettings_hopLimitSubtitle => + '无线电只会自动添加跳数少于此值的联系人。“已发现的联系人”中仍会保存全部。'; + @override String get contactsSettings_evictDiscoveredContactsTitle => '限制已发现的联系人'; diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index d76228dc..21d7f20d 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -2180,6 +2180,9 @@ } }, "contactsSettings_overwriteOldestSubtitle": "Als de contactenlijst van de radio vol is, het oudste contact vervangen dat geen favoriet is.", + "contactsSettings_hopLimit": "Hoplimiet", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Geen limiet} =1{1 (alleen direct)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "De radio voegt alleen contacten met minder hops dan deze waarde automatisch toe. In Ontdekte contacten worden ze nog steeds allemaal opgeslagen.", "contactsSettings_evictDiscoveredContactsTitle": "Ontdekte contacten beperken", "contactsSettings_evictDiscoveredContactsSubtitle": "De app beperkt de lijst \"Ontdekte contacten\" tot {limit} items. Bij het bereiken van de limiet worden oudere contacten verwijderd. Schakel uit om de limiet op te heffen.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index 8530ef0e..e0d02776 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -2180,6 +2180,9 @@ "discoveredContacts_importSummary": "Zaimportowano: {imported}, pominięto już znane: {skipped}, nieczytelne wpisy: {invalid}.", "discoveredContacts_importTooLarge": "Plik importu jest zbyt duży (maksymalnie {maxMb} MB).", "contactsSettings_overwriteOldestSubtitle": "Gdy lista kontaktów w radiu jest pełna, najstarszy kontakt spoza ulubionych zostanie zastąpiony.", + "contactsSettings_hopLimit": "Limit skoków", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Bez limitu} =1{1 (tylko bezpośrednio)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Radio automatycznie dodaje tylko kontakty z mniejszą liczbą skoków niż ta wartość. Lista „Odkryte Kontakty” nadal zapisuje wszystkie.", "contactsSettings_evictDiscoveredContactsTitle": "Ogranicz odkryte kontakty", "contactsSettings_evictDiscoveredContactsSubtitle": "Aplikacja ogranicza listę „Odkryte Kontakty” do {limit} pozycji. Po osiągnięciu limitu starsze kontakty są usuwane. Wyłącz, aby znieść limit.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index fd628855..f3547f3f 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -2073,6 +2073,9 @@ } }, "contactsSettings_overwriteOldestSubtitle": "Quando a lista de contatos do rádio estiver cheia, substitui o contato mais antigo que não seja favorito.", + "contactsSettings_hopLimit": "Limite de saltos", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Sem limite} =1{1 (somente direto)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "O rádio só adiciona automaticamente contatos com menos saltos que este valor. Todos continuam sendo salvos em Contatos Descobertos.", "contactsSettings_evictDiscoveredContactsTitle": "Limitar contatos descobertos", "contactsSettings_evictDiscoveredContactsSubtitle": "O app limita a lista \"Contatos Descobertos\" a {limit} entradas. Ao atingir o limite, os contatos mais antigos são removidos. Desative para remover o limite.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_pt_PT.arb b/lib/l10n/app_pt_PT.arb index db33d8fd..6f11ba88 100644 --- a/lib/l10n/app_pt_PT.arb +++ b/lib/l10n/app_pt_PT.arb @@ -1610,6 +1610,9 @@ "contactsSettings_autoAddSensorsTitle": "Sensores", "contactsSettings_overwriteOldestTitle": "Substituir o mais antigo", "contactsSettings_overwriteOldestSubtitle": "Quando a lista de contactos do rádio estiver cheia, substitui o contacto mais antigo que não seja favorito.", + "contactsSettings_hopLimit": "Limite de hops", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Sem limite} =1{1 (apenas direto)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "O rádio só adiciona automaticamente contactos com menos hops do que este valor. Todos continuam a ser guardados em Contactos descobertos.", "contactsSettings_evictDiscoveredContactsTitle": "Limitar contactos descobertos", "contactsSettings_evictDiscoveredContactsSubtitle": "A app limita a lista \"Contactos descobertos\" a {limit} entradas. Ao atingir o limite, os contactos mais antigos são removidos. Desative para remover o limite.", "discoveredContacts_Title": "Contactos descobertos", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index 36fda42a..f1534715 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -1321,6 +1321,9 @@ "discoveredContacts_importSummary": "Импортировано: {imported}, пропущено уже известных: {skipped}, нечитаемых записей: {invalid}.", "discoveredContacts_importTooLarge": "Файл импорта слишком большой (максимум {maxMb} МБ).", "contactsSettings_overwriteOldestSubtitle": "Когда список контактов радио заполнен, заменяется самый старый контакт не из избранного.", + "contactsSettings_hopLimit": "Лимит хопов", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Без лимита} =1{1 (только напрямую)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Радио автоматически добавляет только контакты, до которых меньше хопов, чем это значение. В списке «Обнаруженные контакты» по-прежнему сохраняются все.", "contactsSettings_evictDiscoveredContactsTitle": "Ограничивать обнаруженные контакты", "contactsSettings_evictDiscoveredContactsSubtitle": "Приложение ограничивает список «Обнаруженные контакты» до {limit} записей. При достижении лимита старые контакты удаляются. Отключите, чтобы снять ограничение.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_sk.arb b/lib/l10n/app_sk.arb index d0154f79..14b282fa 100644 --- a/lib/l10n/app_sk.arb +++ b/lib/l10n/app_sk.arb @@ -2147,6 +2147,9 @@ } }, "contactsSettings_overwriteOldestSubtitle": "Keď je zoznam kontaktov v rádiu plný, nahradí sa najstarší kontakt, ktorý nie je obľúbený.", + "contactsSettings_hopLimit": "Limit skokov", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Bez obmedzenia} =1{1 (iba priamo)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Rádio automaticky pridá iba kontakty s menším počtom skokov, než je táto hodnota. Zoznam „Objavené kontakty“ aj tak uloží všetky.", "contactsSettings_evictDiscoveredContactsTitle": "Obmedziť objavené kontakty", "contactsSettings_evictDiscoveredContactsSubtitle": "Aplikácia obmedzuje zoznam „Objavené kontakty“ na {limit} položiek. Po dosiahnutí limitu sa staršie kontakty odstránia. Vypnite pre zrušenie limitu.", "@contactsSettings_evictDiscoveredContactsSubtitle": { diff --git a/lib/l10n/app_sl.arb b/lib/l10n/app_sl.arb index 7e0e7222..fc2acb06 100644 --- a/lib/l10n/app_sl.arb +++ b/lib/l10n/app_sl.arb @@ -2073,6 +2073,9 @@ } }, "contactsSettings_overwriteOldestSubtitle": "Ko je seznam stikov v radiu poln, se zamenja najstarejši stik, ki ni med priljubljenimi.", + "contactsSettings_hopLimit": "Omejitev skokov", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Brez omejitve} =1{1 (samo neposredno)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Radio avtomatsko doda le stike z manj skoki od te vrednosti. Seznam »Odkriti stiki« še vedno shrani vse.", "contactsSettings_evictDiscoveredContactsTitle": "Omeji odkrite stike", "contactsSettings_evictDiscoveredContactsSubtitle": "Aplikacija omeji seznam »Odkriti stiki« na {limit} vnosov. Ko je omejitev dosežena, se starejši stiki odstranijo. Izklopite za odpravo omejitve.", "common_deleteAll": "Izbriši vse", diff --git a/lib/l10n/app_sv.arb b/lib/l10n/app_sv.arb index 0962936c..68f4d01e 100644 --- a/lib/l10n/app_sv.arb +++ b/lib/l10n/app_sv.arb @@ -2074,6 +2074,9 @@ "discoveredContacts_importSummary": "Importerade: {imported}, hoppade över redan kända: {skipped}, oläsliga poster: {invalid}.", "discoveredContacts_importTooLarge": "Importfilen är för stor (högst {maxMb} MB).", "contactsSettings_overwriteOldestSubtitle": "När radions kontaktlista är full ersätts den äldsta kontakten som inte är en favorit.", + "contactsSettings_hopLimit": "Hoppgräns", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Ingen gräns} =1{1 (endast direkt)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Radion lägger bara till kontakter automatiskt om de har färre hopp än detta värde. Alla sparas ändå i Upptäckta kontakter.", "contactsSettings_evictDiscoveredContactsTitle": "Begränsa upptäckta kontakter", "contactsSettings_evictDiscoveredContactsSubtitle": "Appen begränsar listan ”Upptäckta kontakter” till {limit} poster. När gränsen nås tas äldre kontakter bort. Stäng av för att ta bort gränsen.", "common_deleteAll": "Ta bort alla", diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index fa657172..418a62f0 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -2152,6 +2152,9 @@ "discoveredContacts_importSummary": "Імпортовано: {imported}, пропущено вже відомих: {skipped}, нечитабельних записів: {invalid}.", "discoveredContacts_importTooLarge": "Файл імпорту завеликий (максимум {maxMb} МБ).", "contactsSettings_overwriteOldestSubtitle": "Коли список контактів радіо заповнений, замінюється найстаріший контакт, якого немає в улюблених.", + "contactsSettings_hopLimit": "Ліміт переходів", + "contactsSettings_hopLimitOption": "{hops, plural, =0{Без ліміту} =1{1 (лише напряму)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "Радіо автоматично додає лише контакти, до яких менше переходів, ніж це значення. У списку «Виявлені контакти» й надалі зберігаються всі.", "contactsSettings_evictDiscoveredContactsTitle": "Обмежувати виявлені контакти", "contactsSettings_evictDiscoveredContactsSubtitle": "Застосунок обмежує список «Виявлені контакти» до {limit} записів. Коли ліміт досягнуто, старіші контакти видаляються. Вимкніть, щоб зняти обмеження.", "common_deleteAll": "Видалити все", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 018b2b7d..56a03ab2 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -2078,6 +2078,9 @@ } }, "contactsSettings_overwriteOldestSubtitle": "无线电的联系人列表已满时,替换最旧的非收藏联系人。", + "contactsSettings_hopLimit": "跳数限制", + "contactsSettings_hopLimitOption": "{hops, plural, =0{不限} =1{1(仅直连)} other{{hops}}}", + "contactsSettings_hopLimitSubtitle": "无线电只会自动添加跳数少于此值的联系人。“已发现的联系人”中仍会保存全部。", "contactsSettings_evictDiscoveredContactsTitle": "限制已发现的联系人", "contactsSettings_evictDiscoveredContactsSubtitle": "应用将“已发现的联系人”列表限制为 {limit} 条。达到上限时会移除较旧的联系人。关闭后不限数量。", "common_deleteAll": "删除全部", diff --git a/lib/review_mode/review_radio.dart b/lib/review_mode/review_radio.dart index 91abe8a6..44ae7a58 100644 --- a/lib/review_mode/review_radio.dart +++ b/lib/review_mode/review_radio.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:math' as math; import 'package:flutter/foundation.dart'; @@ -66,6 +67,7 @@ class ReviewRadio { int _txPowerDbm = ReviewScript.txPowerDbm; int _autoAddFlags = autoAddChatFlag | autoAddRepeaterFlag | autoAddRoomServerFlag; + int _autoAddMaxHops = 0; int _timeOffsetSecs = 0; /// Frames radio to app. Each event is one complete companion frame. @@ -240,10 +242,17 @@ class ReviewRadio { _emit([ReviewFrames.customVars('gps:0')]); break; case cmdGetAutoAddConfig: - _emit([ReviewFrames.autoAddConfig(flags: _autoAddFlags)]); + _emit([ + ReviewFrames.autoAddConfig( + flags: _autoAddFlags, + maxHops: _autoAddMaxHops, + ), + ]); break; case cmdSetAutoAddConfig: if (frame.length >= 2) _autoAddFlags = frame[1]; + // Like firmware: the optional hop limit, capped at 64. + if (frame.length >= 3) _autoAddMaxHops = math.min(frame[2], 64); _emit([ReviewFrames.ok()]); break; case cmdGetAllowedRepeatFreq: diff --git a/lib/screens/contact_settings_screen.dart b/lib/screens/contact_settings_screen.dart index 37fd8c9c..3fcd171d 100644 --- a/lib/screens/contact_settings_screen.dart +++ b/lib/screens/contact_settings_screen.dart @@ -16,6 +16,7 @@ typedef _ContactForm = ({ bool autoAddRoomServers, bool autoAddSensors, bool overwriteOldest, + int? maxHops, bool evictDiscovered, }); @@ -33,6 +34,8 @@ class _ContactSettingsScreenState extends State { late bool _autoAddRoomServers; late bool _autoAddSensors; late bool _overwriteOldest; + // Null when the firmware doesn't report a hop limit. + int? _maxHops; late bool _evictDiscovered; late _ContactForm _savedForm; @@ -45,6 +48,7 @@ class _ContactSettingsScreenState extends State { _autoAddRoomServers = connector.autoAddRoomServers ?? false; _autoAddSensors = connector.autoAddSensors ?? false; _overwriteOldest = connector.autoAddOverwriteOldest ?? false; + _maxHops = connector.autoAddMaxHops; _evictDiscovered = context .read() .settings @@ -58,6 +62,7 @@ class _ContactSettingsScreenState extends State { autoAddRoomServers: _autoAddRoomServers, autoAddSensors: _autoAddSensors, overwriteOldest: _overwriteOldest, + maxHops: _maxHops, evictDiscovered: _evictDiscovered, ); @@ -73,6 +78,8 @@ class _ContactSettingsScreenState extends State { autoAddRoomServer: form.autoAddRoomServers, autoAddSensor: form.autoAddSensors, overwriteOldest: form.overwriteOldest, + // Sent only when changed, so the frame is otherwise unchanged. + maxHops: form.maxHops != _savedForm.maxHops ? form.maxHops : null, ), ); await connector.sendFrame(buildGetAutoAddFlagsFrame()); @@ -168,6 +175,44 @@ class _ContactSettingsScreenState extends State { value: _overwriteOldest, onChanged: (v) => _overwriteOldest = v, ), + if (_maxHops != null) ...[ + divider, + // Same row shape as SettingsValueSlider: icon, title and + // description, with the dropdown under the description. + ListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 4, + ), + leading: const Icon(Icons.linear_scale, size: 24), + title: Text(l10n.contactsSettings_hopLimit), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(l10n.contactsSettings_hopLimitSubtitle), + const SizedBox(height: 8), + DropdownButtonFormField( + initialValue: _maxHops, + isExpanded: true, + // Firmware: 0 = no limit, N = under N hops (max 64). + items: [ + for (var hops = 0; hops <= 64; hops++) + DropdownMenuItem( + value: hops, + child: Text( + l10n.contactsSettings_hopLimitOption(hops), + overflow: TextOverflow.ellipsis, + ), + ), + ], + onChanged: (v) { + if (v != null) setState(() => _maxHops = v); + }, + ), + ], + ), + ), + ], divider, _switch( // The Discovered Contacts icon. diff --git a/test/connector/auto_add_config_frame_test.dart b/test/connector/auto_add_config_frame_test.dart new file mode 100644 index 00000000..df3eebd0 --- /dev/null +++ b/test/connector/auto_add_config_frame_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_protocol.dart'; + +void main() { + // CMD_SET_AUTOADD_CONFIG: [cmd][flags][autoadd_max_hops?]. Firmware stores + // the third byte (capped at 64) only when it is present. + group('buildSetAutoAddConfigFrame', () { + Iterable frame({int? maxHops}) => buildSetAutoAddConfigFrame( + autoAddChat: true, + autoAddRepeater: false, + autoAddRoomServer: true, + autoAddSensor: false, + overwriteOldest: true, + maxHops: maxHops, + ); + + const flags = + autoAddChatFlag | autoAddRoomServerFlag | autoAddOverwriteOldestFlag; + + test('omits the hop limit when not given', () { + expect(frame(), [cmdSetAutoAddConfig, flags]); + }); + + test('appends the hop limit, including 0 (no limit)', () { + expect(frame(maxHops: 8), [cmdSetAutoAddConfig, flags, 8]); + expect(frame(maxHops: 0), [cmdSetAutoAddConfig, flags, 0]); + }); + + test('caps the hop limit at 64', () { + expect(frame(maxHops: 200), [cmdSetAutoAddConfig, flags, 64]); + }); + }); +} diff --git a/test/screens/settings_pages_test.dart b/test/screens/settings_pages_test.dart index bd2c298f..51d5713b 100644 --- a/test/screens/settings_pages_test.dart +++ b/test/screens/settings_pages_test.dart @@ -37,6 +37,7 @@ final _l10n = AppLocalizationsEn(); MeshCoreConnector? _sharedConnector; AppSettingsService? _sharedSettings; +final _frameLog = BleDebugLogService(); Future _connectedConnector(WidgetTester tester) async { if (_sharedConnector != null) return _sharedConnector!; @@ -51,6 +52,7 @@ Future _connectedConnector(WidgetTester tester) async { pathHistoryService: PathHistoryService(storage), appSettingsService: settings, translationService: translation, + bleDebugLogService: _frameLog, ); connector.reviewRadioFactoryForTest = () => ReviewRadio( scheduledMessageInterval: const Duration(hours: 1), @@ -338,6 +340,77 @@ void main() { await tester.pumpWidget(const SizedBox()); }); + testWidgets('Contact Settings sends the hop limit and reads it back', ( + tester, + ) async { + final connector = await _connectedConnector(tester); + final original = connector.autoAddMaxHops; + expect(original, isNotNull, reason: 'review radio reports the hop limit'); + await tester.pumpWidget( + _app(connector, _launcher(const ContactSettingsScreen())), + ); + await _open(tester); + String option(int hops) => _l10n.contactsSettings_hopLimitOption(hops); + expect(find.text(option(original!)), findsOneWidget); + + Future setHops(int hops) async { + final field = find.byType(DropdownButtonFormField); + await tester.ensureVisible(field); + await tester.pumpAndSettle(); + await tester.tap(field); + await tester.pumpAndSettle(); + // The open menu builds only the rows around the current value. + final item = find.text(option(hops)); + await tester.scrollUntilVisible( + item, + hops < connector.autoAddMaxHops! ? -48 : 48, + scrollable: find.byType(Scrollable).last, + ); + await tester.pumpAndSettle(); + await tester.tap(item.last); + await tester.pumpAndSettle(); + await tester.tap(_saveAction); + await _waitFor(tester, () => connector.autoAddMaxHops == hops); + } + + // The last frame of [code] the app sent to the radio. + List lastSent(int code) => _frameLog.entries + .lastWhere((e) => e.outgoing && e.payload.first == code) + .payload; + int sentCount(int code) => _frameLog.entries + .where((e) => e.outgoing && e.payload.first == code) + .length; + + final fetchesBefore = sentCount(cmdGetAutoAddConfig); + await setHops(8); + expect(connector.autoAddMaxHops, 8); + expect(find.text(option(8)), findsOneWidget); + expect(_saveAction, findsNothing); + // [CMD_SET_AUTOADD_CONFIG][flags][max hops], then a fetch to read it back. + expect(lastSent(cmdSetAutoAddConfig), hasLength(3)); + expect(lastSent(cmdSetAutoAddConfig).last, 8); + expect(sentCount(cmdGetAutoAddConfig), fetchesBefore + 1); + + // Changing only another setting sends the old two-byte frame. + final overwrite = find.text(_l10n.contactsSettings_overwriteOldestTitle); + for (var i = 0; i < 2; i++) { + await tester.ensureVisible(overwrite); + await tester.pumpAndSettle(); + await tester.tap(overwrite); + await tester.pump(); + await tester.tap(_saveAction); + await _waitFor(tester, () => _saveAction.evaluate().isEmpty); + expect(lastSent(cmdSetAutoAddConfig), hasLength(2)); + } + expect(connector.autoAddMaxHops, 8); + + await setHops(original); + expect(connector.autoAddMaxHops, original); + expect(lastSent(cmdSetAutoAddConfig), hasLength(3)); + expect(lastSent(cmdSetAutoAddConfig).last, original); + await tester.pumpWidget(const SizedBox()); + }); + testWidgets('Node Name counts bytes and saves to the radio', (tester) async { final connector = await _connectedConnector(tester); final originalName = connector.selfName!; From f3cdedf7b091bec1590a9e31f598041e3215fa33 Mon Sep 17 00:00:00 2001 From: zjs81 <30362347+zjs81@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:00:40 -0700 Subject: [PATCH 2/2] Move chat compression to the menu with its own page The Compression control leaves the top of DM and channel chats. The overflow menu now shows Compression: Off|SMAZ|Cyr2Lat and opens a page with the three options, short notes and the Cyr2Lat profile picker. Adds SMAZ codec tests. --- documentation/additional-features.md | 4 +- documentation/channels.md | 4 +- documentation/chat-and-messaging.md | 4 +- documentation/design.md | 4 +- lib/l10n/app_en.arb | 9 +- lib/l10n/app_localizations.dart | 14 +- lib/l10n/app_localizations_bg.dart | 3 - lib/l10n/app_localizations_cs.dart | 3 - lib/l10n/app_localizations_de.dart | 3 - lib/l10n/app_localizations_en.dart | 9 +- lib/l10n/app_localizations_es.dart | 3 - 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 | 3 - lib/l10n/app_localizations_ko.dart | 3 - lib/l10n/app_localizations_nl.dart | 3 - lib/l10n/app_localizations_pl.dart | 3 - lib/l10n/app_localizations_pt.dart | 8 - lib/l10n/app_localizations_ru.dart | 3 - lib/l10n/app_localizations_sk.dart | 3 - lib/l10n/app_localizations_sl.dart | 3 - lib/l10n/app_localizations_sv.dart | 4 - lib/l10n/app_localizations_uk.dart | 3 - lib/l10n/app_localizations_zh.dart | 3 - lib/screens/channel_chat_screen.dart | 58 ++- lib/screens/chat_compression_screen.dart | 236 ++++++++++++ lib/screens/chat_screen.dart | 47 ++- lib/widgets/chat_compression_selector.dart | 364 ------------------ test/helpers/smaz_test.dart | 172 +++++++++ .../screens/chat_compression_screen_test.dart | 265 +++++++++++++ test/screens/offline_mode_test.dart | 57 +-- .../chat_compression_selector_test.dart | 334 ---------------- 33 files changed, 798 insertions(+), 846 deletions(-) create mode 100644 lib/screens/chat_compression_screen.dart delete mode 100644 lib/widgets/chat_compression_selector.dart create mode 100644 test/helpers/smaz_test.dart create mode 100644 test/screens/chat_compression_screen_test.dart delete mode 100644 test/widgets/chat_compression_selector_test.dart diff --git a/documentation/additional-features.md b/documentation/additional-features.md index e01949b6..ae43163c 100644 --- a/documentation/additional-features.md +++ b/documentation/additional-features.md @@ -61,9 +61,9 @@ A list of nodes heard passively over the air but not yet added as contacts. Each ## Compression (SMAZ and Cyr2Lat) ### Where to Find It -Every open direct-message and channel chat shows **Compression: Off**, **Compression: SMAZ** or **Compression: Cyr2Lat** in a strip just below the app bar, above the messages. Tap it to open one sheet with the three choices and what each does. The choice applies to that contact or channel only and is saved on the phone, so it can be changed while the radio is offline. A channel that has not synced from the radio yet has no saved identity, so the strip is disabled and says why. +The top-right menu of every direct-message and channel chat has a **Compression: Off**, **Compression: SMAZ** or **Compression: Cyr2Lat** item. Tap it to open a Compression page with the three choices and a short note on each. The choice applies to that contact or channel only and is saved on the phone, so it can be changed while the radio is offline. A channel that has not synced from the radio yet has no saved identity, so the choices are disabled and the page says why. -Only one mode is active per chat. Choosing SMAZ turns Cyr2Lat off and the other way round. Off and SMAZ close the sheet once saved; Cyr2Lat keeps it open to show its profile picker. If saving fails, the sheet says so and keeps showing the saved choice. +Only one mode is active per chat. Choosing SMAZ turns Cyr2Lat off and the other way round. Cyr2Lat shows its profile picker on the same page. If saving fails, the page says so and keeps showing the saved choice. ### Off Sends your text exactly as typed. Every app can read it. diff --git a/documentation/channels.md b/documentation/channels.md index 6f324f7d..be8537f5 100644 --- a/documentation/channels.md +++ b/documentation/channels.md @@ -82,9 +82,9 @@ Tap a channel card to open the channel chat screen. - Overflow menu (⋮) → **Show bookmarks** toggles the channel's bookmarked-message filter; the bookmark icon is filled while active and outlined while inactive. - Overflow menu (⋮) → **Chat background**: a color or picture, with a fade slider, behind this channel only. See [Chat backgrounds](themes.md#chat-backgrounds). Holiday greetings in new messages play a short animation, as in [direct chat](chat-and-messaging.md#message-list) -### Compression Strip +### Compression -Below the app bar, above the messages, the same strip as in [direct chats](chat-and-messaging.md#compression-strip) shows and changes this channel's compression: Off, SMAZ or Cyr2Lat. It is stored with the channel's key, so every slot holding that channel shares it, and it can be changed offline. Until the channel has synced from the radio the strip is disabled and says why. See [Compression](additional-features.md#compression-smaz-and-cyr2lat). +The top-right menu has the same Compression item as [direct chats](chat-and-messaging.md#compression); it shows and changes this channel's compression: Off, SMAZ or Cyr2Lat. It is stored with the channel's key, so every slot holding that channel shares it, and it can be changed offline. Until the channel has synced from the radio the choices are disabled and the page says why. See [Compression](additional-features.md#compression-smaz-and-cyr2lat). ### Message Display diff --git a/documentation/chat-and-messaging.md b/documentation/chat-and-messaging.md index 40826682..21914cdc 100644 --- a/documentation/chat-and-messaging.md +++ b/documentation/chat-and-messaging.md @@ -22,9 +22,9 @@ From the Contacts screen, tap any Chat-type contact to open the ChatScreen. - **Search** (magnifier icon): Replaces the title with a search field and lists every message in this conversation's full history whose text (or translation) contains the typed word, newest first, with matches highlighted. Channel search also matches sender names and skips messages caught by the [message filter](message-filter.md). Back, Esc or the arrow closes search. Channel chats have the same button. - **Overflow menu** (⋮ icon): Contains Routing, Info, Telemetry, Settings (link images and telemetry permissions), Chat background, Clear Chat, and Remove from contacts (rooms also have Room Server Management). Routing opens the routing sheet where you can switch between Auto, Direct, and Flood routing and manage recent paths (hop count, round-trip time, age, success count, color-coded by repeater). Info shows a dialog with contact type, path, GPS coordinates, and public key. Chat background sets a color or picture (with a fade slider) behind this chat only; see [Chat backgrounds](themes.md#chat-backgrounds). -### Compression Strip +### Compression -Below the app bar, above the messages, a strip shows **Compression: Off**, **SMAZ** or **Cyr2Lat** for this contact. Tap it to choose a mode in one sheet that explains each: SMAZ is lossless but needs a SMAZ-aware app on the other end and is only used when it makes a message smaller; Cyr2Lat swaps some Cyrillic letters for lookalike Latin ones, stays readable everywhere, but changes the exact characters, using the chosen Cyr2Lat profile. The setting is saved on the phone and can be changed offline. Channel chats show the same strip. See [Compression](additional-features.md#compression-smaz-and-cyr2lat). +The top-right menu has a **Compression: Off**, **SMAZ** or **Cyr2Lat** item for this contact. Tap it to choose a mode on a Compression page that explains each: SMAZ is lossless but needs a SMAZ-aware app on the other end and is only used when it makes a message smaller; Cyr2Lat swaps some Cyrillic letters for lookalike Latin ones, stays readable everywhere, but changes the exact characters, using the chosen Cyr2Lat profile. The setting is saved on the phone and can be changed offline. Channel chats have the same menu item. See [Compression](additional-features.md#compression-smaz-and-cyr2lat). ### Message List diff --git a/documentation/design.md b/documentation/design.md index 6d1443dd..dab89622 100644 --- a/documentation/design.md +++ b/documentation/design.md @@ -130,8 +130,8 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act | Note at the top of a page or section | `MeshInfoCard(text)` | Info icon and `bodyMedium` text in a `MeshCard`; one or two short sentences (Add Contact, Privacy) | | Text field with a byte limit | `TextField` with `x / max` as `suffixIcon` (Node Name) | Count always visible. Input past the limit is allowed: the count turns `error`, `errorText` says how far over, and Save is disabled. Don't block input silently | | Choosing a point on a map | `LocationPickerScreen(initial:)` | Page with a fixed centre pin; returns the `LatLng` to the form | -| Radio-style choice in a sheet | `MeshSheetOption` | Used by the language picker, map time filter and compression sheet. Optional `subtitle` explains the option; `onTap: null` disables it. Selected rows show a filled radio icon **and** a bold title, with `selected` semantics | -| Per-chat setting at the top of a chat | Full-width strip under the app bar, above the transcript (`ChatCompressionSelector` in `widgets/chat_compression_selector.dart`) | `surfaceContainerLow` fill, `outlineVariant` bottom border, 48dp minimum height, `bodyLarge` w600 "Label: value ▾"; tap opens one `showMeshSheet` with `MeshSheetOption`s. Shows the saved value only; a spinner replaces ▾ while saving; a disabled strip shows why below the label. One shared widget for DM and channel chats; parents pass state and async callbacks | +| Radio-style choice in a sheet | `MeshSheetOption` | Used by the language picker, map time filter and compression page. Optional `subtitle` explains the option; `onTap: null` disables it. Selected rows show a filled radio icon **and** a bold title, with `selected` semantics | +| Per-chat setting | Overflow-menu item `[icon] Label: value` that opens a dedicated page (`ChatCompressionScreen` in `screens/chat_compression_screen.dart`) | Same `Label: value` pattern as the channel `Notifications: ...` item. Page: centred `AdaptiveAppBarTitle`, `SectionHeader` with a one-sentence description, a `MeshCard(padding: EdgeInsets.zero)` of `MeshSheetOption` rows split by `Divider(height: 1, indent: 16)`, short notes per option, a `MeshInfoCard` when the choice is locked, an error `MeshCard` when a save fails, and a spinner in the app bar while saving. Shows the saved value only. One shared page for DM and channel chats; parents pass state and async callbacks | | Choosing between images | Selectable thumbnail tiles in a centred `Wrap` | Image send versions (`_versionTile` in `image_send_preview_sheet.dart`). `InkWell` with `MeshRadii.sm`; selected tile gets a 3px `primary` border **and** a `primary` check badge (never colour alone); caption under the tile in `bodySmall`, w600 when selected; figures such as packet counts in `MeshTheme.mono` 12; wrap the tile in `Semantics(button: true, selected:, label:)` | | Editing a set of members | Current items first, then a searchable add list | Group editor (`contact_group_editor_dialog.dart`). Wrapping upper-case section label with the count ("Current members (N)"); each member row has a trailing `IconButton` remove (`error` colour, tooltip names the item); the add list excludes current members, and tapping the row or its `primary` add button adds it | | Popup menu row | **always** `PopupMenuItem(child: MeshMenuItemRow(icon:, label:))` | Relies on `MeshTheme.popupMenuTheme` (`surfaceContainerHigh`, `MeshRadii.md`); `MeshMenuItemRow` gives a 20px icon slot, 12px gap, and 2-line wrap + ellipsis (`leading:` for `ThemedIcon`, no icon keeps the 20px slot). Main views share `mainOverflowTrailingItems` (`widgets/connect_sheet.dart`) | diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 642d7f16..2c017afc 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -4466,7 +4466,7 @@ "chatCompression_title": "Compression", "chatCompression_label": "Compression: {mode}", "@chatCompression_label": { - "description": "Always-visible control at the top of a chat; mode is Off, SMAZ or Cyr2Lat", + "description": "Chat menu item that opens the compression page; mode is Off, SMAZ or Cyr2Lat", "placeholders": { "mode": { "type": "String" @@ -4476,11 +4476,10 @@ "chatCompression_off": "Off", "chatCompression_smaz": "SMAZ", "chatCompression_cyr2lat": "Cyr2Lat", - "chatCompression_changeHint": "Change compression for this chat", "chatCompression_sheetSubtitle": "Applies to messages you send in this chat. Saved on this phone.", - "chatCompression_offDescription": "No compression. Sends your text exactly as typed. Every app can read it. Saves no bytes.", - "chatCompression_smazDescription": "Lossless compression for short text. The recipient's app must support SMAZ; other apps show unreadable \"s:…\" text. Only used when it makes a message smaller, so not every message is compressed.", - "chatCompression_cyr2latDescription": "Not lossless. Swaps some Cyrillic letters for lookalike Latin ones (А→A, З→3) to save bytes. Readable in any app with no decoding, but the exact characters change, including your own sent messages here. Copying, search and technical text may be affected. Results depend on the chosen profile.", + "chatCompression_offDescription": "Sends your text as typed. Every app can read it.", + "chatCompression_smazDescription": "Shrinks English text. Used only when the message gets shorter. Apps without SMAZ show \"s:…\" instead of your text.", + "chatCompression_cyr2latDescription": "Swaps Cyrillic letters for similar Latin ones (А→A). Every app can read it, but the characters change. Not lossless.", "chatCompression_profile": "Cyr2Lat profile", "chatCompression_noStorageId": "Can't change compression until this channel has synced from the radio.", "chatCompression_saveFailed": "Couldn't save the compression setting. Showing the saved setting.", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index b5c8ad8e..311e0514 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -12946,7 +12946,7 @@ abstract class AppLocalizations { /// **'Compression'** String get chatCompression_title; - /// Always-visible control at the top of a chat; mode is Off, SMAZ or Cyr2Lat + /// Chat menu item that opens the compression page; mode is Off, SMAZ or Cyr2Lat /// /// In en, this message translates to: /// **'Compression: {mode}'** @@ -12970,12 +12970,6 @@ abstract class AppLocalizations { /// **'Cyr2Lat'** String get chatCompression_cyr2lat; - /// No description provided for @chatCompression_changeHint. - /// - /// In en, this message translates to: - /// **'Change compression for this chat'** - String get chatCompression_changeHint; - /// No description provided for @chatCompression_sheetSubtitle. /// /// In en, this message translates to: @@ -12985,19 +12979,19 @@ abstract class AppLocalizations { /// No description provided for @chatCompression_offDescription. /// /// In en, this message translates to: - /// **'No compression. Sends your text exactly as typed. Every app can read it. Saves no bytes.'** + /// **'Sends your text as typed. Every app can read it.'** String get chatCompression_offDescription; /// No description provided for @chatCompression_smazDescription. /// /// In en, this message translates to: - /// **'Lossless compression for short text. The recipient\'s app must support SMAZ; other apps show unreadable \"s:…\" text. Only used when it makes a message smaller, so not every message is compressed.'** + /// **'Shrinks English text. Used only when the message gets shorter. Apps without SMAZ show \"s:…\" instead of your text.'** String get chatCompression_smazDescription; /// No description provided for @chatCompression_cyr2latDescription. /// /// In en, this message translates to: - /// **'Not lossless. Swaps some Cyrillic letters for lookalike Latin ones (А→A, З→3) to save bytes. Readable in any app with no decoding, but the exact characters change, including your own sent messages here. Copying, search and technical text may be affected. Results depend on the chosen profile.'** + /// **'Swaps Cyrillic letters for similar Latin ones (А→A). Every app can read it, but the characters change. Not lossless.'** String get chatCompression_cyr2latDescription; /// No description provided for @chatCompression_profile. diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 3871cf1b..577d15f8 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -7790,9 +7790,6 @@ class AppLocalizationsBg extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Кир→Лат'; - @override - String get chatCompression_changeHint => 'Промяна на компресията за този чат'; - @override String get chatCompression_sheetSubtitle => 'Важи за съобщенията, които изпращате в този чат. Запазва се на този телефон.'; diff --git a/lib/l10n/app_localizations_cs.dart b/lib/l10n/app_localizations_cs.dart index 14acd0b7..2c3512f1 100644 --- a/lib/l10n/app_localizations_cs.dart +++ b/lib/l10n/app_localizations_cs.dart @@ -7764,9 +7764,6 @@ class AppLocalizationsCs extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Změnit kompresi pro tento chat'; - @override String get chatCompression_sheetSubtitle => 'Platí pro zprávy odeslané v tomto chatu. Uloženo v tomto telefonu.'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 7769c0e0..2ee48790 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -7801,9 +7801,6 @@ class AppLocalizationsDe extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Kompression für diesen Chat ändern'; - @override String get chatCompression_sheetSubtitle => 'Gilt für Nachrichten, die Sie in diesem Chat senden. Auf diesem Telefon gespeichert.'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 3b50a918..0848b5c8 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -7675,24 +7675,21 @@ class AppLocalizationsEn extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Change compression for this chat'; - @override String get chatCompression_sheetSubtitle => 'Applies to messages you send in this chat. Saved on this phone.'; @override String get chatCompression_offDescription => - 'No compression. Sends your text exactly as typed. Every app can read it. Saves no bytes.'; + 'Sends your text as typed. Every app can read it.'; @override String get chatCompression_smazDescription => - 'Lossless compression for short text. The recipient\'s app must support SMAZ; other apps show unreadable \"s:…\" text. Only used when it makes a message smaller, so not every message is compressed.'; + 'Shrinks English text. Used only when the message gets shorter. Apps without SMAZ show \"s:…\" instead of your text.'; @override String get chatCompression_cyr2latDescription => - 'Not lossless. Swaps some Cyrillic letters for lookalike Latin ones (А→A, З→3) to save bytes. Readable in any app with no decoding, but the exact characters change, including your own sent messages here. Copying, search and technical text may be affected. Results depend on the chosen profile.'; + 'Swaps Cyrillic letters for similar Latin ones (А→A). Every app can read it, but the characters change. Not lossless.'; @override String get chatCompression_profile => 'Cyr2Lat profile'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 901e76e5..cbefc233 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -7782,9 +7782,6 @@ class AppLocalizationsEs extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Cambiar la compresión de este chat'; - @override String get chatCompression_sheetSubtitle => 'Se aplica a los mensajes que envíes en este chat. Se guarda en este teléfono.'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 2bfc5046..abf5ffa4 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -7805,10 +7805,6 @@ class AppLocalizationsFr extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => - 'Modifier la compression de cette discussion'; - @override String get chatCompression_sheetSubtitle => 'S\'applique aux messages que vous envoyez dans cette discussion. Enregistré sur ce téléphone.'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 97888e91..2c17d887 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -7771,10 +7771,6 @@ class AppLocalizationsHu extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => - 'Tömörítés módosítása ebben a csevegésben'; - @override String get chatCompression_sheetSubtitle => 'Az ebben a csevegésben küldött üzenetekre vonatkozik. Ezen a telefonon van mentve.'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index e757cc1d..12894b13 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -7793,10 +7793,6 @@ class AppLocalizationsIt extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => - 'Cambia la compressione per questa chat'; - @override String get chatCompression_sheetSubtitle => 'Si applica ai messaggi che invii in questa chat. Salvato su questo telefono.'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index eec2a32e..bd351747 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -7435,9 +7435,6 @@ class AppLocalizationsJa extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'このチャットの圧縮設定を変更'; - @override String get chatCompression_sheetSubtitle => 'このチャットで送信するメッセージに適用されます。このスマートフォンに保存されます。'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index ebf3c99f..59fd46dc 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -7444,9 +7444,6 @@ class AppLocalizationsKo extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => '이 채팅의 압축 설정 변경'; - @override String get chatCompression_sheetSubtitle => '이 채팅에서 보내는 메시지에 적용됩니다. 이 휴대폰에 저장됩니다.'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 84d423dc..d0733de4 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -7746,9 +7746,6 @@ class AppLocalizationsNl extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Compressie voor deze chat wijzigen'; - @override String get chatCompression_sheetSubtitle => 'Geldt voor berichten die je in deze chat verstuurt. Opgeslagen op deze telefoon.'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 0c24139c..1bea98bc 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -7835,9 +7835,6 @@ class AppLocalizationsPl extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Zmień kompresję w tej rozmowie'; - @override String get chatCompression_sheetSubtitle => 'Dotyczy wiadomości wysyłanych w tej rozmowie. Zapisane na tym telefonie.'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index e0e1b7b0..fe1e258d 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -7770,10 +7770,6 @@ class AppLocalizationsPt extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => - 'Alterar a compressão desta conversa'; - @override String get chatCompression_sheetSubtitle => 'Vale para as mensagens que você envia nesta conversa. Salvo neste celular.'; @@ -16014,10 +16010,6 @@ class AppLocalizationsPtPt extends AppLocalizationsPt { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => - 'Alterar a compressão desta conversa'; - @override String get chatCompression_sheetSubtitle => 'Aplica-se às mensagens que envia nesta conversa. Guardado neste telemóvel.'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 0fe4cebb..938d5e83 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -7814,9 +7814,6 @@ class AppLocalizationsRu extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Кир→Лат'; - @override - String get chatCompression_changeHint => 'Изменить сжатие для этого чата'; - @override String get chatCompression_sheetSubtitle => 'Действует для сообщений, которые вы отправляете в этом чате. Сохраняется на этом телефоне.'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 94b88ee8..bbaea7f7 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -7773,9 +7773,6 @@ class AppLocalizationsSk extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Zmeniť kompresiu pre tento chat'; - @override String get chatCompression_sheetSubtitle => 'Platí pre správy, ktoré v tomto chate odošlete. Uložené v tomto telefóne.'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 4a656e3e..42f50ce0 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -7773,9 +7773,6 @@ class AppLocalizationsSl extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => 'Spremeni stiskanje za ta klepet'; - @override String get chatCompression_sheetSubtitle => 'Velja za sporočila, ki jih pošljete v tem klepetu. Shranjeno v tem telefonu.'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index b5982c31..4a971868 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -7722,10 +7722,6 @@ class AppLocalizationsSv extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => - 'Ändra komprimering för den här chatten'; - @override String get chatCompression_sheetSubtitle => 'Gäller meddelanden du skickar i den här chatten. Sparas på den här telefonen.'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index 624c5c27..dc898bce 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -7828,9 +7828,6 @@ class AppLocalizationsUk extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Кир→Лат'; - @override - String get chatCompression_changeHint => 'Змінити стиснення для цього чату'; - @override String get chatCompression_sheetSubtitle => 'Діє для повідомлень, які ви надсилаєте в цьому чаті. Зберігається на цьому телефоні.'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index da104381..22921cd1 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -7281,9 +7281,6 @@ class AppLocalizationsZh extends AppLocalizations { @override String get chatCompression_cyr2lat => 'Cyr2Lat'; - @override - String get chatCompression_changeHint => '更改此聊天的压缩设置'; - @override String get chatCompression_sheetSubtitle => '适用于你在此聊天中发送的消息。保存在本机。'; diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 8b5d26de..d5e3b17d 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -54,7 +54,6 @@ import '../widgets/empty_state.dart'; import '../widgets/filter_rule_dialog.dart'; import '../widgets/filtered_message_ghost.dart'; import '../widgets/chat_composer.dart'; -import '../widgets/chat_compression_selector.dart'; import '../widgets/chat_send_pipeline.dart'; import '../widgets/chat_zoom_wrapper.dart'; import '../widgets/message_bubble_frame.dart'; @@ -76,6 +75,7 @@ import '../widgets/share_contact_sheet.dart'; import '../widgets/shared_contact_card.dart'; import 'app_settings_screen.dart'; import 'channel_chat_transcript_grouping.dart'; +import 'chat_compression_screen.dart'; import 'channels_screen.dart' show confirmDeleteChannel, showEditChannelSheet; import 'channel_message_path_screen.dart'; import 'map_screen.dart'; @@ -599,6 +599,8 @@ class _ChannelChatScreenState extends State _toggleChannelFiltering(); case 'notifications': showChannelNotificationModeSheet(context, muteKey); + case 'compression': + _openCompressionScreen(); case 'region': openRegionSelectDialog(widget.channel); case 'editChannel': @@ -656,6 +658,20 @@ class _ChannelChatScreenState extends State ), ), ), + PopupMenuItem( + value: 'compression', + child: _menuRow( + Icons.compress, + context.l10n.chatCompression_label( + chatCompressionModeLabel( + context, + context.read().channelCompressionMode( + widget.channel.index, + ), + ), + ), + ), + ), PopupMenuItem( value: 'region', child: _menuRow( @@ -880,7 +896,6 @@ class _ChannelChatScreenState extends State bottom: false, child: Column( children: [ - _buildCompressionSelector(), Expanded( child: ChatBackdrop( contentKey: _messageAreaKey, @@ -2804,26 +2819,35 @@ class _ChannelChatScreenState extends State /// Compression is stored on this phone under the channel's storage ID, so /// it can change while the radio is offline, but not before the slot has /// one. - Widget _buildCompressionSelector() { + void _openCompressionScreen() { final slot = widget.channel.index; - return Consumer2( - builder: (context, connector, settingsService, _) { - final hasStorageId = connector.channelIdForSlot(slot) != null; - return ChatCompressionSelector( - mode: connector.channelCompressionMode(slot), - enabled: hasStorageId, - disabledReason: hasStorageId - ? null - : context.l10n.chatCompression_noStorageId, - profiles: settingsService.settings.cyr2latProfiles, - profileId: connector.getChannelCyr2LatProfileId(slot), - defaultProfileId: settingsService.settings.selectedCyr2latProfileId, + final connector = context.read(); + final settingsService = context.read(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChatCompressionScreen( + listenable: Listenable.merge([connector, settingsService]), + read: () { + final hasStorageId = connector.channelIdForSlot(slot) != null; + return ChatCompressionState( + mode: connector.channelCompressionMode(slot), + enabled: hasStorageId, + disabledReason: hasStorageId + ? null + : context.l10n.chatCompression_noStorageId, + profiles: settingsService.settings.cyr2latProfiles, + profileId: connector.getChannelCyr2LatProfileId(slot), + defaultProfileId: + settingsService.settings.selectedCyr2latProfileId, + ); + }, onModeChanged: (mode) => connector.setChannelCompressionMode(slot, mode), onProfileChanged: (id) => connector.setChannelCyr2LatProfileId(slot, id), - ); - }, + ), + ), ); } diff --git a/lib/screens/chat_compression_screen.dart b/lib/screens/chat_compression_screen.dart new file mode 100644 index 00000000..d8d065d9 --- /dev/null +++ b/lib/screens/chat_compression_screen.dart @@ -0,0 +1,236 @@ +import 'package:flutter/material.dart'; + +import '../l10n/l10n.dart'; +import '../models/app_settings.dart'; +import '../models/chat_compression_mode.dart'; +import '../widgets/adaptive_app_bar_title.dart'; +import '../widgets/mesh_nav_tile.dart'; +import '../widgets/mesh_ui.dart'; + +export '../models/chat_compression_mode.dart'; + +String chatCompressionModeLabel(BuildContext context, ChatCompressionMode m) { + final l10n = context.l10n; + return switch (m) { + ChatCompressionMode.off => l10n.chatCompression_off, + ChatCompressionMode.smaz => l10n.chatCompression_smaz, + ChatCompressionMode.cyr2lat => l10n.chatCompression_cyr2lat, + }; +} + +/// What the page shows for one chat, read fresh each time [listenable] fires. +class ChatCompressionState { + final ChatCompressionMode mode; + + /// False locks the choices; [disabledReason] says why. + final bool enabled; + final String? disabledReason; + + final List profiles; + + /// The Cyr2Lat profile saved for this chat, if any. + final String? profileId; + + /// The app-wide profile, which sending uses when [profileId] is unset or + /// no longer exists. + final String? defaultProfileId; + + const ChatCompressionState({ + required this.mode, + required this.enabled, + this.disabledReason, + required this.profiles, + required this.profileId, + this.defaultProfileId, + }); + + /// The profile sending actually uses, matching the connector's fallback. + String? get effectiveProfileId { + bool known(String? id) => profiles.any((p) => p.id == id); + if (known(profileId)) return profileId; + if (known(defaultProfileId)) return defaultProfileId; + return profiles.isEmpty ? null : profiles.first.id; + } +} + +/// The page behind the chat menu's "Compression: ..." item. Shows the three +/// choices with a short note each, plus the Cyr2Lat profile picker. +/// +/// The caller supplies the saved state through [read] (re-read whenever +/// [listenable] notifies) and persists changes through the callbacks. A new +/// choice shows only once the saved state changes; a callback that throws +/// leaves the saved choice in place and shows an error. +class ChatCompressionScreen extends StatefulWidget { + final Listenable listenable; + final ChatCompressionState Function() read; + final Future Function(ChatCompressionMode mode) onModeChanged; + final Future Function(String profileId) onProfileChanged; + + const ChatCompressionScreen({ + super.key, + required this.listenable, + required this.read, + required this.onModeChanged, + required this.onProfileChanged, + }); + + @override + State createState() => _ChatCompressionScreenState(); +} + +class _ChatCompressionScreenState extends State { + bool _busy = false; + bool _failed = false; + + /// Counts failed saves, so the profile picker drops an unsaved choice. + int _failures = 0; + + /// Runs one save; a failure keeps the saved state and shows an error. + Future _save(Future Function() write) async { + if (_busy || !widget.read().enabled) return; + setState(() { + _busy = true; + _failed = false; + }); + var ok = false; + try { + await write(); + ok = true; + } catch (e) { + debugPrint('[ChatCompressionScreen] save failed: $e'); + } + if (!mounted) return; + setState(() { + _busy = false; + _failed = !ok; + if (!ok) _failures++; + }); + } + + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + return Scaffold( + appBar: AppBar( + title: AdaptiveAppBarTitle(l10n.chatCompression_title), + centerTitle: true, + actions: [ + if (_busy) + const Padding( + padding: EdgeInsets.all(14), + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(strokeWidth: 2), + ), + ), + ], + ), + body: SafeArea( + top: false, + child: ListenableBuilder( + listenable: widget.listenable, + builder: (context, _) => _buildBody(context, widget.read()), + ), + ), + ); + } + + Widget _buildBody(BuildContext context, ChatCompressionState view) { + final l10n = context.l10n; + final scheme = Theme.of(context).colorScheme; + final canChange = view.enabled && !_busy; + + Widget option(ChatCompressionMode mode, String description) { + return MeshSheetOption( + label: chatCompressionModeLabel(context, mode), + subtitle: description, + selected: view.mode == mode, + onTap: canChange ? () => _save(() => widget.onModeChanged(mode)) : null, + ); + } + + final profileValue = view.effectiveProfileId; + + return ListView( + padding: const EdgeInsets.only(bottom: 24), + children: [ + if (_failed) + MeshCard( + color: scheme.errorContainer, + borderColor: scheme.errorContainer, + child: Row( + children: [ + Icon(Icons.error_outline, color: scheme.onErrorContainer), + const SizedBox(width: 12), + Expanded( + child: Text( + l10n.chatCompression_saveFailed, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: scheme.onErrorContainer, + ), + ), + ), + ], + ), + ), + if (!view.enabled && view.disabledReason != null) + MeshInfoCard(view.disabledReason!), + SectionHeader( + l10n.chatCompression_title, + description: l10n.chatCompression_sheetSubtitle, + ), + MeshCard( + padding: EdgeInsets.zero, + child: Column( + children: [ + option( + ChatCompressionMode.off, + l10n.chatCompression_offDescription, + ), + const Divider(height: 1, indent: 16), + option( + ChatCompressionMode.smaz, + l10n.chatCompression_smazDescription, + ), + const Divider(height: 1, indent: 16), + option( + ChatCompressionMode.cyr2lat, + l10n.chatCompression_cyr2latDescription, + ), + ], + ), + ), + if (view.mode == ChatCompressionMode.cyr2lat && + view.profiles.isNotEmpty) ...[ + SectionHeader(l10n.chatCompression_profile), + MeshCard( + child: DropdownButtonFormField( + // The field keeps a picked value internally, so rebuild it + // with the saved value after a change or a failure. + key: ValueKey('$profileValue#$_failures'), + isExpanded: true, + initialValue: profileValue, + decoration: InputDecoration( + labelText: l10n.chatCompression_profile, + ), + items: [ + for (final profile in view.profiles) + DropdownMenuItem( + value: profile.id, + child: Text(profile.name, overflow: TextOverflow.ellipsis), + ), + ], + onChanged: canChange + ? (id) { + if (id == null || id == profileValue) return; + _save(() => widget.onProfileChanged(id)); + } + : null, + ), + ), + ], + ], + ); + } +} diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index e8d3eba2..4e249882 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -38,13 +38,13 @@ import '../services/chat_text_scale_service.dart'; import '../services/path_history_service.dart'; import '../services/translation_service.dart'; import '../widgets/chat_composer.dart'; -import '../widgets/chat_compression_selector.dart'; import '../widgets/chat_send_pipeline.dart'; import '../widgets/chat_zoom_wrapper.dart'; import '../widgets/message_bubble_frame.dart'; import '../widgets/reaction_chips.dart'; import '../widgets/chat_day_separator.dart'; import 'channel_message_path_screen.dart'; +import 'chat_compression_screen.dart'; import 'contacts_screen.dart' show confirmRemoveContact; import 'map_screen.dart'; import 'repeater_hub_screen.dart'; @@ -510,6 +510,8 @@ class _ChatScreenState extends State with WidgetsBindingObserver { ContactRoutingSheet.show(context, contact: contact); case 'info': _showContactInfo(context); + case 'compression': + _openCompressionScreen(); case 'settings': _showContactSettings(context); case 'showBookmarks': @@ -576,6 +578,20 @@ class _ChatScreenState extends State with WidgetsBindingObserver { label: context.l10n.room_management, ), ), + PopupMenuItem( + value: 'compression', + child: MeshMenuItemRow( + icon: Icons.compress, + label: context.l10n.chatCompression_label( + chatCompressionModeLabel( + context, + connector.contactCompressionMode( + widget.contact.publicKeyHex, + ), + ), + ), + ), + ), PopupMenuItem( value: 'settings', child: MeshMenuItemRow( @@ -648,7 +664,6 @@ class _ChatScreenState extends State with WidgetsBindingObserver { ); return Column( children: [ - _buildCompressionSelector(connector), Expanded( child: ChatBackdrop( contentKey: _messageAreaKey, @@ -677,22 +692,28 @@ class _ChatScreenState extends State with WidgetsBindingObserver { /// Compression is stored on this phone per contact, so it can change /// while the radio is offline. - Widget _buildCompressionSelector(MeshCoreConnector connector) { + void _openCompressionScreen() { final keyHex = widget.contact.publicKeyHex; - return Consumer( - builder: (context, settingsService, _) { - return ChatCompressionSelector( - mode: connector.contactCompressionMode(keyHex), - enabled: true, - profiles: settingsService.settings.cyr2latProfiles, - profileId: connector.getContactCyr2LatProfileId(keyHex), - defaultProfileId: settingsService.settings.selectedCyr2latProfileId, + final connector = context.read(); + final settingsService = context.read(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChatCompressionScreen( + listenable: Listenable.merge([connector, settingsService]), + read: () => ChatCompressionState( + mode: connector.contactCompressionMode(keyHex), + enabled: true, + profiles: settingsService.settings.cyr2latProfiles, + profileId: connector.getContactCyr2LatProfileId(keyHex), + defaultProfileId: settingsService.settings.selectedCyr2latProfileId, + ), onModeChanged: (mode) => connector.setContactCompressionMode(keyHex, mode), onProfileChanged: (id) => connector.setContactCyr2LatProfileId(keyHex, id), - ); - }, + ), + ), ); } diff --git a/lib/widgets/chat_compression_selector.dart b/lib/widgets/chat_compression_selector.dart deleted file mode 100644 index 864a7f1e..00000000 --- a/lib/widgets/chat_compression_selector.dart +++ /dev/null @@ -1,364 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; - -import '../l10n/l10n.dart'; -import '../models/app_settings.dart'; -import '../models/chat_compression_mode.dart'; -import '../theme/mesh_theme.dart'; -import 'mesh_nav_tile.dart'; -import 'mesh_ui.dart'; - -export '../models/chat_compression_mode.dart'; - -/// Always-visible "Compression: Off / SMAZ / Cyr2Lat" strip for the top of a -/// DM or channel chat. Tapping it opens one sheet with the three choices, -/// what each does, and the Cyr2Lat profile picker. -/// -/// The parent supplies the saved state and persists changes through the -/// callbacks; this widget only shows a new mode once the parent rebuilds it -/// with that mode. A callback that throws leaves the saved mode in place and -/// shows an error in the sheet. -class ChatCompressionSelector extends StatefulWidget { - final ChatCompressionMode mode; - - /// False disables the strip and the sheet; [disabledReason] says why. - final bool enabled; - final String? disabledReason; - - final List profiles; - - /// The Cyr2Lat profile saved for this chat, if any. - final String? profileId; - - /// The app-wide profile, which sending uses when [profileId] is unset or - /// no longer exists. - final String? defaultProfileId; - - final Future Function(ChatCompressionMode mode) onModeChanged; - final Future Function(String profileId) onProfileChanged; - - const ChatCompressionSelector({ - super.key, - required this.mode, - required this.enabled, - this.disabledReason, - required this.profiles, - required this.profileId, - this.defaultProfileId, - required this.onModeChanged, - required this.onProfileChanged, - }); - - /// The profile sending actually uses, matching the connector's fallback. - String? get effectiveProfileId { - bool known(String? id) => profiles.any((p) => p.id == id); - if (known(profileId)) return profileId; - if (known(defaultProfileId)) return defaultProfileId; - return profiles.isEmpty ? null : profiles.first.id; - } - - @override - State createState() => - _ChatCompressionSelectorState(); -} - -String chatCompressionModeLabel(BuildContext context, ChatCompressionMode m) { - final l10n = context.l10n; - return switch (m) { - ChatCompressionMode.off => l10n.chatCompression_off, - ChatCompressionMode.smaz => l10n.chatCompression_smaz, - ChatCompressionMode.cyr2lat => l10n.chatCompression_cyr2lat, - }; -} - -/// What the open sheet renders. The sheet is a separate route, so it listens -/// to this instead of rebuilding with the strip. -class _SelectorView { - final ChatCompressionMode mode; - final bool enabled; - final List profiles; - final String? profileId; - final bool busy; - final bool failed; - - /// Counts failed saves, so the profile picker drops an unsaved choice. - final int failures; - - const _SelectorView({ - required this.mode, - required this.enabled, - required this.profiles, - required this.profileId, - required this.busy, - required this.failed, - required this.failures, - }); -} - -class _ChatCompressionSelectorState extends State { - late final ValueNotifier<_SelectorView> _view = ValueNotifier(_snapshot()); - bool _busy = false; - bool _failed = false; - int _failures = 0; - - _SelectorView _snapshot() => _SelectorView( - mode: widget.mode, - enabled: widget.enabled, - profiles: widget.profiles, - profileId: widget.effectiveProfileId, - busy: _busy, - failed: _failed, - failures: _failures, - ); - - @override - void didUpdateWidget(covariant ChatCompressionSelector oldWidget) { - super.didUpdateWidget(oldWidget); - // The sheet route is not below this widget, so it can't be marked dirty - // during this build. - SchedulerBinding.instance.addPostFrameCallback((_) { - if (mounted) _view.value = _snapshot(); - }); - } - - @override - void dispose() { - _view.dispose(); - super.dispose(); - } - - void _setBusy(bool busy, {required bool failed}) { - setState(() { - _busy = busy; - _failed = failed; - if (failed) _failures++; - }); - _view.value = _snapshot(); - } - - /// Runs one save; returns whether it succeeded. - Future _save(Future Function() write) async { - if (_busy || !widget.enabled) return false; - _setBusy(true, failed: false); - var ok = false; - try { - await write(); - ok = true; - } catch (e) { - debugPrint('[ChatCompressionSelector] save failed: $e'); - } - if (mounted) _setBusy(false, failed: !ok); - return ok; - } - - Future _openSheet() async { - if (_failed) _setBusy(false, failed: false); - await showMeshSheet( - context, - builder: (sheetContext) => ValueListenableBuilder<_SelectorView>( - valueListenable: _view, - builder: (sheetContext, view, _) => _buildSheet(sheetContext, view), - ), - ); - } - - Widget _buildSheet(BuildContext context, _SelectorView view) { - final l10n = context.l10n; - final scheme = Theme.of(context).colorScheme; - final canChange = view.enabled && !view.busy; - - MeshSheetOption option(ChatCompressionMode mode, String description) { - return MeshSheetOption( - label: chatCompressionModeLabel(context, mode), - subtitle: description, - selected: view.mode == mode, - onTap: canChange - ? () async { - final ok = await _save(() => widget.onModeChanged(mode)); - // Cyr2Lat stays open so its profile can be picked. - if (ok && mode != ChatCompressionMode.cyr2lat) { - if (context.mounted) Navigator.of(context).maybePop(); - } - } - : null, - ); - } - - final profileValue = view.profileId; - - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - BottomSheetHeader( - title: l10n.chatCompression_title, - subtitle: l10n.chatCompression_sheetSubtitle, - trailing: view.busy - ? const Padding( - padding: EdgeInsets.all(8), - child: SizedBox( - width: 18, - height: 18, - child: CircularProgressIndicator(strokeWidth: 2), - ), - ) - : null, - ), - Flexible( - child: SingleChildScrollView( - padding: const EdgeInsets.only(bottom: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - if (view.failed) - Container( - margin: const EdgeInsets.fromLTRB(16, 8, 16, 8), - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: scheme.errorContainer, - borderRadius: BorderRadius.circular(MeshRadii.sm), - ), - child: Row( - children: [ - Icon( - Icons.error_outline, - color: scheme.onErrorContainer, - ), - const SizedBox(width: 12), - Expanded( - child: Text( - l10n.chatCompression_saveFailed, - style: Theme.of(context).textTheme.bodyMedium - ?.copyWith(color: scheme.onErrorContainer), - ), - ), - ], - ), - ), - if (!view.enabled && widget.disabledReason != null) - Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), - child: Text( - widget.disabledReason!, - style: Theme.of(context).textTheme.bodyMedium, - ), - ), - option( - ChatCompressionMode.off, - l10n.chatCompression_offDescription, - ), - option( - ChatCompressionMode.smaz, - l10n.chatCompression_smazDescription, - ), - option( - ChatCompressionMode.cyr2lat, - l10n.chatCompression_cyr2latDescription, - ), - if (view.mode == ChatCompressionMode.cyr2lat && - view.profiles.isNotEmpty) - Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), - child: DropdownButtonFormField( - // The field keeps a picked value internally, so rebuild - // it with the saved value after a change or a failure. - key: ValueKey('$profileValue#${view.failures}'), - isExpanded: true, - initialValue: profileValue, - decoration: InputDecoration( - labelText: l10n.chatCompression_profile, - border: const OutlineInputBorder(), - ), - items: [ - for (final profile in view.profiles) - DropdownMenuItem( - value: profile.id, - child: Text( - profile.name, - overflow: TextOverflow.ellipsis, - ), - ), - ], - onChanged: canChange - ? (id) { - if (id == null || id == profileValue) return; - _save(() => widget.onProfileChanged(id)); - } - : null, - ), - ), - ], - ), - ), - ), - ], - ); - } - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final scheme = theme.colorScheme; - final l10n = context.l10n; - final label = l10n.chatCompression_label( - chatCompressionModeLabel(context, widget.mode), - ); - final reason = widget.enabled ? null : widget.disabledReason; - - // One short row: the chat already leaves little room for messages at - // large text sizes, so a disabled strip explains itself in the sheet. - return Material( - color: scheme.surfaceContainerLow, - child: DecoratedBox( - decoration: BoxDecoration( - border: Border(bottom: BorderSide(color: scheme.outlineVariant)), - ), - child: MergeSemantics( - child: Semantics( - button: true, - enabled: !_busy, - label: reason == null ? label : '$label. $reason', - hint: l10n.chatCompression_changeHint, - child: InkWell( - onTap: _busy ? null : _openSheet, - child: ExcludeSemantics( - child: ConstrainedBox( - constraints: const BoxConstraints(minHeight: 48), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Row( - children: [ - Flexible( - child: Text( - label, - style: theme.textTheme.bodyMedium?.copyWith( - fontWeight: FontWeight.w600, - color: scheme.onSurface, - ), - ), - ), - const SizedBox(width: 4), - if (_busy) - const SizedBox( - width: 18, - height: 18, - child: CircularProgressIndicator(strokeWidth: 2), - ) - else - Icon( - widget.enabled - ? Icons.arrow_drop_down - : Icons.lock_outline, - color: scheme.onSurfaceVariant, - ), - ], - ), - ), - ), - ), - ), - ), - ), - ), - ); - } -} diff --git a/test/helpers/smaz_test.dart b/test/helpers/smaz_test.dart new file mode 100644 index 00000000..2f2a3bb6 --- /dev/null +++ b/test/helpers/smaz_test.dart @@ -0,0 +1,172 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/helpers/smaz.dart'; + +int _utf8Len(String s) => utf8.encode(s).length; + +Uint8List _raw(String s) => + Smaz.compressBytes(Uint8List.fromList(utf8.encode(s))); + +/// Sent size, raw SMAZ size and base64 wire size for [text]. +({int plain, int raw, int wire, int sent}) _measure(String text) { + final raw = _raw(text); + return ( + plain: _utf8Len(text), + raw: raw.length, + wire: _utf8Len('s:${base64Encode(raw)}'), + sent: _utf8Len(Smaz.encodeIfSmaller(text)), + ); +} + +void main() { + group('compression results', () { + test('lowercase English compresses well', () { + const text = 'hello there, how are you doing today?'; + final m = _measure(text); + expect((m.plain, m.raw, m.wire, m.sent), (37, 20, 30, 30)); + expect(Smaz.encodeIfSmaller(text), startsWith('s:')); + }); + + test('sentence case compresses, a little less', () { + const text = 'Hello there, how are you doing today?'; + final m = _measure(text); + expect((m.plain, m.raw, m.wire, m.sent), (37, 22, 34, 34)); + expect(Smaz.encodeIfSmaller(text), startsWith('s:')); + }); + + test('mixed case with many capitals barely compresses', () { + const mixed = 'Meeting at Headquarters on Monday afternoon'; + const lower = 'meeting at headquarters on monday afternoon'; + expect(_measure(mixed).wire, 42); + expect(_measure(mixed).plain, 43); + expect(Smaz.encodeIfSmaller(mixed), startsWith('s:')); + // The same words in lowercase save far more. + expect(_measure(lower).wire, 34); + expect(_measure(lower).raw, 24); + // Each capital that is not in the codebook costs 2 bytes. + expect(_measure(mixed).raw - _measure(lower).raw, 4); + }); + + test('all caps is longer than the plain text, so it is sent plain', () { + const text = 'HELLO THERE, HOW ARE YOU DOING TODAY?'; + final m = _measure(text); + expect((m.plain, m.raw, m.wire, m.sent), (37, 50, 70, 37)); + expect(Smaz.encodeIfSmaller(text), text); + }); + + test('a reply prefix costs the same in either case', () { + expect( + _raw('@[Alice] hello there, how are you?').length, + _raw('@[alice] hello there, how are you?').length, + ); + // 34 bytes plain, 34 bytes encoded: not strictly smaller, sent plain. + const text = '@[Alice] hello there, how are you?'; + expect(_measure(text).wire, _measure(text).plain); + expect(Smaz.encodeIfSmaller(text), text); + }); + }); + + group('non-ASCII text', () { + test('Cyrillic round-trips as raw bytes but is sent plain', () { + const text = 'Привет, как дела сегодня?'; + final m = _measure(text); + expect((m.plain, m.raw, m.wire, m.sent), (45, 52, 74, 45)); + expect(Smaz.encodeIfSmaller(text), text); + // The byte-level codec is still lossless. + expect(utf8.decode(Smaz.decompressBytes(_raw(text))), text); + }); + + test('emoji survives a compressed round trip', () { + const text = + 'see you soon 😀 the best of luck with the new house and the garden'; + final encoded = Smaz.encodeIfSmaller(text); + expect(encoded, startsWith('s:')); + expect(_utf8Len(encoded), lessThan(_utf8Len(text))); + expect(Smaz.tryDecodePrefixed(encoded), text); + }); + + test('a short emoji message is not smaller, so it is sent plain', () { + const text = 'see you soon 😀 the best'; + final m = _measure(text); + expect((m.plain, m.raw, m.wire, m.sent), (26, 17, 26, 26)); + expect(Smaz.encodeIfSmaller(text), text); + }); + }); + + group('encodeIfSmaller falls back to plain text', () { + test('short strings', () { + for (final text in ['hi', 'ok', 'Hello', 'the']) { + expect(Smaz.encodeIfSmaller(text), text, reason: text); + } + }); + + test('empty string', () { + expect(Smaz.encodeIfSmaller(''), ''); + }); + + test('sent form is never longer than the plain text', () { + for (final text in [ + 'a', + 'Hello', + 'HELLO THERE, HOW ARE YOU DOING TODAY?', + 'the quick brown fox jumps over the lazy dog', + 'Привет, как дела?', + '12345 67890', + ]) { + expect( + _utf8Len(Smaz.encodeIfSmaller(text)), + lessThanOrEqualTo(_utf8Len(text)), + reason: text, + ); + } + }); + }); + + group('round trip', () { + test('tryDecodePrefixed restores what encodeIfSmaller produced', () { + for (final text in [ + 'hello there, how are you doing today?', + 'Hello there, how are you doing today?', + 'Meeting at Headquarters on Monday afternoon', + 'the quick brown fox jumps over the lazy dog', + '@[Alice] hello there, how are you doing today my friend?', + ]) { + final encoded = Smaz.encodeIfSmaller(text); + expect(encoded, startsWith('s:'), reason: text); + expect(Smaz.tryDecodePrefixed(encoded), text, reason: text); + } + }); + + test('the decoder ignores leading whitespace', () { + const text = 'hello there, how are you doing today?'; + expect(Smaz.tryDecodePrefixed(' ${Smaz.encodeIfSmaller(text)}'), text); + }); + + test('plain text is not a compressed payload', () { + expect(Smaz.tryDecodePrefixed('hello there'), isNull); + expect(Smaz.tryDecodePrefixed('s:'), isNull); + }); + }); + + group('"s:" guard', () { + test('text that already starts with "s:" is never re-encoded', () { + const text = 's:hello there, how are you doing today?'; + expect(Smaz.encodeIfSmaller(text), text); + }); + + test('plain "s:" text is not mistaken for a compressed payload', () { + expect(Smaz.tryDecodePrefixed('s:test'), isNull); + expect(Smaz.tryDecodePrefixed('s:hello'), isNull); + // Valid base64 that is not what the encoder would have produced. + expect(Smaz.tryDecodePrefixed('s:AAAA'), isNull); + }); + + test('malformed payloads return null instead of throwing', () { + expect(Smaz.tryDecodePrefixed('s:!!!!'), isNull); + // Truncated verbatim escape (0xFE with no byte after it). + expect(Smaz.tryDecodePrefixed('s:${base64Encode([254])}'), isNull); + }); + }); +} diff --git a/test/screens/chat_compression_screen_test.dart b/test/screens/chat_compression_screen_test.dart new file mode 100644 index 00000000..dc2ca9ec --- /dev/null +++ b/test/screens/chat_compression_screen_test.dart @@ -0,0 +1,265 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/l10n/app_localizations.dart'; +import 'package:meshcore_open/models/app_settings.dart'; +import 'package:meshcore_open/theme/mesh_theme.dart'; +import 'package:meshcore_open/screens/chat_compression_screen.dart'; + +final _l10n = lookupAppLocalizations(const Locale('en')); + +final _profiles = [ + Cyr2LatProfile(id: 'ru', name: 'Russian', charMap: const {'А': 'A'}), + Cyr2LatProfile(id: 'sr', name: 'Serbian', charMap: const {'З': '3'}), +]; + +/// Stands in for a chat screen: keeps the "saved" state and applies a change +/// only when the test completes the pending write. +class _Host extends ChangeNotifier { + ChatCompressionMode mode; + String? profileId; + final bool enabled; + final List modeCalls = []; + final List profileCalls = []; + final List> pending = []; + + _Host({ + this.mode = ChatCompressionMode.off, + this.enabled = true, + this.profileId, + }); + + ChatCompressionState read() => ChatCompressionState( + mode: mode, + enabled: enabled, + disabledReason: enabled ? null : _l10n.chatCompression_noStorageId, + profiles: _profiles, + profileId: profileId, + defaultProfileId: 'ru', + ); + + Future _write(void Function() apply) async { + final completer = Completer(); + pending.add(completer); + await completer.future; + apply(); + notifyListeners(); + } + + Future setMode(ChatCompressionMode m) { + modeCalls.add(m); + return _write(() => mode = m); + } + + Future setProfile(String id) { + profileCalls.add(id); + return _write(() => profileId = id); + } +} + +void main() { + late _Host host; + + Future pumpPage( + WidgetTester tester, { + ChatCompressionMode mode = ChatCompressionMode.off, + bool enabled = true, + String? profileId, + Size size = const Size(400, 800), + double textScale = 1.0, + }) async { + host = _Host(mode: mode, enabled: enabled, profileId: profileId); + addTearDown(host.dispose); + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); + await tester.pumpWidget( + MaterialApp( + theme: MeshTheme.light(), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + builder: (context, child) => MediaQuery( + data: MediaQuery.of( + context, + ).copyWith(textScaler: TextScaler.linear(textScale)), + child: child!, + ), + home: ChatCompressionScreen( + listenable: host, + read: host.read, + onModeChanged: host.setMode, + onProfileChanged: host.setProfile, + ), + ), + ); + } + + Finder optionRow(String label) => + find.ancestor(of: find.text(label), matching: find.byType(ListTile)); + + bool isSelected(String label) { + return find + .descendant( + of: optionRow(label), + matching: find.byIcon(Icons.radio_button_checked), + ) + .evaluate() + .isNotEmpty; + } + + testWidgets( + 'lists the three modes with short notes and marks the saved one', + (tester) async { + await pumpPage(tester, mode: ChatCompressionMode.smaz); + + expect(find.text(_l10n.chatCompression_title), findsWidgets); + expect(find.text(_l10n.chatCompression_off), findsOneWidget); + expect(find.text(_l10n.chatCompression_smaz), findsOneWidget); + expect(find.text(_l10n.chatCompression_cyr2lat), findsOneWidget); + expect(find.text(_l10n.chatCompression_offDescription), findsOneWidget); + expect(find.text(_l10n.chatCompression_smazDescription), findsOneWidget); + expect( + find.text(_l10n.chatCompression_cyr2latDescription), + findsOneWidget, + ); + expect(isSelected(_l10n.chatCompression_smaz), isTrue); + expect(isSelected(_l10n.chatCompression_off), isFalse); + expect(find.text(_l10n.chatCompression_profile), findsNothing); + for (final mode in [ + _l10n.chatCompression_off, + _l10n.chatCompression_smaz, + _l10n.chatCompression_cyr2lat, + ]) { + expect( + tester.getSize(optionRow(mode)).height, + greaterThanOrEqualTo(48), + reason: mode, + ); + } + }, + ); + + testWidgets('a choice shows only after it is saved', (tester) async { + await pumpPage(tester); + + await tester.tap(find.text(_l10n.chatCompression_smaz)); + await tester.pump(); + expect(host.modeCalls, [ChatCompressionMode.smaz]); + // Still saving: old mode shown, options locked against rapid taps. + expect(isSelected(_l10n.chatCompression_off), isTrue); + expect( + tester.widget(optionRow(_l10n.chatCompression_cyr2lat)).enabled, + isFalse, + ); + await tester.tap(find.text(_l10n.chatCompression_cyr2lat)); + await tester.pump(); + expect(host.modeCalls, [ChatCompressionMode.smaz]); + + host.pending.single.complete(); + await tester.pumpAndSettle(); + expect(isSelected(_l10n.chatCompression_smaz), isTrue); + expect(isSelected(_l10n.chatCompression_off), isFalse); + expect( + tester.widget(optionRow(_l10n.chatCompression_cyr2lat)).enabled, + isTrue, + ); + }); + + testWidgets('Cyr2Lat reveals the profile picker', (tester) async { + await pumpPage(tester); + + await tester.tap(find.text(_l10n.chatCompression_cyr2lat)); + await tester.pump(); + host.pending.removeAt(0).complete(); + await tester.pumpAndSettle(); + + expect(isSelected(_l10n.chatCompression_cyr2lat), isTrue); + expect(find.text(_l10n.chatCompression_profile), findsWidgets); + // No profile saved for the chat: the app-wide one is what sending uses. + expect(find.text('Russian'), findsOneWidget); + + await tester.tap(find.text('Russian')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Serbian').last); + await tester.pump(); + expect(host.profileCalls, ['sr']); + host.pending.removeAt(0).complete(); + await tester.pumpAndSettle(); + expect(find.text('Serbian'), findsOneWidget); + }); + + testWidgets('a failed save keeps the saved mode and says so', (tester) async { + await pumpPage(tester, mode: ChatCompressionMode.smaz); + + await tester.tap(find.text(_l10n.chatCompression_cyr2lat)); + await tester.pump(); + host.pending.single.completeError(StateError('disk full')); + await tester.pumpAndSettle(); + + expect(find.text(_l10n.chatCompression_saveFailed), findsOneWidget); + expect(isSelected(_l10n.chatCompression_smaz), isTrue); + expect(isSelected(_l10n.chatCompression_cyr2lat), isFalse); + expect( + tester.widget(optionRow(_l10n.chatCompression_off)).enabled, + isTrue, + ); + }); + + testWidgets('a failed profile save shows the saved profile again', ( + tester, + ) async { + await pumpPage(tester, mode: ChatCompressionMode.cyr2lat, profileId: 'ru'); + + await tester.tap(find.text('Russian')); + await tester.pumpAndSettle(); + await tester.tap(find.text('Serbian').last); + await tester.pump(); + expect(host.profileCalls, ['sr']); + host.pending.single.completeError(StateError('disk full')); + await tester.pumpAndSettle(); + + expect(find.text(_l10n.chatCompression_saveFailed), findsOneWidget); + await tester.scrollUntilVisible(find.text('Russian'), 100); + expect(find.text('Russian'), findsOneWidget); + expect(find.text('Serbian'), findsNothing); + }); + + testWidgets('disabled shows the saved mode, says why and allows no change', ( + tester, + ) async { + await pumpPage(tester, mode: ChatCompressionMode.smaz, enabled: false); + + expect(find.text(_l10n.chatCompression_noStorageId), findsOneWidget); + expect(isSelected(_l10n.chatCompression_smaz), isTrue); + for (final mode in [ + _l10n.chatCompression_off, + _l10n.chatCompression_smaz, + _l10n.chatCompression_cyr2lat, + ]) { + expect(tester.widget(optionRow(mode)).enabled, isFalse); + } + await tester.tap(find.text(_l10n.chatCompression_off), warnIfMissed: false); + await tester.pumpAndSettle(); + expect(host.modeCalls, isEmpty); + }); + + for (final scale in [1.3, 2.0]) { + testWidgets('fits a 320dp phone at ${scale}x text', (tester) async { + await pumpPage( + tester, + mode: ChatCompressionMode.cyr2lat, + size: const Size(320, 568), + textScale: scale, + ); + expect(tester.takeException(), isNull); + // The page scrolls to its last option and the profile picker. + await tester.scrollUntilVisible( + find.byType(DropdownButtonFormField), + 200, + scrollable: find.byType(Scrollable).first, + ); + expect(tester.takeException(), isNull); + }); + } +} diff --git a/test/screens/offline_mode_test.dart b/test/screens/offline_mode_test.dart index 11469c44..a705f82e 100644 --- a/test/screens/offline_mode_test.dart +++ b/test/screens/offline_mode_test.dart @@ -42,9 +42,8 @@ import 'package:meshcore_open/storage/last_radio_store.dart'; import 'package:meshcore_open/storage/message_store.dart'; import 'package:meshcore_open/storage/prefs_manager.dart'; import 'package:meshcore_open/theme/mesh_theme.dart'; -import 'package:meshcore_open/widgets/chat_background.dart'; import 'package:meshcore_open/widgets/chat_composer.dart'; -import 'package:meshcore_open/widgets/chat_compression_selector.dart'; +import 'package:meshcore_open/screens/chat_compression_screen.dart'; import 'package:meshcore_open/widgets/connect_sheet.dart'; final _radioKey = Uint8List.fromList(List.generate(32, (i) => 0xA0 + i)); @@ -349,10 +348,18 @@ void main() { await tester.pump(const Duration(minutes: 1)); }); - group('compression selector', () { - Future choose(WidgetTester tester, String mode) async { - await tester.tap(find.byType(ChatCompressionSelector)); + group('compression menu item', () { + Future openMenu(WidgetTester tester) async { + await tester.tap(find.byIcon(Icons.more_vert)); await _settle(tester); + } + + /// Opens the page from the overflow menu, picks [mode], and returns. + Future choose(WidgetTester tester, String mode) async { + await openMenu(tester); + await tester.tap(find.textContaining('${_l10n.chatCompression_title}:')); + await _settle(tester); + expect(find.byType(ChatCompressionScreen), findsOneWidget); await tester.tap(find.text(mode)); await _settle(tester); // Connector notifications are debounced on a real timer. @@ -360,9 +367,11 @@ void main() { () => Future.delayed(const Duration(milliseconds: 200)), ); await _settle(tester); + await tester.pageBack(); + await _settle(tester); } - testWidgets('DM chat shows it at the top and saves offline', ( + testWidgets('DM chat shows it in the menu and saves offline', ( tester, ) async { final connector = await _offlineConnector(tester); @@ -373,32 +382,27 @@ void main() { ); await _settle(tester); - expect(find.byType(ChatCompressionSelector), findsOneWidget); + // No strip above the transcript any more. + expect(find.byType(ChatCompressionScreen), findsNothing); + expect(find.text(_l10n.chatCompression_label('Off')), findsNothing); + await openMenu(tester); expect(find.text(_l10n.chatCompression_label('Off')), findsOneWidget); - // Above the transcript, outside its scroll view. - expect( - find.ancestor( - of: find.byType(ChatCompressionSelector), - matching: find.byType(Scrollable), - ), - findsNothing, - ); - expect( - tester.getBottomLeft(find.byType(ChatCompressionSelector)).dy, - lessThanOrEqualTo(tester.getTopLeft(find.byType(ChatBackdrop)).dy), - ); + expect(find.byIcon(Icons.compress), findsOneWidget); + await tester.tapAt(const Offset(1, 1)); + await _settle(tester); await choose(tester, _l10n.chatCompression_smaz); + await openMenu(tester); expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); + await tester.tapAt(const Offset(1, 1)); + await _settle(tester); expect( await tester.runAsync(() => store.loadSmazEnabled(alice.publicKeyHex)), isTrue, ); await choose(tester, _l10n.chatCompression_cyr2lat); - // Cyr2Lat keeps the sheet open for its profile picker. - await tester.tap(find.byTooltip('Close')); - await _settle(tester); + await openMenu(tester); expect(find.text(_l10n.chatCompression_label('Cyr2Lat')), findsOneWidget); expect( connector.contactCompressionMode(alice.publicKeyHex), @@ -416,8 +420,6 @@ void main() { ); // The settings dialog no longer carries the compression switches. - await tester.tap(find.byIcon(Icons.more_vert)); - await _settle(tester); await tester.tap(find.text(_l10n.contact_settings).last); await _settle(tester); expect(find.byType(AlertDialog), findsOneWidget); @@ -431,7 +433,7 @@ void main() { await tester.pumpWidget(const SizedBox()); }); - testWidgets('channel chat uses the same selector and saves offline', ( + testWidgets('channel chat uses the same page and saves offline', ( tester, ) async { final connector = await _offlineConnector(tester); @@ -442,10 +444,13 @@ void main() { ); await _settle(tester); - expect(find.byType(ChatCompressionSelector), findsOneWidget); + await openMenu(tester); expect(find.text(_l10n.chatCompression_label('Off')), findsOneWidget); + await tester.tapAt(const Offset(1, 1)); + await _settle(tester); await choose(tester, _l10n.chatCompression_smaz); + await openMenu(tester); expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); expect( await tester.runAsync(() => store.loadSmazEnabled(channel.storageId!)), diff --git a/test/widgets/chat_compression_selector_test.dart b/test/widgets/chat_compression_selector_test.dart deleted file mode 100644 index ec32ff8d..00000000 --- a/test/widgets/chat_compression_selector_test.dart +++ /dev/null @@ -1,334 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:meshcore_open/l10n/app_localizations.dart'; -import 'package:meshcore_open/models/app_settings.dart'; -import 'package:meshcore_open/theme/mesh_theme.dart'; -import 'package:meshcore_open/widgets/chat_compression_selector.dart'; - -final _l10n = lookupAppLocalizations(const Locale('en')); - -final _profiles = [ - Cyr2LatProfile(id: 'ru', name: 'Russian', charMap: const {'А': 'A'}), - Cyr2LatProfile(id: 'sr', name: 'Serbian', charMap: const {'З': '3'}), -]; - -/// Stands in for a chat screen: keeps the "saved" state and applies a change -/// only when the test completes the pending write. -class _Host extends StatefulWidget { - final ChatCompressionMode initialMode; - final bool enabled; - final String? initialProfileId; - final List modeCalls; - final List profileCalls; - final List> pending; - - const _Host({ - this.initialMode = ChatCompressionMode.off, - this.enabled = true, - this.initialProfileId, - required this.modeCalls, - required this.profileCalls, - required this.pending, - }); - - @override - State<_Host> createState() => _HostState(); -} - -class _HostState extends State<_Host> { - late ChatCompressionMode _mode = widget.initialMode; - late String? _profileId = widget.initialProfileId; - - Future _write(void Function() apply) async { - final completer = Completer(); - widget.pending.add(completer); - await completer.future; - if (mounted) setState(apply); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text('Chat')), - body: Column( - children: [ - ChatCompressionSelector( - mode: _mode, - enabled: widget.enabled, - disabledReason: widget.enabled - ? null - : _l10n.chatCompression_noStorageId, - profiles: _profiles, - profileId: _profileId, - defaultProfileId: 'ru', - onModeChanged: (mode) { - widget.modeCalls.add(mode); - return _write(() => _mode = mode); - }, - onProfileChanged: (id) { - widget.profileCalls.add(id); - return _write(() => _profileId = id); - }, - ), - const Expanded(child: Placeholder()), - ], - ), - ); - } -} - -void main() { - late List modeCalls; - late List profileCalls; - late List> pending; - - setUp(() { - modeCalls = []; - profileCalls = []; - pending = []; - }); - - Future pumpHost( - WidgetTester tester, { - ChatCompressionMode mode = ChatCompressionMode.off, - bool enabled = true, - String? profileId, - Size size = const Size(400, 800), - double textScale = 1.0, - }) async { - tester.view.physicalSize = size; - tester.view.devicePixelRatio = 1.0; - addTearDown(tester.view.reset); - await tester.pumpWidget( - MaterialApp( - theme: MeshTheme.light(), - localizationsDelegates: AppLocalizations.localizationsDelegates, - supportedLocales: AppLocalizations.supportedLocales, - builder: (context, child) => MediaQuery( - data: MediaQuery.of( - context, - ).copyWith(textScaler: TextScaler.linear(textScale)), - child: child!, - ), - home: _Host( - initialMode: mode, - enabled: enabled, - initialProfileId: profileId, - modeCalls: modeCalls, - profileCalls: profileCalls, - pending: pending, - ), - ), - ); - } - - Future openSheet(WidgetTester tester) async { - await tester.tap(find.byType(ChatCompressionSelector)); - await tester.pumpAndSettle(); - } - - Finder optionRow(String label) => - find.ancestor(of: find.text(label), matching: find.byType(ListTile)); - - bool isSelected(WidgetTester tester, String label) { - final row = optionRow(label); - return find - .descendant(of: row, matching: find.byIcon(Icons.radio_button_checked)) - .evaluate() - .isNotEmpty; - } - - testWidgets('shows the saved mode and announces it', (tester) async { - final semantics = tester.ensureSemantics(); - await pumpHost(tester, mode: ChatCompressionMode.smaz); - - expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); - expect( - tester.getSemantics( - find.bySemanticsLabel(_l10n.chatCompression_label('SMAZ')), - ), - isSemantics( - label: _l10n.chatCompression_label('SMAZ'), - hint: _l10n.chatCompression_changeHint, - isButton: true, - isEnabled: true, - hasTapAction: true, - ), - ); - expect( - tester.getSize(find.byType(ChatCompressionSelector)).height, - greaterThanOrEqualTo(48), - ); - semantics.dispose(); - }); - - testWidgets('one sheet lists the three modes with their explanations', ( - tester, - ) async { - await pumpHost(tester); - await openSheet(tester); - - expect(find.text(_l10n.chatCompression_title), findsOneWidget); - expect(find.text(_l10n.chatCompression_off), findsOneWidget); - expect(find.text(_l10n.chatCompression_smaz), findsOneWidget); - expect(find.text(_l10n.chatCompression_cyr2lat), findsOneWidget); - expect(find.text(_l10n.chatCompression_offDescription), findsOneWidget); - expect(find.text(_l10n.chatCompression_smazDescription), findsOneWidget); - expect(find.text(_l10n.chatCompression_cyr2latDescription), findsOneWidget); - expect(isSelected(tester, _l10n.chatCompression_off), isTrue); - expect(isSelected(tester, _l10n.chatCompression_smaz), isFalse); - // No profile picker unless Cyr2Lat is chosen. - expect(find.text(_l10n.chatCompression_profile), findsNothing); - expect(find.byType(Dialog), findsNothing); - }); - - testWidgets('a choice shows only after it is saved, then the sheet closes', ( - tester, - ) async { - await pumpHost(tester); - await openSheet(tester); - - await tester.tap(find.text(_l10n.chatCompression_smaz)); - await tester.pump(); - expect(modeCalls, [ChatCompressionMode.smaz]); - // Still saving: old mode shown, options locked against rapid taps. - expect(isSelected(tester, _l10n.chatCompression_off), isTrue); - expect( - tester.widget(optionRow(_l10n.chatCompression_cyr2lat)).enabled, - isFalse, - ); - await tester.tap(find.text(_l10n.chatCompression_cyr2lat)); - await tester.pump(); - expect(modeCalls, [ChatCompressionMode.smaz]); - - pending.single.complete(); - await tester.pumpAndSettle(); - expect(find.text(_l10n.chatCompression_title), findsNothing); - expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); - }); - - testWidgets('Cyr2Lat keeps the sheet open with its profile picker', ( - tester, - ) async { - await pumpHost(tester); - await openSheet(tester); - - await tester.tap(find.text(_l10n.chatCompression_cyr2lat)); - await tester.pump(); - pending.removeAt(0).complete(); - await tester.pumpAndSettle(); - - expect(find.text(_l10n.chatCompression_title), findsOneWidget); - expect(isSelected(tester, _l10n.chatCompression_cyr2lat), isTrue); - expect(find.text(_l10n.chatCompression_profile), findsOneWidget); - // No profile saved for the chat: the app-wide one is what sending uses. - expect(find.text('Russian'), findsOneWidget); - - await tester.ensureVisible(find.text('Russian')); - await tester.pumpAndSettle(); - await tester.tap(find.text('Russian')); - await tester.pumpAndSettle(); - await tester.tap(find.text('Serbian').last); - await tester.pump(); - expect(profileCalls, ['sr']); - pending.removeAt(0).complete(); - await tester.pumpAndSettle(); - expect(find.text('Serbian'), findsOneWidget); - expect(find.text(_l10n.chatCompression_label('Cyr2Lat')), findsOneWidget); - }); - - testWidgets('a failed save keeps the saved mode and says so', (tester) async { - await pumpHost(tester, mode: ChatCompressionMode.smaz); - await openSheet(tester); - - await tester.tap(find.text(_l10n.chatCompression_cyr2lat)); - await tester.pump(); - pending.single.completeError(StateError('disk full')); - await tester.pumpAndSettle(); - - expect(find.text(_l10n.chatCompression_saveFailed), findsOneWidget); - expect(isSelected(tester, _l10n.chatCompression_smaz), isTrue); - expect(isSelected(tester, _l10n.chatCompression_cyr2lat), isFalse); - expect( - tester.widget(optionRow(_l10n.chatCompression_off)).enabled, - isTrue, - ); - await tester.tap(find.byTooltip('Close')); - await tester.pumpAndSettle(); - expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); - }); - - testWidgets('a failed profile save shows the saved profile again', ( - tester, - ) async { - await pumpHost(tester, mode: ChatCompressionMode.cyr2lat, profileId: 'ru'); - await openSheet(tester); - - await tester.ensureVisible(find.text('Russian')); - await tester.pumpAndSettle(); - await tester.tap(find.text('Russian')); - await tester.pumpAndSettle(); - await tester.tap(find.text('Serbian').last); - await tester.pump(); - expect(profileCalls, ['sr']); - pending.single.completeError(StateError('disk full')); - await tester.pumpAndSettle(); - - expect(find.text(_l10n.chatCompression_saveFailed), findsOneWidget); - expect(find.text('Russian'), findsOneWidget); - expect(find.text('Serbian'), findsNothing); - }); - - testWidgets('disabled shows the saved mode, and the sheet says why and ' - 'allows no change', (tester) async { - final semantics = tester.ensureSemantics(); - await pumpHost(tester, mode: ChatCompressionMode.smaz, enabled: false); - - final label = _l10n.chatCompression_label('SMAZ'); - expect(find.text(label), findsOneWidget); - expect(find.byIcon(Icons.lock_outline), findsOneWidget); - expect( - find.bySemanticsLabel('$label. ${_l10n.chatCompression_noStorageId}'), - findsOneWidget, - ); - - await openSheet(tester); - expect(find.text(_l10n.chatCompression_noStorageId), findsOneWidget); - expect(isSelected(tester, _l10n.chatCompression_smaz), isTrue); - for (final mode in [ - _l10n.chatCompression_off, - _l10n.chatCompression_smaz, - _l10n.chatCompression_cyr2lat, - ]) { - expect(tester.widget(optionRow(mode)).enabled, isFalse); - } - await tester.tap(find.text(_l10n.chatCompression_off), warnIfMissed: false); - await tester.pumpAndSettle(); - expect(modeCalls, isEmpty); - semantics.dispose(); - }); - - for (final scale in [1.3, 2.0]) { - testWidgets('fits a 320dp phone at ${scale}x text', (tester) async { - await pumpHost( - tester, - mode: ChatCompressionMode.cyr2lat, - enabled: true, - size: const Size(320, 568), - textScale: scale, - ); - expect(tester.takeException(), isNull); - await openSheet(tester); - expect(tester.takeException(), isNull); - // The sheet scrolls to its last option and the profile picker. - await tester.scrollUntilVisible( - find.text(_l10n.chatCompression_profile), - 200, - scrollable: find.byType(Scrollable).last, - ); - expect(tester.takeException(), isNull); - }); - } -}