Merge dev; fix share-location and discovered-contact import/export; update docs

Merge dev (#588 share location, #436 discovered-contact import/export)
into fix/review-fixes-and-issue-batch. Conflicts: keep the node-scan
button alongside dev's import/export menu; take dev's marker label
prompt.

Share location (#588):
- Never share a missing or 0,0 radio position; hide the chat action and
  show "Your radio has no location set"
- Sanitise marker labels ('|' -> '/', newlines -> spaces) on every path
- One shared MarkerLabelDialog owning its controller/focus node, with
  keyboard submit, replacing three copies
- Map pins default to "Point of interest" again; "Share my location"
  uses the node name
- Location shares honour the send cooldown and handle send errors

Discovered-contact import/export (#436):
- Per-entry decoding with imported/skipped/invalid counts; reject keys
  that are not 32 bytes; skip in-file duplicates and the radio's own key
- Strip routing paths on import and stop exporting them; clamp future
  timestamps; enforce the discovered-contact cap; require a connection;
  2 MB file limit
- Export via in-memory XFile (fixes web); pass sharePositionOrigin for
  iPad (also GPX export and image save); macOS user-selected read-write
  entitlement for save dialogs

Docs: cover share location, import/export, node scan, TCP reconnect,
channel auto-resend options, arrival ordering, badge, password length
and image limits.

Translations for all new strings in every locale.
This commit is contained in:
zjs81 committed 2026-10-11 01:54:07 -07:00
commit 5fb67abdde
66 files changed
+3118 -168

No files matched your search

+118 -4
View File
@@ -31,6 +31,7 @@ import '../services/path_history_service.dart';
import '../services/translation_service.dart';
import '../widgets/chat_zoom_wrapper.dart';
import '../widgets/byte_count_input.dart';
import '../widgets/marker_label_dialog.dart';
import '../widgets/chat_day_separator.dart';
import 'channel_message_path_screen.dart';
import 'map_screen.dart';
@@ -491,10 +492,76 @@ class _ChatScreenState extends State<ChatScreen> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
icon: const Icon(Icons.gif_box_outlined),
tooltip: context.l10n.chat_sendGif,
onPressed: () => _showGifPicker(context),
Builder(
builder: (menuContext) {
return IconButton(
icon: const Icon(Icons.add_circle_outline),
tooltip: context.l10n.chat_selectSendAction,
onPressed: () async {
final RenderBox button =
menuContext.findRenderObject() as RenderBox;
final RenderBox overlay =
Overlay.of(menuContext).context.findRenderObject()
as RenderBox;
final Offset buttonOffset = button.localToGlobal(
Offset.zero,
ancestor: overlay,
);
const menuHeight = 2 * kMinInteractiveDimension + 16;
final menuTop = (buttonOffset.dy - menuHeight).clamp(
8.0,
overlay.size.height,
);
final position = RelativeRect.fromLTRB(
buttonOffset.dx,
menuTop,
overlay.size.width -
buttonOffset.dx -
button.size.width,
overlay.size.height - buttonOffset.dy,
);
final selected = await showMenu<String>(
context: menuContext,
position: position,
items: [
PopupMenuItem(
value: 'gif',
child: Row(
children: [
const Icon(Icons.gif_box),
const SizedBox(width: 12),
Text(context.l10n.chat_sendGif),
],
),
),
PopupMenuItem(
value: 'send-my-location',
child: Row(
children: [
const Icon(Icons.my_location),
const SizedBox(width: 12),
Text(context.l10n.chat_shareMyLocation),
],
),
),
],
);
if (!mounted || !menuContext.mounted) return;
if (selected == null) return;
switch (selected) {
case 'gif':
_showGifPicker(context);
break;
case 'send-my-location':
await _shareMyLocation(
context.read<MeshCoreConnector>(),
);
break;
}
},
);
},
),
if (settings.translationEnabled)
MessageTranslationButton(
@@ -667,6 +734,53 @@ class _ChatScreenState extends State<ChatScreen> {
);
}
/// Shares the radio's own position as a map marker. Shares the text send
/// guard and cooldown so it can't race or flood alongside typed messages.
Future<void> _shareMyLocation(MeshCoreConnector connector) async {
final lat = connector.selfLatitude;
final lon = connector.selfLongitude;
if (!hasShareableLocation(lat, lon)) {
showDismissibleSnackBar(
context,
content: Text(context.l10n.chat_noRadioLocation),
);
return;
}
final selfName = connector.selfName;
final label = await showMarkerLabelDialog(
context,
lat: lat!,
lon: lon!,
defaultLabel: selfName != null && selfName.isNotEmpty
? selfName
: context.l10n.map_sharedPin,
flags: 'poi',
confirmText: context.l10n.common_share,
);
if (label == null || label.isEmpty || !mounted || _isSendingText) return;
final now = DateTime.now();
if (_lastTextSendAt != null &&
now.difference(_lastTextSendAt!) < const Duration(seconds: 1)) {
showDismissibleSnackBar(
context,
content: Text(context.l10n.chat_sendCooldown),
);
return;
}
_lastTextSendAt = now;
_isSendingText = true;
try {
await connector.sendMessage(
_resolveContact(connector),
formatMarkerText(lat, lon, label, 'poi'),
);
} catch (e) {
appLogger.warn('Sharing location failed: $e', tag: 'Chat');
} finally {
_isSendingText = false;
}
}
Future<void> _sendMessage(MeshCoreConnector connector) async {
if (_isSendingText) return;
_isSendingText = true;