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:
commit
5fb67abdde
66 files changed
+3118
-168
No files matched your search
+11
-67
@@ -28,6 +28,7 @@ import '../utils/contact_search.dart';
|
||||
import '../utils/disconnect_navigation_mixin.dart';
|
||||
import '../utils/battery_utils.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../widgets/marker_label_dialog.dart';
|
||||
import '../widgets/quick_switch_bar.dart';
|
||||
import '../widgets/sync_progress_overlay.dart';
|
||||
import '../icons/los_icon.dart';
|
||||
@@ -3120,21 +3121,15 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
return;
|
||||
}
|
||||
|
||||
// The whole `m:lat,lon|label|flags` text must fit in one message to
|
||||
// either a contact or a channel, so the label gets what's left.
|
||||
final maxMessageBytes = min(
|
||||
maxContactMessageBytes(),
|
||||
maxChannelMessageBytes(connector.selfName),
|
||||
);
|
||||
final label = await _promptForLabel(
|
||||
// A map point is not the user's own position, so it keeps the point's
|
||||
// default label; reusing one label would move earlier shared points.
|
||||
final label = await showMarkerLabelDialog(
|
||||
context,
|
||||
defaultLabel,
|
||||
maxBytes: maxMessageBytes,
|
||||
encode: (text) => _formatMarkerMessage(
|
||||
position,
|
||||
text.trim().replaceAll('|', '/'),
|
||||
flags,
|
||||
),
|
||||
lat: position.latitude,
|
||||
lon: position.longitude,
|
||||
defaultLabel: defaultLabel,
|
||||
flags: flags,
|
||||
confirmText: context.l10n.common_continue,
|
||||
);
|
||||
if (label == null || !mounted) return;
|
||||
|
||||
@@ -3149,53 +3144,6 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
);
|
||||
}
|
||||
|
||||
Future<String?> _promptForLabel(
|
||||
BuildContext context,
|
||||
String defaultLabel, {
|
||||
required int maxBytes,
|
||||
required String Function(String label) encode,
|
||||
}) async {
|
||||
final fixedBytes = utf8ByteLength(encode(''));
|
||||
final fittedDefault = truncateUtf8(defaultLabel, maxBytes - fixedBytes);
|
||||
final controller = TextEditingController(text: fittedDefault);
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: controller.text.length,
|
||||
);
|
||||
return showDialog<String>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(context.l10n.map_pinLabel),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
hintText: context.l10n.map_label,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
inputFormatters: [
|
||||
Utf8LengthLimitingTextInputFormatter(maxBytes, encoder: encode),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
final label = controller.text.trim().replaceAll('|', '/');
|
||||
Navigator.pop(
|
||||
dialogContext,
|
||||
label.isEmpty ? fittedDefault : label,
|
||||
);
|
||||
},
|
||||
child: Text(context.l10n.common_continue),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool _markerFits(BuildContext context, String markerText, int maxBytes) {
|
||||
if (utf8ByteLength(markerText) <= maxBytes) return true;
|
||||
showDismissibleSnackBar(
|
||||
@@ -3205,11 +3153,8 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
||||
return false;
|
||||
}
|
||||
|
||||
String _formatMarkerMessage(LatLng position, String label, String flags) {
|
||||
final lat = position.latitude.toStringAsFixed(6);
|
||||
final lon = position.longitude.toStringAsFixed(6);
|
||||
return 'm:$lat,$lon|$label|$flags';
|
||||
}
|
||||
String _formatMarkerMessage(LatLng position, String label, String flags) =>
|
||||
formatMarkerText(position.latitude, position.longitude, label, flags);
|
||||
|
||||
Future<void> _showRecipientSheet({
|
||||
required BuildContext context,
|
||||
@@ -3915,7 +3860,6 @@ int _mapContactSignature(Contact contact) {
|
||||
contact.lastSeen.millisecondsSinceEpoch,
|
||||
contact.lastMessageAt.millisecondsSinceEpoch,
|
||||
contact.isActive,
|
||||
contact.wasPulled,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user