Merge upstream/dev: Android Auto as opt-in flavor, decluttered map overlay
build / build (push) Failing after 3m2s
build / build (push) Failing after 3m2s
Conflicts: the manifest keeps our unread widget receiver and drops the Android Auto meta-data, which upstream moved to the androidAuto source set (fe7e72a). Rename detection had moved our unread_widget_info.xml into that source set with it; it stays in main. _mapChip is gone upstream with the map overlay declutter (ed5884e), so our terminal-theme restyle of it goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
9489dee1c3
114 files changed
+11506
-1027
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/app_settings_service.dart'
|
||||
show AppSettingsService, ChannelNotificationMode;
|
||||
import 'mesh_ui.dart';
|
||||
|
||||
/// Localized label for a channel notification [mode].
|
||||
String channelNotificationModeLabel(
|
||||
BuildContext context,
|
||||
ChannelNotificationMode mode,
|
||||
) => switch (mode) {
|
||||
ChannelNotificationMode.all => context.l10n.channels_notifyAll,
|
||||
ChannelNotificationMode.mentionsOnly =>
|
||||
context.l10n.channels_notifyMentionsOnly,
|
||||
ChannelNotificationMode.muted => context.l10n.channels_notifyNone,
|
||||
};
|
||||
|
||||
/// Icon for a channel notification [mode].
|
||||
IconData channelNotificationModeIcon(ChannelNotificationMode mode) =>
|
||||
switch (mode) {
|
||||
ChannelNotificationMode.all => Icons.notifications,
|
||||
ChannelNotificationMode.mentionsOnly => Icons.notification_important,
|
||||
ChannelNotificationMode.muted => Icons.notifications_off,
|
||||
};
|
||||
|
||||
/// Shows the per-channel notification mode picker (all / mentions only /
|
||||
/// muted) for the channel identified by [muteKey].
|
||||
void showChannelNotificationModeSheet(BuildContext context, String muteKey) {
|
||||
final settingsService = context.read<AppSettingsService>();
|
||||
final currentMode = settingsService.getChannelNotificationMode(muteKey);
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (sheetContext) {
|
||||
final scheme = Theme.of(sheetContext).colorScheme;
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final mode in ChannelNotificationMode.values)
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
channelNotificationModeIcon(mode),
|
||||
color: mode == currentMode
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
title: Text(channelNotificationModeLabel(sheetContext, mode)),
|
||||
trailing: mode == currentMode ? const Icon(Icons.check) : null,
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
await settingsService.setChannelNotificationMode(
|
||||
muteKey,
|
||||
mode,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import '../theme/terminal_theme.dart';
|
||||
import 'byte_count_input.dart';
|
||||
import 'gif_message.dart';
|
||||
import 'gif_picker.dart';
|
||||
import 'mesh_ui.dart';
|
||||
import 'message_translation_button.dart';
|
||||
|
||||
/// One entry of the composer's "+" menu.
|
||||
@@ -28,9 +29,8 @@ class ChatComposerAction {
|
||||
|
||||
/// Opens the GIF picker and puts the chosen GIF into [controller].
|
||||
void showChatGifPicker(BuildContext context, TextEditingController controller) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showMeshSheet<void>(
|
||||
context,
|
||||
builder: (context) => GifPicker(
|
||||
onGifSelected: (gifId) {
|
||||
controller.text = GifHelper.encodeGif(gifId);
|
||||
|
||||
@@ -210,12 +210,8 @@ class EmojiPicker extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final emojiCategories = _emojiCategories(l10n);
|
||||
return Container(
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
|
||||
@@ -2,25 +2,42 @@ import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/node_banner_service.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
|
||||
/// Affiliate link for the SenseCAP MeshTracker X1.
|
||||
const getNodeUrl =
|
||||
'https://www.seeedstudio.com/sensecap-meshtracker-x1-meshtastic-gps-tracker-p-6935.html'
|
||||
'?sensecap_affiliate=JFWID0g&referring_service=link';
|
||||
|
||||
/// Bottom banner on the connect screen pointing new users at a node to buy.
|
||||
class GetNodeBanner extends StatelessWidget {
|
||||
const GetNodeBanner({super.key});
|
||||
/// Its link (and optionally its text) comes from the `_banner` DNS TXT
|
||||
/// record; it stays hidden until that loads, and when the lookup fails or the
|
||||
/// record turns it off.
|
||||
class GetNodeBanner extends StatefulWidget {
|
||||
final Future<NodeBannerConfig?> Function()? loadConfig;
|
||||
|
||||
void _open() =>
|
||||
launchUrl(Uri.parse(getNodeUrl), mode: LaunchMode.externalApplication);
|
||||
const GetNodeBanner({super.key, this.loadConfig});
|
||||
|
||||
@override
|
||||
State<GetNodeBanner> createState() => _GetNodeBannerState();
|
||||
}
|
||||
|
||||
class _GetNodeBannerState extends State<GetNodeBanner> {
|
||||
NodeBannerConfig? _config;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
(widget.loadConfig ?? NodeBannerService().load)().then((config) {
|
||||
if (mounted && config != null) setState(() => _config = config);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final config = _config;
|
||||
if (config == null) return const SizedBox.shrink();
|
||||
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
void open() => launchUrl(config.url, mode: LaunchMode.externalApplication);
|
||||
|
||||
return SafeArea(
|
||||
top: false,
|
||||
@@ -34,7 +51,7 @@ class GetNodeBanner extends StatelessWidget {
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
onTap: _open,
|
||||
onTap: open,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 10),
|
||||
child: Column(
|
||||
@@ -51,7 +68,7 @@ class GetNodeBanner extends StatelessWidget {
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.scanner_getNodeTitle,
|
||||
config.title ?? l10n.scanner_getNodeTitle,
|
||||
style: textTheme.titleMedium?.copyWith(
|
||||
color: scheme.onPrimaryContainer,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -62,7 +79,7 @@ class GetNodeBanner extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
l10n.scanner_getNodeBody,
|
||||
config.body ?? l10n.scanner_getNodeBody,
|
||||
style: textTheme.bodyMedium?.copyWith(
|
||||
color: scheme.onPrimaryContainer,
|
||||
height: 1.35,
|
||||
@@ -72,9 +89,9 @@ class GetNodeBanner extends StatelessWidget {
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton.icon(
|
||||
onPressed: _open,
|
||||
onPressed: open,
|
||||
icon: const Icon(Icons.shopping_cart_outlined, size: 22),
|
||||
label: Text(l10n.scanner_getNodeAction),
|
||||
label: Text(config.action ?? l10n.scanner_getNodeAction),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
@@ -117,7 +117,9 @@ class _GifPickerState extends State<GifPicker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height * 0.7,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.7,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../connector/meshcore_protocol.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../l10n/contact_localization.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../screens/chat_screen.dart';
|
||||
import '../screens/repeater_hub_screen.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import 'mesh_ui.dart';
|
||||
import 'repeater_login_dialog.dart';
|
||||
import 'room_login_dialog.dart';
|
||||
|
||||
/// Map accent colour for a node type.
|
||||
Color mapNodeTypeColor(int type) {
|
||||
switch (type) {
|
||||
case advTypeChat:
|
||||
return MapPalette.selected;
|
||||
case advTypeRepeater:
|
||||
return MapPalette.repeater;
|
||||
case advTypeRoom:
|
||||
return MapPalette.router;
|
||||
case advTypeSensor:
|
||||
return MapPalette.sensor;
|
||||
default:
|
||||
return MapPalette.offline;
|
||||
}
|
||||
}
|
||||
|
||||
/// Map icon for a node type.
|
||||
IconData mapNodeTypeIcon(int type) {
|
||||
switch (type) {
|
||||
case advTypeChat:
|
||||
return Icons.person;
|
||||
case advTypeRepeater:
|
||||
return Icons.router;
|
||||
case advTypeRoom:
|
||||
return Icons.meeting_room;
|
||||
case advTypeSensor:
|
||||
return Icons.sensors;
|
||||
default:
|
||||
return Icons.device_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
String formatNodeLastSeen(AppLocalizations l10n, DateTime lastSeen) {
|
||||
final difference = DateTime.now().difference(lastSeen);
|
||||
if (difference.inSeconds < 60) {
|
||||
return l10n.time_justNow;
|
||||
} else if (difference.inMinutes < 60) {
|
||||
return l10n.time_minutesAgo(difference.inMinutes);
|
||||
} else if (difference.inHours < 24) {
|
||||
return l10n.time_hoursAgo(difference.inHours);
|
||||
} else {
|
||||
return l10n.time_daysAgo(difference.inDays);
|
||||
}
|
||||
}
|
||||
|
||||
/// Label above a selectable mono value, as used in node detail sheets.
|
||||
class NodeInfoRow extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
const NodeInfoRow({super.key, required this.label, required this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
SelectableText(
|
||||
value,
|
||||
style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Repeater login, then the repeater hub on success.
|
||||
void showRepeaterLoginDialog(BuildContext context, Contact repeater) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RepeaterLoginDialog(
|
||||
repeater: repeater,
|
||||
onLogin: (password, isAdmin) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RepeaterHubScreen(
|
||||
repeater: repeater,
|
||||
password: password,
|
||||
isAdmin: isAdmin,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Room login, then the room chat (or the hub when [manage] is set).
|
||||
void showRoomLoginDialog(
|
||||
BuildContext context,
|
||||
Contact room, {
|
||||
bool manage = false,
|
||||
}) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RoomLoginDialog(
|
||||
room: room,
|
||||
onLogin: (password, isAdmin) {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final unread = connector.getUnreadCountForContactKey(room.publicKeyHex);
|
||||
connector.markContactRead(room.publicKeyHex);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => manage
|
||||
? RepeaterHubScreen(
|
||||
repeater: room,
|
||||
password: password,
|
||||
isAdmin: isAdmin,
|
||||
)
|
||||
: ChatScreen(contact: room, initialUnreadCount: unread),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Node details sheet (path, location, last seen, key) with the actions for
|
||||
/// its type: open chat, manage repeater, or join/manage room.
|
||||
void showNodeInfoSheet(
|
||||
BuildContext context,
|
||||
Contact contact, {
|
||||
LatLng? guessedPosition,
|
||||
}) {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (sheetContext) {
|
||||
final l10n = context.l10n;
|
||||
void importIfNeeded() {
|
||||
if (!contact.isActive) {
|
||||
connector.importDiscoveredContact(contact);
|
||||
}
|
||||
}
|
||||
|
||||
final actions = <Widget>[];
|
||||
if (contact.type == advTypeChat) {
|
||||
actions.add(
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
importIfNeeded();
|
||||
final unread = connector.getUnreadCountForContactKey(
|
||||
contact.publicKeyHex,
|
||||
);
|
||||
Navigator.pop(sheetContext);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ChatScreen(contact: contact, initialUnreadCount: unread),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text(l10n.contacts_openChat),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (contact.type == advTypeRepeater) {
|
||||
actions.add(
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
importIfNeeded();
|
||||
Navigator.pop(sheetContext);
|
||||
showRepeaterLoginDialog(context, contact);
|
||||
},
|
||||
child: Text(l10n.map_manageRepeater),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (contact.type == advTypeRoom) {
|
||||
actions.add(
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
importIfNeeded();
|
||||
Navigator.pop(sheetContext);
|
||||
showRoomLoginDialog(context, contact);
|
||||
},
|
||||
child: Text(l10n.map_joinRoom),
|
||||
),
|
||||
);
|
||||
actions.add(
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
importIfNeeded();
|
||||
Navigator.pop(sheetContext);
|
||||
showRoomLoginDialog(context, contact, manage: true);
|
||||
},
|
||||
child: Text(l10n.map_manageServer),
|
||||
),
|
||||
);
|
||||
}
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BottomSheetHeader(
|
||||
title: contact.name,
|
||||
subtitle: contact.typeLabel(l10n),
|
||||
trailing: Icon(
|
||||
mapNodeTypeIcon(contact.type),
|
||||
color: mapNodeTypeColor(contact.type),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
NodeInfoRow(
|
||||
label: l10n.map_path,
|
||||
value: contact.pathLabel(
|
||||
l10n,
|
||||
pathHashByteWidth: connector.pathHashByteWidth,
|
||||
),
|
||||
),
|
||||
if (contact.hasLocation)
|
||||
NodeInfoRow(
|
||||
label: l10n.map_location,
|
||||
value:
|
||||
'${contact.latitude!.toStringAsFixed(6)}, ${contact.longitude!.toStringAsFixed(6)}',
|
||||
)
|
||||
else if (guessedPosition != null)
|
||||
NodeInfoRow(
|
||||
label: l10n.map_estLocation,
|
||||
value:
|
||||
'~${guessedPosition.latitude.toStringAsFixed(6)}, ${guessedPosition.longitude.toStringAsFixed(6)}',
|
||||
),
|
||||
NodeInfoRow(
|
||||
label: l10n.map_lastSeen,
|
||||
value: formatNodeLastSeen(l10n, contact.lastSeen),
|
||||
),
|
||||
NodeInfoRow(
|
||||
label: l10n.map_publicKey,
|
||||
value: contact.publicKeyHex,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
...actions,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -30,9 +30,9 @@ bool _isAllowedRepeatFreqKHz(MeshCoreConnector connector, int freqKHz) {
|
||||
/// Lowest TX power companion firmware accepts (CMD_SET_RADIO_TX_POWER).
|
||||
const int _minTxPowerDbm = -9;
|
||||
|
||||
/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power and
|
||||
/// off-grid client repeat). Stays open when the radio rejects or fails to
|
||||
/// apply the settings so the user's edits are not lost.
|
||||
/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power,
|
||||
/// path-hash size and off-grid client repeat). Stays open when the radio
|
||||
/// rejects or fails to apply the settings so the user's edits are not lost.
|
||||
class RadioSettingsDialog extends StatefulWidget {
|
||||
final MeshCoreConnector connector;
|
||||
|
||||
@@ -49,11 +49,14 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
LoRaCodingRate _codingRate = LoRaCodingRate.cr4_5;
|
||||
final _txPowerController = TextEditingController(text: '20');
|
||||
bool _clientRepeat = false;
|
||||
int _pathHashByteWidth = 1;
|
||||
int? _selectedPresetIndex;
|
||||
_RadioSettingsSnapshot? _lastNonRepeatSnapshot;
|
||||
String? _frequencyError;
|
||||
String? _txPowerError;
|
||||
|
||||
bool get _supportsPathHashMode => widget.connector.supportsPathHashMode;
|
||||
|
||||
AppDebugLogService get _appLog =>
|
||||
Provider.of<AppDebugLogService>(context, listen: false);
|
||||
|
||||
@@ -106,6 +109,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
_txPowerController.text = widget.connector.currentTxPower.toString();
|
||||
}
|
||||
|
||||
_pathHashByteWidth = widget.connector.pathHashByteWidth;
|
||||
_clientRepeat = widget.connector.clientRepeat ?? false;
|
||||
_selectedPresetIndex = _findMatchingPresetIndex();
|
||||
if (_clientRepeat) {
|
||||
@@ -439,11 +443,34 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
return;
|
||||
}
|
||||
await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower));
|
||||
// setPathHashMode updates the local width optimistically; the refreshed
|
||||
// DEVICE_INFO below overwrites it with what the radio actually stored.
|
||||
final requestedPathHashWidth =
|
||||
_supportsPathHashMode &&
|
||||
_pathHashByteWidth != widget.connector.pathHashByteWidth
|
||||
? _pathHashByteWidth
|
||||
: null;
|
||||
if (requestedPathHashWidth != null) {
|
||||
await widget.connector.setPathHashMode(requestedPathHashWidth - 1);
|
||||
}
|
||||
final selfInfo = widget.connector.receivedFrames
|
||||
.firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo)
|
||||
.timeout(const Duration(seconds: 5));
|
||||
final deviceInfo = requestedPathHashWidth == null
|
||||
? null
|
||||
: widget.connector.receivedFrames
|
||||
.firstWhere((f) => f.isNotEmpty && f[0] == respCodeDeviceInfo)
|
||||
.timeout(const Duration(seconds: 5));
|
||||
await widget.connector.refreshDeviceInfo();
|
||||
final applied = await selfInfo.then(
|
||||
// Without a refreshed DEVICE_INFO the path hash change is unconfirmed
|
||||
// (this also covers setPathHashMode skipping a disconnected radio).
|
||||
final pathHashApplied =
|
||||
deviceInfo == null ||
|
||||
await deviceInfo.then(
|
||||
(_) => widget.connector.pathHashByteWidth == requestedPathHashWidth,
|
||||
onError: (_) => false,
|
||||
);
|
||||
final radioApplied = await selfInfo.then(
|
||||
(_) => _deviceMatches(
|
||||
freqHz: freqHz,
|
||||
bwHz: bwHz,
|
||||
@@ -454,7 +481,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
),
|
||||
onError: (_) => true,
|
||||
);
|
||||
if (!applied) {
|
||||
if (!radioApplied) {
|
||||
_logRadioSettingsState('Radio did not apply requested settings');
|
||||
if (!mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
@@ -463,6 +490,17 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!pathHashApplied) {
|
||||
// Radio params and TX power were already applied; only the path
|
||||
// hash size is outstanding, so say that rather than a generic error.
|
||||
_logRadioSettingsState('Radio did not apply requested path hash size');
|
||||
if (!mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(l10n.settings_pathHashModeNotApplied),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final rememberedSnapshot = _clientRepeat
|
||||
? _lastNonRepeatSnapshot
|
||||
: _currentSnapshot();
|
||||
@@ -539,6 +577,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
'sf=${_spreadingFactor.label} '
|
||||
'cr=${_codingRate.label} '
|
||||
'tx=${_txPowerController.text}dBm '
|
||||
'pathHash=${_pathHashByteWidth}B '
|
||||
'repeat=$_clientRepeat '
|
||||
'preset=${_presetLabel(_selectedPresetIndex)} '
|
||||
'lastNonRepeat=${_formatSnapshot(_lastNonRepeatSnapshot)}',
|
||||
@@ -673,6 +712,41 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (_supportsPathHashMode) ...[
|
||||
// Values are path hash modes (0-2, byte width - 1), matching
|
||||
// the selectors in settings_screen and repeater_settings_screen.
|
||||
DropdownButtonFormField<int>(
|
||||
initialValue: (_pathHashByteWidth - 1).clamp(0, 2).toInt(),
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.repeater_pathHashMode,
|
||||
helperText: l10n.settings_pathHashModeHelper,
|
||||
helperMaxLines: 5,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: 0,
|
||||
child: Text(l10n.repeater_pathHashModeOption0),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 1,
|
||||
child: Text(l10n.repeater_pathHashModeOption1),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 2,
|
||||
child: Text(l10n.repeater_pathHashModeOption2),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
setState(() => _pathHashByteWidth = value + 1);
|
||||
_logRadioSettingsState(
|
||||
'Manual settings edit: path hash size',
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
TextField(
|
||||
controller: _txPowerController,
|
||||
onChanged: (_) => _handleManualSettingsChanged('tx power'),
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
|
||||
/// Asks the user to confirm, then sets the radio's advertised location to
|
||||
/// [position] and waits for SELF_INFO to report it. Shows a success or
|
||||
/// failure snackbar and returns whether the radio confirmed the new location.
|
||||
Future<bool> confirmAndSetMyLocation(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
LatLng position,
|
||||
) async {
|
||||
if (!connector.isConnected) return false;
|
||||
final l10n = context.l10n;
|
||||
final latText = position.latitude.toStringAsFixed(6);
|
||||
final lonText = position.longitude.toStringAsFixed(6);
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(l10n.map_setLocationConfirmTitle),
|
||||
content: Text(l10n.map_setLocationConfirmBody(latText, lonText)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: Text(l10n.common_cancel),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: Text(l10n.map_setLocationAction),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed != true || !context.mounted || !connector.isConnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The firmware stores coordinates as int32 micro-degrees.
|
||||
bool matches() {
|
||||
final lat = connector.selfLatitude;
|
||||
final lon = connector.selfLongitude;
|
||||
return lat != null &&
|
||||
lon != null &&
|
||||
(lat - position.latitude).abs() < 2e-6 &&
|
||||
(lon - position.longitude).abs() < 2e-6;
|
||||
}
|
||||
|
||||
var ok = false;
|
||||
try {
|
||||
await connector.setNodeLocation(
|
||||
lat: position.latitude,
|
||||
lon: position.longitude,
|
||||
);
|
||||
await connector.refreshDeviceInfo();
|
||||
// Self info arrives asynchronously after the query; wait for it.
|
||||
final deadline = DateTime.now().add(const Duration(seconds: 6));
|
||||
while (context.mounted && connector.isConnected) {
|
||||
if (matches()) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
if (DateTime.now().isAfter(deadline)) break;
|
||||
await Future<void>.delayed(const Duration(milliseconds: 250));
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Set node location failed: $e');
|
||||
}
|
||||
if (!context.mounted) return ok;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
ok ? l10n.map_locationSetSuccess : l10n.map_locationSetFailed,
|
||||
),
|
||||
);
|
||||
return ok;
|
||||
}
|
||||
+126
-40
@@ -9,6 +9,7 @@ import '../l10n/l10n.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import 'mesh_ui.dart';
|
||||
import 'node_info_sheet.dart';
|
||||
import 'signal_ui.dart';
|
||||
|
||||
Contact? _getRepeaterPrefixMatchNearLocation(
|
||||
@@ -276,53 +277,77 @@ class _SNRIndicatorState extends State<SNRIndicator> {
|
||||
);
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarCircle(
|
||||
name: name ?? prefixLabel,
|
||||
size: 36,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Semantics(
|
||||
button: true,
|
||||
hint: l10n.map_details,
|
||||
child: InkWell(
|
||||
onTap: () => contact != null
|
||||
? showNodeInfoSheet(context, contact)
|
||||
: _showUnknownRepeaterSheet(
|
||||
context,
|
||||
repeater,
|
||||
prefixLabel,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 56),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
name ?? prefixLabel,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
AvatarCircle(
|
||||
name: name ?? prefixLabel,
|
||||
size: 36,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.circle,
|
||||
size: 8,
|
||||
color: snrColor,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'${repeater.snr.toStringAsFixed(1)} dB • ${_formatLastUpdated(repeater.lastUpdated)}',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
name ?? prefixLabel,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.circle,
|
||||
size: 8,
|
||||
color: snrColor,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'${repeater.snr.toStringAsFixed(1)} dB • ${_formatLastUpdated(repeater.lastUpdated)}',
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: colorScheme
|
||||
.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
size: 24,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -341,4 +366,65 @@ class _SNRIndicatorState extends State<SNRIndicator> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showUnknownRepeaterSheet(
|
||||
BuildContext context,
|
||||
DirectRepeater repeater,
|
||||
String prefixLabel,
|
||||
) {
|
||||
showMeshSheet<void>(
|
||||
context,
|
||||
builder: (sheetContext) {
|
||||
final l10n = sheetContext.l10n;
|
||||
final scheme = Theme.of(sheetContext).colorScheme;
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BottomSheetHeader(
|
||||
title: prefixLabel,
|
||||
subtitle: l10n.snrIndicator_unknownRepeater,
|
||||
trailing: Icon(
|
||||
mapNodeTypeIcon(advTypeRepeater),
|
||||
color: mapNodeTypeColor(advTypeRepeater),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
NodeInfoRow(
|
||||
label: l10n.map_publicKeyPrefix,
|
||||
value: repeater.pubkeyPrefixHex,
|
||||
),
|
||||
NodeInfoRow(
|
||||
label: l10n.repeater_lastSnr,
|
||||
value: '${repeater.snr.toStringAsFixed(1)} dB',
|
||||
),
|
||||
NodeInfoRow(
|
||||
label: l10n.map_lastSeen,
|
||||
value: formatNodeLastSeen(l10n, repeater.lastUpdated),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
l10n.snrIndicator_unknownRepeaterHint,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user