diff --git a/documentation/README.md b/documentation/README.md index 64533529..8e392098 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -20,7 +20,7 @@ MeshCore Open is an open-source Flutter client for MeshCore LoRa mesh networking 7. [Settings](settings.md) - Device settings, app settings, radio configuration, backup/restore, and exports 8. [Notifications](notifications.md) - System notifications, replies from watches and Android Auto, unread badges, and notification preferences 9. [Repeater Management](repeater-management.md) - Repeater hub, status, CLI, telemetry, and neighbors -10. [Additional Features](additional-features.md) - GIF picker, localization, debug logs, SMAZ compression, and more +10. [Additional Features](additional-features.md) - GIF picker, localization, debug logs, SMAZ and Cyr2Lat compression, and more 11. [Routing Paths](routing-paths.md) - Path encoding, validation, device capability detection, and storage 12. [BLE Protocol & Data Layer](ble-protocol.md) - Technical reference for the communication protocol and data architecture 13. [Regions](regions.md) - App and radio default regions, unscoped sends, message labels, and reply regions diff --git a/documentation/additional-features.md b/documentation/additional-features.md index b160577d..3b984c8c 100644 --- a/documentation/additional-features.md +++ b/documentation/additional-features.md @@ -58,21 +58,28 @@ A list of nodes heard passively over the air but not yet added as contacts. Each --- -## SMAZ Compression +## Compression (SMAZ and Cyr2Lat) -### What It Is -An optional per-contact and per-channel text compression feature using the SMAZ algorithm (optimized for short English text). +### 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. -### How to Enable -- **Per contact**: Chat screen → overflow menu → Contact Settings → toggle "SMAZ compression" -- **Per channel**: Long-press channel → Edit → toggle "SMAZ compression" +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. -### How It Works -- When enabled, compression is applied using a "compress only if smaller" strategy — the message is only transmitted compressed if the encoded result is actually shorter than the original. Otherwise, the original text is sent uncompressed -- Compressed messages are transmitted with a `s:` prefix followed by base64-encoded data -- Recipients using MeshCore Open will decompress automatically. **Recipients using other software** that is not SMAZ-aware will see garbled `s:...` text -- The codec operates on ASCII. Non-ASCII / non-English text generally does not benefit from compression and may even expand. Best suited for short English messages -- Disabled by default +### Off +Sends your text exactly as typed. Every app can read it. + +### SMAZ (lossless) +- Compresses with the SMAZ short-text dictionary (optimized for short English text) +- "Compress only if smaller": a message is sent compressed only when the encoded result is shorter. Otherwise the original text is sent, so turning SMAZ on does not compress every message +- Compressed messages are sent as `s:` followed by base64 data. MeshCore Open decodes them back to exactly the original text. **Apps that do not understand SMAZ** show the `s:...` text instead +- The codec works on ASCII. Non-English text rarely benefits and may grow + +### Cyr2Lat (character substitution) +- Replaces some Cyrillic letters with lookalike Latin ones (for example `А→A`, `З→3`, `Ь→b`). Many Cyrillic letters take two bytes in UTF-8 and Latin ones take one, so some Cyrillic messages get shorter +- Not lossless: the exact characters change. Recipients need nothing special to read the result, but copying, searching, names and technical text may behave differently. Your own sent messages appear in the converted form +- The replacements come from a Cyr2Lat profile. Pick the chat's profile in the same sheet; without one, the app-wide profile from App Settings → Cyr2Lat is used. Not useful for English text + +Both are off by default. Settings saved before this selector existed are kept. --- diff --git a/documentation/channels.md b/documentation/channels.md index a8ce6641..3f682c25 100644 --- a/documentation/channels.md +++ b/documentation/channels.md @@ -61,7 +61,7 @@ Name limits count the `#` and any community prefix, so the name stored on the ra | Action | Description | |---|---| -| Edit | Change name, PSK (with a dice icon to generate a random PSK), SMAZ compression toggle (compresses outgoing messages to allow longer text within the byte limit), Cyr2Lat encoding toggle (transliterates Cyrillic to Latin for compatibility), or "Enable URL images" toggle (previews image links; requires internet) | +| Edit | Change name, PSK (with a dice icon to generate a random PSK), or "Enable URL images" toggle (previews image links; requires internet). Compression is chosen inside the channel chat (see below) | | Mute / Unmute | Toggle push notification suppression for this channel | | Delete | Remove the channel from the device and delete its messages, settings, region and images (confirmation required) | @@ -82,6 +82,10 @@ 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 + +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). + ### Message Display - Reverse-scrolling list (newest at bottom) diff --git a/documentation/chat-and-messaging.md b/documentation/chat-and-messaging.md index 53a47331..fbca33dc 100644 --- a/documentation/chat-and-messaging.md +++ b/documentation/chat-and-messaging.md @@ -20,7 +20,11 @@ From the Contacts screen, tap any Chat-type contact to open the ChatScreen. - **Subtitle**: Current routing path label (e.g., "2 hops", "flood (auto)", "direct (forced)") and unread count. Tapping the subtitle shows the full path details. - **Action buttons**: - **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, 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). + - **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 + +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). ### Message List diff --git a/documentation/design.md b/documentation/design.md index 423b53aa..8483c73d 100644 --- a/documentation/design.md +++ b/documentation/design.md @@ -117,7 +117,8 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act | Label above a group | `SectionHeader(label, trailing:)` | Upper-cases for you; pass the normal-case l10n string | | Settings navigation row | `MeshNavTile` | `onTap: null` dims it to 50 % and reports it as disabled; use `subtitle` to say why | | Settings switch | `SwitchListTile` inside `MeshSettingsTileTheme` | Wrap the settings screen body once in `MeshSettingsTileTheme` | -| Radio-style choice in a sheet | `MeshSheetOption` | Used by the language picker and map time filter | +| 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 | | 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:)` | | Popup menu row | **always** `PopupMenuItem(child: MeshMenuItemRow(icon:, label:))` | Label wraps to 2 lines then ellipsizes; `leading:` for `ThemedIcon`; no icon keeps the 20px slot | | Segmented button label | **always** `ButtonSegment(label: MeshSegmentLabel(text))` | Shrinks to 12 (before system scale), then wraps at word boundaries onto 2 centred lines; never breaks a word | diff --git a/documentation/settings.md b/documentation/settings.md index 3f101f07..91b2af5e 100644 --- a/documentation/settings.md +++ b/documentation/settings.md @@ -178,7 +178,7 @@ Save the settings before sharing. The upload action is shown in the chat compose Image message controls live in App Settings → Messaging. Turn on **Enable image messages** first; **Process images automatically** and the image model download/cancel/removal controls then appear. Automatic processing reconstructs every image as it arrives and uses about 2 GB of memory for a second each time; leave it off to reconstruct with a tap. See [Image Messages](image-messages.md) for firmware, native-runtime, storage, and memory requirements. ### Cyrillic-to-Latin (Cyr2Lat) -Controls character substitution profiles used to render Cyrillic text in Latin characters. A dropdown selects the active profile; Add, Edit, and Delete buttons manage the profile list (the last remaining profile cannot be deleted). Each profile stores a JSON character map. +Controls character substitution profiles used to render Cyrillic text in Latin characters. A dropdown selects the active profile; Add, Edit, and Delete buttons manage the profile list (the last remaining profile cannot be deleted). Each profile stores a JSON character map. The active profile is the default; each chat can pick its own in its **Compression** strip (see [Compression](additional-features.md#compression-smaz-and-cyr2lat)). ### Debug - **App Debug Logging**: Enable the in-app debug log diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index ad9fa57e..2f311f43 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -12,6 +12,7 @@ import 'package:flutter_blue_plus_platform_interface/flutter_blue_plus_platform_ import '../utils/advert_signature.dart'; import '../models/channel.dart'; import '../models/channel_message.dart'; +import '../models/chat_compression_mode.dart'; import '../models/bookmarked_message.dart'; import '../models/companion_radio_stats.dart'; import '../models/contact.dart'; @@ -1816,10 +1817,6 @@ class MeshCoreConnector extends ChangeNotifier { await _channelRegionStore.saveDefaultRegion(region); } - void ensureContactSmazSettingLoaded(String contactKeyHex) { - _ensureContactSmazSettingLoaded(contactKeyHex); - } - bool isChannelCyr2LatEnabled(int channelIndex) { _ensureChannelCyr2LatSettingLoaded(channelIndex); return _channelCyr2LatEnabled[channelIndex] ?? false; @@ -1830,10 +1827,6 @@ class MeshCoreConnector extends ChangeNotifier { return _contactCyr2LatEnabled[contactKeyHex] ?? false; } - void ensureContactCyr2LatSettingLoaded(String contactKeyHex) { - _ensureContactCyr2LatSettingLoaded(contactKeyHex); - } - Future loadUnreadState() async { _contactUnreadCount ..clear() @@ -2102,30 +2095,97 @@ class MeshCoreConnector extends ChangeNotifier { ]; } - Future setChannelSmazEnabled(int channelIndex, bool enabled) async { - final slots = _slotsSharingChannel(channelIndex); - for (final slot in slots) { - _channelSmazEnabled[slot] = enabled; + ChatCompressionMode channelCompressionMode(int channelIndex) { + if (isChannelSmazEnabled(channelIndex)) return ChatCompressionMode.smaz; + if (isChannelCyr2LatEnabled(channelIndex)) { + return ChatCompressionMode.cyr2lat; } - final channelId = _channelIdForSlot(channelIndex); - if (enabled) { - for (final slot in slots) { - _channelCyr2LatEnabled[slot] = false; - } - if (channelId != null) { - await _channelSettingsStore.saveCyr2LatEnabled(channelId, false); - } - } - if (channelId != null) { - await _channelSettingsStore.saveSmazEnabled(channelId, enabled); - } - notifyListeners(); + return ChatCompressionMode.off; } - Future setContactSmazEnabled(String contactKeyHex, bool enabled) async { - _contactSmazEnabled[contactKeyHex] = enabled; - await _contactSettingsStore.saveSmazEnabled(contactKeyHex, enabled); - notifyListeners(); + ChatCompressionMode contactCompressionMode(String contactKeyHex) { + _ensureContactSmazSettingLoaded(contactKeyHex); + if (isContactSmazEnabled(contactKeyHex)) return ChatCompressionMode.smaz; + if (isContactCyr2LatEnabled(contactKeyHex)) { + return ChatCompressionMode.cyr2lat; + } + return ChatCompressionMode.off; + } + + /// Serializes compression writes so overlapping choices can't interleave + /// their flag writes and leave SMAZ and Cyr2Lat both on. + Future _compressionWrites = Future.value(); + + Future _queueCompressionWrite(Future Function() write) { + final next = _compressionWrites.then((_) => write()); + _compressionWrites = next.catchError((_) {}); + return next; + } + + /// Saves [mode] for the channel in [channelIndex] and every slot holding + /// the same channel. Flags are switched off before the new one is switched + /// on, and memory follows each completed write, so a failure never leaves + /// both on. Throws [StateError] when the slot has no storage ID. + Future setChannelCompressionMode( + int channelIndex, + ChatCompressionMode mode, + ) { + return _queueCompressionWrite(() async { + final channelId = _channelIdForSlot(channelIndex); + if (channelId == null) { + throw StateError('Channel slot $channelIndex has no storage ID'); + } + final slots = _slotsSharingChannel(channelIndex); + Future writeSmaz(bool on) async { + await _channelSettingsStore.saveSmazEnabled(channelId, on); + for (final slot in slots) { + _channelSmazEnabled[slot] = on; + } + } + + Future writeCyr2Lat(bool on) async { + await _channelSettingsStore.saveCyr2LatEnabled(channelId, on); + for (final slot in slots) { + _channelCyr2LatEnabled[slot] = on; + } + } + + try { + if (mode != ChatCompressionMode.smaz) await writeSmaz(false); + if (mode != ChatCompressionMode.cyr2lat) await writeCyr2Lat(false); + if (mode == ChatCompressionMode.smaz) await writeSmaz(true); + if (mode == ChatCompressionMode.cyr2lat) await writeCyr2Lat(true); + } finally { + notifyListeners(); + } + }); + } + + /// Contact counterpart of [setChannelCompressionMode]. + Future setContactCompressionMode( + String contactKeyHex, + ChatCompressionMode mode, + ) { + return _queueCompressionWrite(() async { + Future writeSmaz(bool on) async { + await _contactSettingsStore.saveSmazEnabled(contactKeyHex, on); + _contactSmazEnabled[contactKeyHex] = on; + } + + Future writeCyr2Lat(bool on) async { + await _contactSettingsStore.saveCyr2LatEnabled(contactKeyHex, on); + _contactCyr2LatEnabled[contactKeyHex] = on; + } + + try { + if (mode != ChatCompressionMode.smaz) await writeSmaz(false); + if (mode != ChatCompressionMode.cyr2lat) await writeCyr2Lat(false); + if (mode == ChatCompressionMode.smaz) await writeSmaz(true); + if (mode == ChatCompressionMode.cyr2lat) await writeCyr2Lat(true); + } finally { + notifyListeners(); + } + }); } Future setChannelUrlImagesEnabled( @@ -2151,35 +2211,6 @@ class MeshCoreConnector extends ChangeNotifier { notifyListeners(); } - Future setChannelCyr2LatEnabled(int channelIndex, bool enabled) async { - final slots = _slotsSharingChannel(channelIndex); - for (final slot in slots) { - _channelCyr2LatEnabled[slot] = enabled; - } - final channelId = _channelIdForSlot(channelIndex); - if (enabled) { - for (final slot in slots) { - _channelSmazEnabled[slot] = false; - } - if (channelId != null) { - await _channelSettingsStore.saveSmazEnabled(channelId, false); - } - } - if (channelId != null) { - await _channelSettingsStore.saveCyr2LatEnabled(channelId, enabled); - } - notifyListeners(); - } - - Future setContactCyr2LatEnabled( - String contactKeyHex, - bool enabled, - ) async { - _contactCyr2LatEnabled[contactKeyHex] = enabled; - await _contactSettingsStore.saveCyr2LatEnabled(contactKeyHex, enabled); - notifyListeners(); - } - Future setChannelRegion(int channelIndex, String region) async { // Update in-memory state and notify synchronously so the UI reflects the // change immediately; persistence happens in the background. @@ -8337,7 +8368,7 @@ class MeshCoreConnector extends ChangeNotifier { void _ensureContactSmazSettingLoaded(String contactKeyHex) { if (_contactSmazEnabled.containsKey(contactKeyHex)) return; _contactSettingsStore.loadSmazEnabled(contactKeyHex).then((enabled) { - if (_contactSmazEnabled[contactKeyHex] == enabled) return; + if (_contactSmazEnabled.containsKey(contactKeyHex)) return; _contactSmazEnabled[contactKeyHex] = enabled; notifyListeners(); }); @@ -8346,7 +8377,7 @@ class MeshCoreConnector extends ChangeNotifier { void _ensureContactCyr2LatSettingLoaded(String contactKeyHex) { if (_contactCyr2LatEnabled.containsKey(contactKeyHex)) return; _contactSettingsStore.loadCyr2LatEnabled(contactKeyHex).then((enabled) { - if (_contactCyr2LatEnabled[contactKeyHex] == enabled) return; + if (_contactCyr2LatEnabled.containsKey(contactKeyHex)) return; _contactCyr2LatEnabled[contactKeyHex] = enabled; notifyListeners(); }); @@ -8364,7 +8395,7 @@ class MeshCoreConnector extends ChangeNotifier { void _ensureContactCyr2LatProfileLoaded(String contactKeyHex) { if (_contactCyr2LatProfileId.containsKey(contactKeyHex)) return; _contactSettingsStore.loadCyr2LatProfileId(contactKeyHex).then((profileId) { - if (_contactCyr2LatProfileId[contactKeyHex] == profileId) return; + if (_contactCyr2LatProfileId.containsKey(contactKeyHex)) return; _contactCyr2LatProfileId[contactKeyHex] = profileId; notifyListeners(); }); @@ -8375,7 +8406,7 @@ class MeshCoreConnector extends ChangeNotifier { final channelId = _slotChannelIds[channelIndex]; if (channelId == null) return; _channelSettingsStore.loadCyr2LatEnabled(channelId).then((enabled) { - if (_channelCyr2LatEnabled[channelIndex] == enabled) return; + if (_channelCyr2LatEnabled.containsKey(channelIndex)) return; _channelCyr2LatEnabled[channelIndex] = enabled; notifyListeners(); }); @@ -8386,7 +8417,7 @@ class MeshCoreConnector extends ChangeNotifier { final channelId = _slotChannelIds[channelIndex]; if (channelId == null) return; _channelSettingsStore.loadCyr2LatProfileId(channelId).then((profileId) { - if (_channelCyr2LatProfileId[channelIndex] == profileId) return; + if (_channelCyr2LatProfileId.containsKey(channelIndex)) return; _channelCyr2LatProfileId[channelIndex] = profileId; notifyListeners(); }); @@ -8402,13 +8433,13 @@ class MeshCoreConnector extends ChangeNotifier { String? profileId, ) async { if (_channelCyr2LatProfileId[channelIndex] == profileId) return; - for (final slot in _slotsSharingChannel(channelIndex)) { - _channelCyr2LatProfileId[slot] = profileId; - } final channelId = _channelIdForSlot(channelIndex); if (channelId != null) { await _channelSettingsStore.saveCyr2LatProfileId(channelId, profileId); } + for (final slot in _slotsSharingChannel(channelIndex)) { + _channelCyr2LatProfileId[slot] = profileId; + } notifyListeners(); } @@ -8422,8 +8453,8 @@ class MeshCoreConnector extends ChangeNotifier { String? profileId, ) async { if (_contactCyr2LatProfileId[contactKeyHex] == profileId) return; - _contactCyr2LatProfileId[contactKeyHex] = profileId; await _contactSettingsStore.saveCyr2LatProfileId(contactKeyHex, profileId); + _contactCyr2LatProfileId[contactKeyHex] = profileId; notifyListeners(); } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e18f6ed9..0e612bb8 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -973,9 +973,6 @@ } } }, - "channels_smazCompression": "SMAZ compression", - "channels_cyr2latCompression": "Cyr2Lat compression", - "channels_cyr2latCompressionDscr": "Replaces some Cyrillic characters with Latin characters when sending.", "channels_cyr2latSettingsHeading": "Cyr2Lat Setup", "channels_cyr2latSettingsSubheading": "List of replacements", "channels_cyr2latSettingsDscr": "Edit the JSON configuration of character replacement", @@ -1414,7 +1411,6 @@ "chat_path": "Path", "chat_viewPathOnMap": "View path on map", "chat_publicKey": "Public Key", - "chat_compressOutgoingMessages": "Compress outgoing messages", "chat_floodForced": "Flood (forced)", "chat_directForced": "Direct (forced)", "chat_hopsForced": "{count} hops (forced)", @@ -4341,5 +4337,26 @@ "chat_composerOffline": "Connect to a radio to send messages", "@chat_composerOffline": { "description": "Shown in place of the message box while no radio is connected" - } + }, + "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", + "placeholders": { + "mode": { + "type": "String" + } + } + }, + "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_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 53e641fa..d3b05d2f 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -3607,24 +3607,6 @@ abstract class AppLocalizations { /// **'Edit Channel {index}'** String channels_editChannelTitle(int index); - /// No description provided for @channels_smazCompression. - /// - /// In en, this message translates to: - /// **'SMAZ compression'** - String get channels_smazCompression; - - /// No description provided for @channels_cyr2latCompression. - /// - /// In en, this message translates to: - /// **'Cyr2Lat compression'** - String get channels_cyr2latCompression; - - /// No description provided for @channels_cyr2latCompressionDscr. - /// - /// In en, this message translates to: - /// **'Replaces some Cyrillic characters with Latin characters when sending.'** - String get channels_cyr2latCompressionDscr; - /// No description provided for @channels_cyr2latSettingsHeading. /// /// In en, this message translates to: @@ -4813,12 +4795,6 @@ abstract class AppLocalizations { /// **'Public Key'** String get chat_publicKey; - /// No description provided for @chat_compressOutgoingMessages. - /// - /// In en, this message translates to: - /// **'Compress outgoing messages'** - String get chat_compressOutgoingMessages; - /// No description provided for @chat_floodForced. /// /// In en, this message translates to: @@ -12633,6 +12609,84 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Connect to a radio to send messages'** String get chat_composerOffline; + + /// No description provided for @chatCompression_title. + /// + /// In en, this message translates to: + /// **'Compression'** + String get chatCompression_title; + + /// Always-visible control at the top of a chat; mode is Off, SMAZ or Cyr2Lat + /// + /// In en, this message translates to: + /// **'Compression: {mode}'** + String chatCompression_label(String mode); + + /// No description provided for @chatCompression_off. + /// + /// In en, this message translates to: + /// **'Off'** + String get chatCompression_off; + + /// No description provided for @chatCompression_smaz. + /// + /// In en, this message translates to: + /// **'SMAZ'** + String get chatCompression_smaz; + + /// No description provided for @chatCompression_cyr2lat. + /// + /// In en, this message translates to: + /// **'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: + /// **'Applies to messages you send in this chat. Saved on this phone.'** + String get chatCompression_sheetSubtitle; + + /// 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.'** + 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.'** + 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.'** + String get chatCompression_cyr2latDescription; + + /// No description provided for @chatCompression_profile. + /// + /// In en, this message translates to: + /// **'Cyr2Lat profile'** + String get chatCompression_profile; + + /// No description provided for @chatCompression_noStorageId. + /// + /// In en, this message translates to: + /// **'Can\'t change compression until this channel has synced from the radio.'** + String get chatCompression_noStorageId; + + /// No description provided for @chatCompression_saveFailed. + /// + /// In en, this message translates to: + /// **'Couldn\'t save the compression setting. Showing the saved setting.'** + String get chatCompression_saveFailed; } class _AppLocalizationsDelegate diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index cc0a9670..fe6e6735 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -2020,16 +2020,6 @@ class AppLocalizationsBg extends AppLocalizations { return 'Редактирай Канал $index'; } - @override - String get channels_smazCompression => 'Компресия SMAZ'; - - @override - String get channels_cyr2latCompression => 'Компресия Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Заменя някои кирилични символи с латиница при изпращане.'; - @override String get channels_cyr2latSettingsHeading => 'Настройки на Cyr2Lat'; @@ -2757,10 +2747,6 @@ class AppLocalizationsBg extends AppLocalizations { @override String get chat_publicKey => 'Публичен ключ'; - @override - String get chat_compressOutgoingMessages => - 'Компресиране на изходящи съобщения'; - @override String get chat_floodForced => 'Flood (принудително)'; @@ -7582,4 +7568,51 @@ class AppLocalizationsBg extends AppLocalizations { @override String get chat_composerOffline => 'Свържете се с радио, за да изпращате съобщения'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_cs.dart b/lib/l10n/app_localizations_cs.dart index 60ad5ee3..c5e7a674 100644 --- a/lib/l10n/app_localizations_cs.dart +++ b/lib/l10n/app_localizations_cs.dart @@ -2005,16 +2005,6 @@ class AppLocalizationsCs extends AppLocalizations { return 'Upravit kanál $index'; } - @override - String get channels_smazCompression => 'Komprese SMAZ'; - - @override - String get channels_cyr2latCompression => 'Komprese Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Při odesílání nahradí některé znaky cyrilice latinkou.'; - @override String get channels_cyr2latSettingsHeading => 'Nastavení Cyr2Lat'; @@ -2747,9 +2737,6 @@ class AppLocalizationsCs extends AppLocalizations { @override String get chat_publicKey => 'Veřejný klíč'; - @override - String get chat_compressOutgoingMessages => 'Komprimovat odchozí zprávy'; - @override String get chat_floodForced => 'Flood (vynuceno)'; @@ -7552,4 +7539,51 @@ class AppLocalizationsCs extends AppLocalizations { @override String get chat_composerOffline => 'Pro odesílání zpráv se připojte k rádiu'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 587287f7..47298222 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -2020,16 +2020,6 @@ class AppLocalizationsDe extends AppLocalizations { return 'Kanal $index bearbeiten'; } - @override - String get channels_smazCompression => 'SMAZ-Komprimierung'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat-Komprimierung'; - - @override - String get channels_cyr2latCompressionDscr => - 'Ersetzt beim Senden einige kyrillische Zeichen durch lateinische Zeichen.'; - @override String get channels_cyr2latSettingsHeading => 'Cyr2Lat-Einstellungen'; @@ -2759,10 +2749,6 @@ class AppLocalizationsDe extends AppLocalizations { @override String get chat_publicKey => 'Öffentlicher Schlüssel'; - @override - String get chat_compressOutgoingMessages => - 'Komprimieren ausgehender Nachrichten'; - @override String get chat_floodForced => 'Flood (erzwungen)'; @@ -7597,4 +7583,51 @@ class AppLocalizationsDe extends AppLocalizations { @override String get chat_composerOffline => 'Mit einem Funkgerät verbinden, um Nachrichten zu senden'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index f73db6d1..55f25921 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1984,16 +1984,6 @@ class AppLocalizationsEn extends AppLocalizations { return 'Edit Channel $index'; } - @override - String get channels_smazCompression => 'SMAZ compression'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat compression'; - - @override - String get channels_cyr2latCompressionDscr => - 'Replaces some Cyrillic characters with Latin characters when sending.'; - @override String get channels_cyr2latSettingsHeading => 'Cyr2Lat Setup'; @@ -2711,9 +2701,6 @@ class AppLocalizationsEn extends AppLocalizations { @override String get chat_publicKey => 'Public Key'; - @override - String get chat_compressOutgoingMessages => 'Compress outgoing messages'; - @override String get chat_floodForced => 'Flood (forced)'; @@ -7468,4 +7455,51 @@ class AppLocalizationsEn extends AppLocalizations { @override String get chat_composerOffline => 'Connect to a radio to send messages'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 8dd0aa61..1e3a9f98 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -2013,16 +2013,6 @@ class AppLocalizationsEs extends AppLocalizations { return 'Editar Canal $index'; } - @override - String get channels_smazCompression => 'Compresión SMAZ'; - - @override - String get channels_cyr2latCompression => 'Compresión Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Reemplaza algunos caracteres cirílicos con caracteres latinos al enviar.'; - @override String get channels_cyr2latSettingsHeading => 'Configuración de Cyr2Lat'; @@ -2749,9 +2739,6 @@ class AppLocalizationsEs extends AppLocalizations { @override String get chat_publicKey => 'Clave pública'; - @override - String get chat_compressOutgoingMessages => 'Comprimir mensajes salientes'; - @override String get chat_floodForced => 'Flood (forzado)'; @@ -7573,4 +7560,51 @@ class AppLocalizationsEs extends AppLocalizations { @override String get chat_composerOffline => 'Conéctate a una radio para enviar mensajes'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 9e1cde19..a3006ad0 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -2017,16 +2017,6 @@ class AppLocalizationsFr extends AppLocalizations { return 'Modifier le Canal $index'; } - @override - String get channels_smazCompression => 'Compression SMAZ'; - - @override - String get channels_cyr2latCompression => 'Compression Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Remplace certains caractères cyrilliques par des caractères latins lors de l\'envoi.'; - @override String get channels_cyr2latSettingsHeading => 'Paramètres Cyr2Lat'; @@ -2754,10 +2744,6 @@ class AppLocalizationsFr extends AppLocalizations { @override String get chat_publicKey => 'Clé publique'; - @override - String get chat_compressOutgoingMessages => - 'Compresser les messages sortants'; - @override String get chat_floodForced => 'Flood (forcé)'; @@ -7602,4 +7588,51 @@ class AppLocalizationsFr extends AppLocalizations { @override String get chat_composerOffline => 'Connectez-vous à une radio pour envoyer des messages'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index fae906b6..7781741b 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -2011,16 +2011,6 @@ class AppLocalizationsHu extends AppLocalizations { return 'Csatorna szerkesztése $index'; } - @override - String get channels_smazCompression => 'SMAZ tömörítés'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat tömörítés'; - - @override - String get channels_cyr2latCompressionDscr => - 'Küldéskor egyes cirill karaktereket latin karakterekre cserél.'; - @override String get channels_cyr2latSettingsHeading => 'Cyr2Lat beállítás'; @@ -2746,9 +2736,6 @@ class AppLocalizationsHu extends AppLocalizations { @override String get chat_publicKey => 'Nyilvános kulcs'; - @override - String get chat_compressOutgoingMessages => 'A kimenő üzenetek tömörítése'; - @override String get chat_floodForced => 'Flood (kényszerített)'; @@ -7565,4 +7552,51 @@ class AppLocalizationsHu extends AppLocalizations { @override String get chat_composerOffline => 'Üzenetküldéshez csatlakozzon rádióhoz'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 9d96718d..d34a068a 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -2014,16 +2014,6 @@ class AppLocalizationsIt extends AppLocalizations { return 'Modifica Canale $index'; } - @override - String get channels_smazCompression => 'Compressione SMAZ'; - - @override - String get channels_cyr2latCompression => 'Compressione Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Sostituisce alcuni caratteri cirillici con caratteri latini durante l\'invio.'; - @override String get channels_cyr2latSettingsHeading => 'Impostazioni Cyr2Lat'; @@ -2754,9 +2744,6 @@ class AppLocalizationsIt extends AppLocalizations { @override String get chat_publicKey => 'Chiave pubblica'; - @override - String get chat_compressOutgoingMessages => 'Comprimi messaggi in uscita'; - @override String get chat_floodForced => 'Flood (forzato)'; @@ -7585,4 +7572,51 @@ class AppLocalizationsIt extends AppLocalizations { @override String get chat_composerOffline => 'Connettiti a una radio per inviare messaggi'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 10908f1e..88d6e946 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -1919,15 +1919,6 @@ class AppLocalizationsJa extends AppLocalizations { return 'チャンネル $index の編集'; } - @override - String get channels_smazCompression => 'SMAZ 圧縮'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat 圧縮'; - - @override - String get channels_cyr2latCompressionDscr => '送信時に一部のキリル文字をラテン文字に置き換えます。'; - @override String get channels_cyr2latSettingsHeading => 'Cyr2Lat 設定'; @@ -2627,9 +2618,6 @@ class AppLocalizationsJa extends AppLocalizations { @override String get chat_publicKey => '公開鍵'; - @override - String get chat_compressOutgoingMessages => '送信メッセージを圧縮する'; - @override String get chat_floodForced => 'フラッド(強制)'; @@ -7227,4 +7215,51 @@ class AppLocalizationsJa extends AppLocalizations { @override String get chat_composerOffline => 'メッセージを送信するには無線機に接続してください'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 2ed52089..e8e29f0c 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -1923,15 +1923,6 @@ class AppLocalizationsKo extends AppLocalizations { return '채널 $index 편집'; } - @override - String get channels_smazCompression => 'SMAZ 압축'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat 압축'; - - @override - String get channels_cyr2latCompressionDscr => '보낼 때 일부 키릴 문자를 라틴 문자로 바꿉니다.'; - @override String get channels_cyr2latSettingsHeading => 'Cyr2Lat 설정'; @@ -2630,9 +2621,6 @@ class AppLocalizationsKo extends AppLocalizations { @override String get chat_publicKey => '공개 키'; - @override - String get chat_compressOutgoingMessages => '전송되는 메시지 압축'; - @override String get chat_floodForced => '플러딩 (강제)'; @@ -7240,4 +7228,51 @@ class AppLocalizationsKo extends AppLocalizations { @override String get chat_composerOffline => '메시지를 보내려면 무전기에 연결하세요'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index cc092841..ba6e9de4 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -2004,16 +2004,6 @@ class AppLocalizationsNl extends AppLocalizations { return 'Bewerk Kanaal $index'; } - @override - String get channels_smazCompression => 'SMAZ compressie'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat compressie'; - - @override - String get channels_cyr2latCompressionDscr => - 'Vervangt sommige Cyrillische tekens door Latijnse tekens bij het verzenden.'; - @override String get channels_cyr2latSettingsHeading => 'Instellingen Cyr2Lat'; @@ -2738,9 +2728,6 @@ class AppLocalizationsNl extends AppLocalizations { @override String get chat_publicKey => 'Openbare Sleutel'; - @override - String get chat_compressOutgoingMessages => 'Uitgaande berichten comprimeren'; - @override String get chat_floodForced => 'Flood (afgedwongen)'; @@ -7541,4 +7528,51 @@ class AppLocalizationsNl extends AppLocalizations { @override String get chat_composerOffline => 'Verbind met een radio om berichten te versturen'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 62a18751..76abe1f3 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -2028,16 +2028,6 @@ class AppLocalizationsPl extends AppLocalizations { return 'Edytuj Kanał $index'; } - @override - String get channels_smazCompression => 'Kompresja SMAZ'; - - @override - String get channels_cyr2latCompression => 'Kompresja Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Zastępuje niektóre znaki cyrylicy alfabetem łacińskim podczas wysyłania.'; - @override String get channels_cyr2latSettingsHeading => 'Ustawienia Cyr2Lat'; @@ -2781,9 +2771,6 @@ class AppLocalizationsPl extends AppLocalizations { @override String get chat_publicKey => 'Klucz Publiczny'; - @override - String get chat_compressOutgoingMessages => 'Kompresuj wychodzące wiadomości'; - @override String get chat_floodForced => 'Flood (wymuszony)'; @@ -7619,4 +7606,51 @@ class AppLocalizationsPl extends AppLocalizations { @override String get chat_composerOffline => 'Połącz się z radiem, aby wysyłać wiadomości'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 48a93255..e03a6a77 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -2013,16 +2013,6 @@ class AppLocalizationsPt extends AppLocalizations { return 'Editar Canal $index'; } - @override - String get channels_smazCompression => 'Compressão SMAZ'; - - @override - String get channels_cyr2latCompression => 'Compressão Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Substitui alguns caracteres cirílicos por caracteres latinos ao enviar.'; - @override String get channels_cyr2latSettingsHeading => 'Configuração do Cyr2Lat'; @@ -2748,9 +2738,6 @@ class AppLocalizationsPt extends AppLocalizations { @override String get chat_publicKey => 'Chave Pública'; - @override - String get chat_compressOutgoingMessages => 'Comprimir mensagens enviadas'; - @override String get chat_floodForced => 'Flood (forçado)'; @@ -7563,6 +7550,53 @@ class AppLocalizationsPt extends AppLocalizations { @override String get chat_composerOffline => 'Conecte-se a um rádio para enviar mensagens'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } /// The translations for Portuguese, as used in Portugal (`pt_PT`). @@ -9564,16 +9598,6 @@ class AppLocalizationsPtPt extends AppLocalizationsPt { return 'Editar canal $index'; } - @override - String get channels_smazCompression => 'Compressão SMAZ'; - - @override - String get channels_cyr2latCompression => 'Compressão Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Substitui alguns caracteres cirílicos por latinos ao enviar.'; - @override String get channels_cyr2latSettingsHeading => 'Configuração Cyr2Lat'; @@ -10273,9 +10297,6 @@ class AppLocalizationsPtPt extends AppLocalizationsPt { @override String get chat_publicKey => 'Chave pública'; - @override - String get chat_compressOutgoingMessages => 'Comprimir mensagens enviadas'; - @override String get chat_floodForced => 'Flood (forçado)'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index b2d7a486..65fa0d17 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -2012,16 +2012,6 @@ class AppLocalizationsRu extends AppLocalizations { return 'Изменить канал $index'; } - @override - String get channels_smazCompression => 'Сжатие SMAZ'; - - @override - String get channels_cyr2latCompression => 'Сжатие Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Заменяет некоторые кириллические символы на латиницу при отправке.'; - @override String get channels_cyr2latSettingsHeading => 'Настройка Cyr2Lat'; @@ -2760,9 +2750,6 @@ class AppLocalizationsRu extends AppLocalizations { @override String get chat_publicKey => 'Публичный ключ'; - @override - String get chat_compressOutgoingMessages => 'Сжимать исходящие сообщения'; - @override String get chat_floodForced => 'Flood (принудительно)'; @@ -7599,4 +7586,51 @@ class AppLocalizationsRu extends AppLocalizations { @override String get chat_composerOffline => 'Подключитесь к радио, чтобы отправлять сообщения'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 0c1327b4..531f0f42 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -2005,16 +2005,6 @@ class AppLocalizationsSk extends AppLocalizations { return 'Upraviť kanál $index'; } - @override - String get channels_smazCompression => 'Odstránenie kompresie SMAZ'; - - @override - String get channels_cyr2latCompression => 'Odstránenie kompresie Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Pri odosielaní nahradí niektoré znaky cyriliky latinskými znakmi.'; - @override String get channels_cyr2latSettingsHeading => 'Nastavenia Cyr2Lat'; @@ -2752,9 +2742,6 @@ class AppLocalizationsSk extends AppLocalizations { @override String get chat_publicKey => 'Verejný kľúč'; - @override - String get chat_compressOutgoingMessages => 'Komprimovať odoslané správy'; - @override String get chat_floodForced => 'Flood (vynútený)'; @@ -7564,4 +7551,51 @@ class AppLocalizationsSk extends AppLocalizations { @override String get chat_composerOffline => 'Na odosielanie správ sa pripojte k rádiu'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 3701f9e0..9f3507f6 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -2003,16 +2003,6 @@ class AppLocalizationsSl extends AppLocalizations { return 'Uredi Kanal $index'; } - @override - String get channels_smazCompression => 'Kompresija SMAZ'; - - @override - String get channels_cyr2latCompression => 'Kompresija Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Pri pošiljanju nekatere cirilice nadomesti z latiničnimi.'; - @override String get channels_cyr2latSettingsHeading => 'Nastavitve Cyr2Lat'; @@ -2747,9 +2737,6 @@ class AppLocalizationsSl extends AppLocalizations { @override String get chat_publicKey => 'Ključ javnega tipa'; - @override - String get chat_compressOutgoingMessages => 'Stisnite izhodne sporočila'; - @override String get chat_floodForced => 'Flood (vsiljeno)'; @@ -7558,4 +7545,51 @@ class AppLocalizationsSl extends AppLocalizations { @override String get chat_composerOffline => 'Za pošiljanje sporočil se povežite z radiem'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 9aa969ce..a1a1d60c 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -1991,16 +1991,6 @@ class AppLocalizationsSv extends AppLocalizations { return 'Redigera Kanal $index'; } - @override - String get channels_smazCompression => 'SMAZ-komprimering'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat-komprimering'; - - @override - String get channels_cyr2latCompressionDscr => - 'Ersätter vissa kyrilliska tecken med latinska tecken när du skickar.'; - @override String get channels_cyr2latSettingsHeading => 'Inställningar för Cyr2Lat'; @@ -2726,9 +2716,6 @@ class AppLocalizationsSv extends AppLocalizations { @override String get chat_publicKey => 'Publik nyckel'; - @override - String get chat_compressOutgoingMessages => 'Komprimera utgående meddelanden'; - @override String get chat_floodForced => 'Flood (tvingad)'; @@ -7518,4 +7505,51 @@ class AppLocalizationsSv extends AppLocalizations { @override String get chat_composerOffline => 'Anslut till en radio för att skicka meddelanden'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index de2125bc..27db6d88 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -2008,16 +2008,6 @@ class AppLocalizationsUk extends AppLocalizations { return 'Редагувати канал $index'; } - @override - String get channels_smazCompression => 'Стиснення SMAZ'; - - @override - String get channels_cyr2latCompression => 'Стиснення Cyr2Lat'; - - @override - String get channels_cyr2latCompressionDscr => - 'Замінює деякі кириличні символи на латиницю при відправці.'; - @override String get channels_cyr2latSettingsHeading => 'Налаштування Cyr2Lat'; @@ -2757,9 +2747,6 @@ class AppLocalizationsUk extends AppLocalizations { @override String get chat_publicKey => 'Відкритий ключ'; - @override - String get chat_compressOutgoingMessages => 'Стискати вихідні повідомлення'; - @override String get chat_floodForced => 'Flood (примусово)'; @@ -7611,4 +7598,51 @@ class AppLocalizationsUk extends AppLocalizations { @override String get chat_composerOffline => 'Підключіться до радіо, щоб надсилати повідомлення'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 241d78de..2c7eefd0 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1893,15 +1893,6 @@ class AppLocalizationsZh extends AppLocalizations { return '编辑频道 $index'; } - @override - String get channels_smazCompression => 'SMAZ 压缩'; - - @override - String get channels_cyr2latCompression => 'Cyr2Lat 压缩'; - - @override - String get channels_cyr2latCompressionDscr => '发送时将一些西里尔字符替换为拉丁字符。'; - @override String get channels_cyr2latSettingsHeading => 'Cyr2Lat 設定'; @@ -2586,9 +2577,6 @@ class AppLocalizationsZh extends AppLocalizations { @override String get chat_publicKey => '公钥'; - @override - String get chat_compressOutgoingMessages => '压缩发送的消息'; - @override String get chat_floodForced => '泛洪(强制)'; @@ -7070,4 +7058,51 @@ class AppLocalizationsZh extends AppLocalizations { @override String get chat_composerOffline => '连接到无线电后才能发送消息'; + + @override + String get chatCompression_title => 'Compression'; + + @override + String chatCompression_label(String mode) { + return 'Compression: $mode'; + } + + @override + String get chatCompression_off => 'Off'; + + @override + String get chatCompression_smaz => 'SMAZ'; + + @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.'; + + @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.'; + + @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.'; + + @override + String get chatCompression_profile => 'Cyr2Lat profile'; + + @override + String get chatCompression_noStorageId => + 'Can\'t change compression until this channel has synced from the radio.'; + + @override + String get chatCompression_saveFailed => + 'Couldn\'t save the compression setting. Showing the saved setting.'; } diff --git a/lib/models/chat_compression_mode.dart b/lib/models/chat_compression_mode.dart new file mode 100644 index 00000000..fd2bd98b --- /dev/null +++ b/lib/models/chat_compression_mode.dart @@ -0,0 +1,3 @@ +/// Outgoing text transformation chosen for one contact or channel chat. +/// Stored as the existing SMAZ and Cyr2Lat flags, at most one of them on. +enum ChatCompressionMode { off, smaz, cyr2lat } diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 67a397ab..32068471 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -53,6 +53,7 @@ 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'; @@ -845,6 +846,7 @@ class _ChannelChatScreenState extends State { top: false, child: Column( children: [ + _buildCompressionSelector(), Expanded( child: ChatBackdrop( key: _messageAreaKey, @@ -2753,6 +2755,32 @@ class _ChannelChatScreenState extends State { static String _replyPrefix(ChannelMessage replyTo) => '@[${replyTo.senderName}] '; + /// 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() { + 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, + onModeChanged: (mode) => + connector.setChannelCompressionMode(slot, mode), + onProfileChanged: (id) => + connector.setChannelCyr2LatProfileId(slot, id), + ); + }, + ); + } + Widget _buildInputBar() { // Only the fields the composer depends on, so unrelated connector // notifications (adverts, other chats, radio stats) don't rebuild it. diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index 6f247343..9131ed35 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -1951,16 +1951,11 @@ void showEditChannelSheet( context, listen: false, ); - bool smazEnabled = connector.isChannelSmazEnabled(channel.index); - bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index); final initialUrlImagesEnabled = connector.isChannelUrlImagesEnabled( channel.index, ); bool urlImagesEnabled = initialUrlImagesEnabled; final loadLinkImages = appSettingsService.settings.loadLinkImages; - String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId( - channel.index, - ); showMeshSheet( context, @@ -2018,62 +2013,6 @@ void showEditChannelSheet( ), ), const SizedBox(height: 16), - SwitchListTile( - contentPadding: EdgeInsets.zero, - title: Text(sheetContext.l10n.channels_smazCompression), - value: smazEnabled, - onChanged: (value) => setSheetState(() { - smazEnabled = value; - if (smazEnabled) { - cyr2latEnabled = false; - } - }), - ), - SwitchListTile( - contentPadding: EdgeInsets.zero, - title: Text( - sheetContext.l10n.channels_cyr2latCompression, - ), - subtitle: Text( - sheetContext.l10n.channels_cyr2latCompressionDscr, - ), - value: cyr2latEnabled, - onChanged: (value) => setSheetState(() { - cyr2latEnabled = value; - if (cyr2latEnabled) { - smazEnabled = false; - } - }), - ), - if (cyr2latEnabled) ...[ - Padding( - padding: const EdgeInsets.fromLTRB(0, 8, 0, 8), - child: DropdownButtonFormField( - isExpanded: true, - initialValue: selectedCyr2LatProfileId, - decoration: InputDecoration( - labelText: sheetContext - .l10n - .channels_cyr2latSettingsSubheading, - border: const OutlineInputBorder(), - ), - items: appSettingsService.settings.cyr2latProfiles - .map((profile) { - return DropdownMenuItem( - value: profile.id, - child: Text( - profile.name, - overflow: TextOverflow.ellipsis, - ), - ); - }) - .toList(), - onChanged: (value) => setSheetState(() { - selectedCyr2LatProfileId = value; - }), - ), - ), - ], SwitchListTile( contentPadding: EdgeInsets.zero, title: Text(sheetContext.l10n.urlImage_enable), @@ -2135,30 +2074,38 @@ void showEditChannelSheet( } Navigator.pop(sheetContext); + // A new PSK gives the channel a new storage ID; + // its compression settings move with it. + final previousId = connector.channelIdForSlot( + channel.index, + ); + final compression = connector + .channelCompressionMode(channel.index); + final cyr2LatProfileId = connector + .getChannelCyr2LatProfileId(channel.index); try { await connector.setChannel( channel.index, name, psk, ); - await connector.setChannelSmazEnabled( - channel.index, - smazEnabled, - ); - await connector.setChannelCyr2LatEnabled( - channel.index, - cyr2latEnabled, - ); + if (connector.channelIdForSlot(channel.index) != + previousId) { + await connector.setChannelCompressionMode( + channel.index, + compression, + ); + await connector.setChannelCyr2LatProfileId( + channel.index, + cyr2LatProfileId, + ); + } if (urlImagesEnabled != initialUrlImagesEnabled) { await connector.setChannelUrlImagesEnabled( channel.index, urlImagesEnabled, ); } - await connector.setChannelCyr2LatProfileId( - channel.index, - selectedCyr2LatProfileId, - ); if (!context.mounted) return; showDismissibleSnackBar( context, diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index ad509b82..7b03ae03 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -37,6 +37,7 @@ 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'; @@ -622,6 +623,7 @@ class _ChatScreenState extends State { ); return Column( children: [ + _buildCompressionSelector(connector), Expanded( child: ChatBackdrop( key: _messageAreaKey, @@ -648,6 +650,27 @@ class _ChatScreenState extends State { ); } + /// Compression is stored on this phone per contact, so it can change + /// while the radio is offline. + Widget _buildCompressionSelector(MeshCoreConnector connector) { + 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, + onModeChanged: (mode) => + connector.setContactCompressionMode(keyHex, mode), + onProfileChanged: (id) => + connector.setContactCyr2LatProfileId(keyHex, id), + ); + }, + ); + } + Widget _buildEmptyState() { if (_showBookmarkedOnly) return _buildBookmarkEmptyState(); return EmptyState( @@ -1109,19 +1132,9 @@ class _ChatScreenState extends State { void _showContactSettings(BuildContext context) { final connector = Provider.of(context, listen: false); - final appSettingsService = Provider.of( - context, - listen: false, - ); - connector.ensureContactSmazSettingLoaded(widget.contact.publicKeyHex); - connector.ensureContactCyr2LatSettingLoaded(widget.contact.publicKeyHex); // The live contact carries the current telemetry flags; widget.contact // is the snapshot this screen was opened with. final contact = _resolveContact(connector); - bool smazEnabled = connector.isContactSmazEnabled(contact.publicKeyHex); - bool cyr2latEnabled = connector.isContactCyr2LatEnabled( - contact.publicKeyHex, - ); bool urlImagesEnabled = connector.isContactUrlImagesEnabled( contact.publicKeyHex, ); @@ -1129,14 +1142,11 @@ class _ChatScreenState extends State { .read() .settings .loadLinkImages; - String? selectedCyr2LatProfileId = connector.getContactCyr2LatProfileId( - contact.publicKeyHex, - ); bool teleBaseEnabled = contact.teleBaseEnabled; bool teleLocEnabled = contact.teleLocEnabled; bool teleEnvEnabled = contact.teleEnvEnabled; - // Each toggle is committed immediately, like the compression switches, - // so dismissing the dialog by tapping outside keeps the change. All three + // Each toggle is committed immediately, like the link-image switch, so + // dismissing the dialog by tapping outside keeps the change. All three // flags are sent every time so overlapping writes can't undo each other. void commitTelemetryFlags() { connector.setContactFlags( @@ -1164,86 +1174,6 @@ class _ChatScreenState extends State { ), const Divider(height: 8), ], - SwitchListTile( - contentPadding: EdgeInsets.zero, - title: Text(context.l10n.channels_smazCompression), - subtitle: Text(context.l10n.chat_compressOutgoingMessages), - value: smazEnabled, - onChanged: (value) { - connector.setContactSmazEnabled( - contact.publicKeyHex, - value, - ); - connector.setContactCyr2LatEnabled( - contact.publicKeyHex, - false, - ); - setDialogState(() { - smazEnabled = value; - if (smazEnabled) { - cyr2latEnabled = false; - } - }); - }, - ), - const Divider(height: 8), - SwitchListTile( - contentPadding: EdgeInsets.zero, - title: Text(context.l10n.channels_cyr2latCompression), - subtitle: Text(context.l10n.channels_cyr2latCompressionDscr), - value: cyr2latEnabled, - onChanged: (value) { - connector.setContactCyr2LatEnabled( - contact.publicKeyHex, - value, - ); - connector.setContactSmazEnabled( - contact.publicKeyHex, - false, - ); - setDialogState(() { - cyr2latEnabled = value; - if (cyr2latEnabled) { - smazEnabled = false; - } - }); - }, - ), - if (cyr2latEnabled) ...[ - Padding( - padding: const EdgeInsets.fromLTRB(0, 8, 0, 8), - child: DropdownButtonFormField( - isExpanded: true, - initialValue: selectedCyr2LatProfileId, - decoration: InputDecoration( - labelText: - context.l10n.channels_cyr2latSettingsSubheading, - border: const OutlineInputBorder(), - ), - items: appSettingsService.settings.cyr2latProfiles.map(( - profile, - ) { - return DropdownMenuItem( - value: profile.id, - child: Text( - profile.name, - overflow: TextOverflow.ellipsis, - ), - ); - }).toList(), - onChanged: (value) { - connector.setContactCyr2LatProfileId( - contact.publicKeyHex, - value, - ); - setDialogState(() { - selectedCyr2LatProfileId = value; - }); - }, - ), - ), - ], - const Divider(height: 8), SwitchListTile( contentPadding: EdgeInsets.zero, title: Text(context.l10n.urlImage_enable), diff --git a/lib/widgets/chat_compression_selector.dart b/lib/widgets/chat_compression_selector.dart new file mode 100644 index 00000000..5bddf0cd --- /dev/null +++ b/lib/widgets/chat_compression_selector.dart @@ -0,0 +1,356 @@ +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; + + const _SelectorView({ + required this.mode, + required this.enabled, + required this.profiles, + required this.profileId, + required this.busy, + required this.failed, + }); +} + +class _ChatCompressionSelectorState extends State { + late final ValueNotifier<_SelectorView> _view = ValueNotifier(_snapshot()); + bool _busy = false; + bool _failed = false; + + _SelectorView _snapshot() => _SelectorView( + mode: widget.mode, + enabled: widget.enabled, + profiles: widget.profiles, + profileId: widget.effectiveProfileId, + busy: _busy, + failed: _failed, + ); + + @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; + }); + _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( + // Rebuild with the saved value after a change or failure. + key: ValueKey(profileValue), + 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/lib/widgets/mesh_nav_tile.dart b/lib/widgets/mesh_nav_tile.dart index 9838f4b2..f5771371 100644 --- a/lib/widgets/mesh_nav_tile.dart +++ b/lib/widgets/mesh_nav_tile.dart @@ -119,14 +119,18 @@ class MeshNavTile extends StatelessWidget { } /// One radio-style option row inside a bottom sheet picker. +/// The selected row shows a filled radio icon and a bold title, so the +/// choice never depends on colour alone. A null [onTap] disables the row. class MeshSheetOption extends StatelessWidget { final String label; + final String? subtitle; final bool selected; - final VoidCallback onTap; + final VoidCallback? onTap; const MeshSheetOption({ super.key, required this.label, + this.subtitle, required this.selected, required this.onTap, }); @@ -134,14 +138,23 @@ class MeshSheetOption extends StatelessWidget { @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; - return ListTile( - leading: Icon( - selected ? Icons.radio_button_checked : Icons.radio_button_unchecked, - size: 24, - color: selected ? scheme.primary : scheme.onSurfaceVariant, + return Semantics( + selected: selected, + inMutuallyExclusiveGroup: true, + child: ListTile( + leading: Icon( + selected ? Icons.radio_button_checked : Icons.radio_button_unchecked, + size: 24, + color: selected ? scheme.primary : scheme.onSurfaceVariant, + ), + title: Text( + label, + style: selected ? const TextStyle(fontWeight: FontWeight.w700) : null, + ), + subtitle: subtitle == null ? null : Text(subtitle!), + enabled: onTap != null, + onTap: onTap, ), - title: Text(label), - onTap: onTap, ); } } diff --git a/test/connector/channel_slot_map_test.dart b/test/connector/channel_slot_map_test.dart index cdcbafa7..870cc37a 100644 --- a/test/connector/channel_slot_map_test.dart +++ b/test/connector/channel_slot_map_test.dart @@ -7,6 +7,7 @@ import 'package:meshcore_open/connector/meshcore_connector.dart'; import 'package:meshcore_open/connector/meshcore_protocol.dart'; import 'package:meshcore_open/models/channel.dart'; import 'package:meshcore_open/models/channel_message.dart'; +import 'package:meshcore_open/models/chat_compression_mode.dart'; import 'package:meshcore_open/review_mode/review_frames.dart'; import 'package:meshcore_open/review_mode/review_radio.dart'; import 'package:meshcore_open/review_mode/review_script.dart'; @@ -201,7 +202,7 @@ void main() { 'another slot brings its history back', () async { await _connect(_TestRadio()); await _waitFor(() => _texts(1).contains(_queuedHikingText)); - await _connector.setChannelSmazEnabled(1, true); + await _connector.setChannelCompressionMode(1, ChatCompressionMode.smaz); await _connector.setChannel(1, 'Hiking Group', ghostPsk); expect(_connector.channelIdForSlot(1), ghostId); @@ -408,7 +409,7 @@ void main() { expect(_texts(5), _texts(1)); // Settings are stored per channel, so both slots see a change. - await _connector.setChannelSmazEnabled(5, true); + await _connector.setChannelCompressionMode(5, ChatCompressionMode.smaz); expect(_connector.isChannelSmazEnabled(1), isTrue); await _connector.setChannelRegion(1, 'test-region'); expect(_connector.getChannelRegion(5), 'test-region'); diff --git a/test/connector/chat_compression_mode_test.dart b/test/connector/chat_compression_mode_test.dart new file mode 100644 index 00000000..2f3bc7a0 --- /dev/null +++ b/test/connector/chat_compression_mode_test.dart @@ -0,0 +1,163 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/models/chat_compression_mode.dart'; +import 'package:meshcore_open/review_mode/review_radio.dart'; +import 'package:meshcore_open/services/message_retry_service.dart'; +import 'package:meshcore_open/services/path_history_service.dart'; +import 'package:meshcore_open/services/storage_service.dart'; +import 'package:meshcore_open/storage/channel_settings_store.dart'; +import 'package:meshcore_open/storage/contact_settings_store.dart'; +import 'package:meshcore_open/storage/prefs_manager.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const _contactKey = + '1111111111111111111111111111111111111111111111111111111111111111'; + +Future _waitFor(bool Function() condition) async { + final end = DateTime.now().add(const Duration(seconds: 8)); + while (!condition()) { + if (DateTime.now().isAfter(end)) fail('Timed out waiting for condition'); + await Future.delayed(const Duration(milliseconds: 20)); + } +} + +ContactSettingsStore _contactStore() => + ContactSettingsStore()..setPublicKeyHex = ReviewRadio.selfPublicKeyHex; + +ChannelSettingsStore _channelStore() => + ChannelSettingsStore()..setPublicKeyHex = ReviewRadio.selfPublicKeyHex; + +Future<(bool, bool)> _savedContactFlags() async => ( + await _contactStore().loadSmazEnabled(_contactKey), + await _contactStore().loadCyr2LatEnabled(_contactKey), +); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + late MeshCoreConnector connector; + + // The connector's frame streams can only be listened to once per process, + // so the tests share one connected review radio. + setUpAll(() async { + SharedPreferences.setMockInitialValues({}); + PrefsManager.reset(); + await PrefsManager.initialize(); + connector = MeshCoreConnector(); + final retryService = MessageRetryService(); + connector.initialize( + retryService: retryService, + pathHistoryService: PathHistoryService(StorageService()), + ); + connector.reviewRadioFactoryForTest = () => ReviewRadio( + scheduledMessageInterval: const Duration(hours: 1), + ackDelay: const Duration(hours: 1), + replyDelay: const Duration(hours: 1), + ); + await connector.connectReview(); + await _waitFor(() => connector.channelMapConfirmed); + addTearDown(() async { + await connector.disconnect(); + connector.dispose(); + retryService.dispose(); + }); + }); + + test('contact modes are mutually exclusive and saved', () async { + expect( + connector.contactCompressionMode(_contactKey), + ChatCompressionMode.off, + ); + + await connector.setContactCompressionMode( + _contactKey, + ChatCompressionMode.smaz, + ); + expect(connector.isContactSmazEnabled(_contactKey), isTrue); + expect(connector.isContactCyr2LatEnabled(_contactKey), isFalse); + expect(await _savedContactFlags(), (true, false)); + + await connector.setContactCompressionMode( + _contactKey, + ChatCompressionMode.cyr2lat, + ); + expect( + connector.contactCompressionMode(_contactKey), + ChatCompressionMode.cyr2lat, + ); + expect(connector.isContactSmazEnabled(_contactKey), isFalse); + expect(await _savedContactFlags(), (false, true)); + + await connector.setContactCompressionMode( + _contactKey, + ChatCompressionMode.off, + ); + expect( + connector.contactCompressionMode(_contactKey), + ChatCompressionMode.off, + ); + expect(await _savedContactFlags(), (false, false)); + }); + + test('overlapping contact choices end on the last one, never both', () async { + final writes = [ + connector.setContactCompressionMode( + _contactKey, + ChatCompressionMode.smaz, + ), + connector.setContactCompressionMode( + _contactKey, + ChatCompressionMode.cyr2lat, + ), + connector.setContactCompressionMode( + _contactKey, + ChatCompressionMode.smaz, + ), + ]; + await Future.wait(writes); + expect( + connector.contactCompressionMode(_contactKey), + ChatCompressionMode.smaz, + ); + expect(connector.isContactCyr2LatEnabled(_contactKey), isFalse); + expect(await _savedContactFlags(), (true, false)); + }); + + test( + 'channel modes are mutually exclusive and saved by channel ID', + () async { + final channelId = connector.channelIdForSlot(1)!; + + await connector.setChannelCompressionMode(1, ChatCompressionMode.cyr2lat); + expect(connector.channelCompressionMode(1), ChatCompressionMode.cyr2lat); + expect(await _channelStore().loadCyr2LatEnabled(channelId), isTrue); + expect(await _channelStore().loadSmazEnabled(channelId), isFalse); + + await connector.setChannelCompressionMode(1, ChatCompressionMode.smaz); + expect(connector.channelCompressionMode(1), ChatCompressionMode.smaz); + expect(connector.isChannelCyr2LatEnabled(1), isFalse); + expect(await _channelStore().loadCyr2LatEnabled(channelId), isFalse); + expect(await _channelStore().loadSmazEnabled(channelId), isTrue); + + // Other channels are untouched. + expect(connector.channelCompressionMode(0), ChatCompressionMode.off); + }, + ); + + test('a channel slot without a storage ID is refused', () async { + const emptySlot = 30; + expect(connector.channelIdForSlot(emptySlot), isNull); + await expectLater( + connector.setChannelCompressionMode(emptySlot, ChatCompressionMode.smaz), + throwsStateError, + ); + expect( + connector.channelCompressionMode(emptySlot), + ChatCompressionMode.off, + ); + + // A refused write does not block later ones. + await connector.setChannelCompressionMode(1, ChatCompressionMode.smaz); + expect(connector.channelCompressionMode(1), ChatCompressionMode.smaz); + }); +} diff --git a/test/screens/offline_mode_test.dart b/test/screens/offline_mode_test.dart index a381d195..fb827588 100644 --- a/test/screens/offline_mode_test.dart +++ b/test/screens/offline_mode_test.dart @@ -34,13 +34,17 @@ import 'package:meshcore_open/services/timeout_prediction_service.dart'; import 'package:meshcore_open/services/translation_service.dart'; import 'package:meshcore_open/services/ui_view_state_service.dart'; import 'package:meshcore_open/storage/channel_message_store.dart'; +import 'package:meshcore_open/storage/channel_settings_store.dart'; +import 'package:meshcore_open/storage/contact_settings_store.dart'; import 'package:meshcore_open/storage/channel_store.dart'; import 'package:meshcore_open/storage/contact_store.dart'; 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/widgets/connect_sheet.dart'; final _radioKey = Uint8List.fromList(List.generate(32, (i) => 0xA0 + i)); @@ -344,4 +348,246 @@ void main() { await tester.pumpWidget(const SizedBox()); await tester.pump(const Duration(minutes: 1)); }); + + group('compression selector', () { + Future choose(WidgetTester tester, String mode) async { + await tester.tap(find.byType(ChatCompressionSelector)); + await _settle(tester); + await tester.tap(find.text(mode)); + await _settle(tester); + // Connector notifications are debounced on a real timer. + await tester.runAsync( + () => Future.delayed(const Duration(milliseconds: 200)), + ); + await _settle(tester); + } + + testWidgets('DM chat shows it at the top and saves offline', ( + tester, + ) async { + final connector = await _offlineConnector(tester); + final alice = connector.contacts.single; + final store = ContactSettingsStore()..setPublicKeyHex = _radioHex; + await tester.pumpWidget( + await _app(tester, connector, ChatScreen(contact: alice)), + ); + await _settle(tester); + + expect(find.byType(ChatCompressionSelector), findsOneWidget); + 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), + ); + + await choose(tester, _l10n.chatCompression_smaz); + expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); + 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); + expect(find.text(_l10n.chatCompression_label('Cyr2Lat')), findsOneWidget); + expect( + connector.contactCompressionMode(alice.publicKeyHex), + ChatCompressionMode.cyr2lat, + ); + expect( + await tester.runAsync(() => store.loadSmazEnabled(alice.publicKeyHex)), + isFalse, + ); + expect( + await tester.runAsync( + () => store.loadCyr2LatEnabled(alice.publicKeyHex), + ), + isTrue, + ); + + // 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); + expect( + find.descendant( + of: find.byType(AlertDialog), + matching: find.textContaining(RegExp('SMAZ|Cyr2Lat')), + ), + findsNothing, + ); + await tester.pumpWidget(const SizedBox()); + }); + + testWidgets('channel chat uses the same selector and saves offline', ( + tester, + ) async { + final connector = await _offlineConnector(tester); + final channel = connector.channels.single; + final store = ChannelSettingsStore()..setPublicKeyHex = _radioHex; + await tester.pumpWidget( + await _app(tester, connector, ChannelChatScreen(channel: channel)), + ); + await _settle(tester); + + expect(find.byType(ChatCompressionSelector), findsOneWidget); + expect(find.text(_l10n.chatCompression_label('Off')), findsOneWidget); + + await choose(tester, _l10n.chatCompression_smaz); + expect(find.text(_l10n.chatCompression_label('SMAZ')), findsOneWidget); + expect( + await tester.runAsync(() => store.loadSmazEnabled(channel.storageId!)), + isTrue, + ); + expect( + await tester.runAsync( + () => store.loadCyr2LatEnabled(channel.storageId!), + ), + isFalse, + ); + await tester.pumpWidget(const SizedBox()); + }); + + testWidgets('saving the channel edit sheet leaves compression alone', ( + tester, + ) async { + final connector = MeshCoreConnector(); + addTearDown(connector.dispose); + connector.reviewRadioFactoryForTest = () => ReviewRadio( + scheduledMessageInterval: const Duration(hours: 1), + ackDelay: const Duration(hours: 1), + replyDelay: const Duration(hours: 1), + ); + await tester.runAsync(connector.connectReview); + await _waitFor(tester, () => connector.channelMapConfirmed); + final channel = connector.channels.firstWhere((c) => c.index == 1); + await tester.runAsync( + () => connector.setChannelCompressionMode(1, ChatCompressionMode.smaz), + ); + + await tester.pumpWidget( + await _app( + tester, + connector, + Builder( + builder: (context) => Scaffold( + body: Center( + child: TextButton( + onPressed: () => + showEditChannelSheet(context, connector, channel), + child: const Text('edit'), + ), + ), + ), + ), + ), + ); + await tester.tap(find.text('edit')); + await _settle(tester); + expect(find.text('SMAZ compression'), findsNothing); + + // The chat's selector changes the mode while the sheet is open. + await tester.runAsync( + () => + connector.setChannelCompressionMode(1, ChatCompressionMode.cyr2lat), + ); + await tester.enterText(find.byType(TextField).first, 'Hiking Crew'); + await tester.tap(find.text(_l10n.common_save)); + await tester.runAsync( + () => Future.delayed(const Duration(milliseconds: 500)), + ); + await _settle(tester); + + expect( + connector.channels.firstWhere((c) => c.index == 1).name, + 'Hiking Crew', + ); + expect(connector.channelCompressionMode(1), ChatCompressionMode.cyr2lat); + + await tester.runAsync(connector.disconnect); + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }); + + testWidgets('a new PSK in the channel edit sheet keeps compression', ( + tester, + ) async { + final connector = MeshCoreConnector(); + addTearDown(connector.dispose); + connector.reviewRadioFactoryForTest = () => ReviewRadio( + scheduledMessageInterval: const Duration(hours: 1), + ackDelay: const Duration(hours: 1), + replyDelay: const Duration(hours: 1), + ); + await tester.runAsync(connector.connectReview); + await _waitFor(tester, () => connector.channelMapConfirmed); + final channel = connector.channels.firstWhere((c) => c.index == 1); + final oldId = connector.channelIdForSlot(1); + await tester.runAsync( + () => connector.setChannelCompressionMode(1, ChatCompressionMode.smaz), + ); + + await tester.pumpWidget( + await _app( + tester, + connector, + Builder( + builder: (context) => Scaffold( + body: Center( + child: TextButton( + onPressed: () => + showEditChannelSheet(context, connector, channel), + child: const Text('edit'), + ), + ), + ), + ), + ), + ); + await tester.tap(find.text('edit')); + await _settle(tester); + await tester.enterText(find.byType(TextField).at(1), '0f' * 16); + await tester.tap(find.text(_l10n.common_save)); + // The save runs in the test zone and waits on the radio's real I/O. + for (var i = 0; i < 40; i++) { + await tester.runAsync( + () => Future.delayed(const Duration(milliseconds: 50)), + ); + await tester.pump(const Duration(milliseconds: 100)); + if (find + .text(_l10n.channels_channelUpdated(channel.name)) + .evaluate() + .isNotEmpty) { + break; + } + } + await _settle(tester); + + final newId = connector.channelIdForSlot(1); + expect(newId, isNot(oldId)); + expect(connector.channelCompressionMode(1), ChatCompressionMode.smaz); + final store = ChannelSettingsStore() + ..setPublicKeyHex = connector.selfPublicKeyHex; + expect( + await tester.runAsync(() => store.loadSmazEnabled(newId!)), + isTrue, + ); + + await tester.runAsync(connector.disconnect); + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }); + }); } diff --git a/test/widgets/chat_compression_selector_test.dart b/test/widgets/chat_compression_selector_test.dart new file mode 100644 index 00000000..a3ad6633 --- /dev/null +++ b/test/widgets/chat_compression_selector_test.dart @@ -0,0 +1,313 @@ +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('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); + }); + } +}