Tester feedback: routing, bulk select, notifications, map crash

Routing
- Auto routing picks routes by Thompson sampling over faded delivery
  stats (24 h half-life, capped evidence), weighted by what the radio
  currently hears; retries prefer a different route; last attempt floods.
- Route failures are held until a message's fate is known, so an offline
  contact no longer wrecks its route history; failing routes are only
  deleted after a week without a delivery.
- Direct (zero-hop) path is a rotation candidate (#643) and a new Direct
  mode in the routing sheet; history routes are used for repeater logins.
- Remove the route-weight sliders the new chooser no longer uses.

Chats
- Bulk selection in channel chats (spam / not spam / delete / copy) and
  in the Filtered messages list.
- Tapping a search result jumps to the message.
- Swipe-to-reply ignores vertical scrolls.
- Active conversation follows route lifecycle, so covered chats count
  unread again.

Notifications
- Tapping a notification opens its conversation.
- Per-conversation coalescing and one alert per queued-message sync.
- Monochrome status-bar icon; background service stops when the app is
  swiped away; stale notifications cleared on radio or slot change.

Other
- Online map: opaque links and painted dots for dense areas to avoid an
  Impeller GPU crash; expandable hop list on path maps.
- Contact share: clipboard import of shared contacts, "Add again".
- Android: enableEdgeToEdge and scrolling-screenshot support.
- Translations for all new strings; fix mistranslated routing labels.
This commit is contained in:
zjs81 committed 2026-11-08 23:19:15 -07:00
1 parent f81f2686a7
commit 5ea44d6ce9
85 files changed
+6520 -1716

No files matched your search

+47 -35
View File
@@ -14,11 +14,15 @@ class ChatSearchResults extends StatefulWidget {
final Future<List<ChatSearchEntry>> Function() loadEntries;
final double textScale;
/// Tapping a result: the chat closes search and jumps to the message.
final ValueChanged<ChatSearchEntry>? onSelect;
const ChatSearchResults({
super.key,
required this.query,
required this.loadEntries,
this.textScale = 1.0,
this.onSelect,
});
@override
@@ -116,6 +120,9 @@ class _ChatSearchResultsState extends State<ChatSearchResults> {
entry: _results[index],
needle: needle,
textScale: scale,
onTap: widget.onSelect == null
? null
: () => widget.onSelect!(_results[index]),
),
),
),
@@ -128,11 +135,13 @@ class _ResultRow extends StatelessWidget {
final ChatSearchEntry entry;
final String needle;
final double textScale;
final VoidCallback? onTap;
const _ResultRow({
required this.entry,
required this.needle,
required this.textScale,
this.onTap,
});
@override
@@ -145,44 +154,47 @@ class _ResultRow extends StatelessWidget {
: entry.text;
// Show whichever text actually contains the query.
final shown = body.toLowerCase().contains(needle) ? body : entry.text;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: _highlight(
entry.sender,
entry.matchSender ? needle : '',
TextStyle(
fontSize: 14 * s,
fontWeight: FontWeight.w700,
color: scheme.primary,
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: _highlight(
entry.sender,
entry.matchSender ? needle : '',
TextStyle(
fontSize: 14 * s,
fontWeight: FontWeight.w700,
color: scheme.primary,
),
scheme,
),
scheme,
),
),
const SizedBox(width: 8),
Text(
'${formatChatDayLabel(context, entry.time)}, '
'${formatChatTime(context, entry.time)}',
style: TextStyle(
fontSize: 12 * s,
color: scheme.onSurfaceVariant,
const SizedBox(width: 8),
Text(
'${formatChatDayLabel(context, entry.time)}, '
'${formatChatTime(context, entry.time)}',
style: TextStyle(
fontSize: 12 * s,
color: scheme.onSurfaceVariant,
),
),
),
],
),
const SizedBox(height: 4),
_highlight(
shown,
needle,
TextStyle(fontSize: 16 * s, color: scheme.onSurface),
scheme,
),
],
],
),
const SizedBox(height: 4),
_highlight(
shown,
needle,
TextStyle(fontSize: 16 * s, color: scheme.onSurface),
scheme,
),
],
),
),
);
}
+29
View File
@@ -163,6 +163,35 @@ void copyChatMessageText(BuildContext context, String text) {
);
}
/// Asks before deleting [count] selected messages from this device.
Future<bool> confirmBulkDelete(BuildContext context, int count) async {
final result = await showDialog<bool>(
context: context,
builder: (dialogContext) {
final l10n = dialogContext.l10n;
return AlertDialog(
title: Text(l10n.chat_deleteSelectedTitle),
content: Text(l10n.chat_deleteSelectedConfirm(count)),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext, false),
child: Text(l10n.common_cancel),
),
FilledButton(
style: FilledButton.styleFrom(
backgroundColor: Theme.of(dialogContext).colorScheme.error,
foregroundColor: Theme.of(dialogContext).colorScheme.onError,
),
onPressed: () => Navigator.pop(dialogContext, true),
child: Text(l10n.common_delete),
),
],
);
},
);
return result ?? false;
}
/// Asks before clearing a transcript. [message] says what will be erased.
Future<bool> confirmClearChat(
BuildContext context, {
+87 -40
View File
@@ -25,6 +25,9 @@ class NetworkMapOnlineController extends ChangeNotifier {
final NetworkMapApiClient _client;
final LayerHitNotifier<NetworkMapRepeater> hitNotifier = ValueNotifier(null);
final LayerHitNotifier<NetworkMapRepeater> dotHitNotifier = ValueNotifier(
null,
);
List<NetworkMapRepeater> _repeaters = const [];
List<NetworkMapLink> _links = const [];
@@ -98,6 +101,7 @@ class NetworkMapOnlineController extends ChangeNotifier {
_disposed = true;
_timer?.cancel();
hitNotifier.dispose();
dotHitNotifier.dispose();
_client.close();
super.dispose();
}
@@ -117,6 +121,16 @@ const int networkMapDenseNodeCount = 30;
/// Above this many in-view links, each line is one stroke at half width
const int networkMapDenseLinkCount = 70;
/// Above this many in-view repeaters, each is painted as a plain dot in one
/// layer instead of its own marker widget. A zoomed-out view of a dense mesh
/// (e.g. Moscow) holds thousands of repeaters; one widget subtree each was
/// enough to run mid-range phones out of memory and crash the app.
const int networkMapMarkerWidgetLimit = 250;
/// Above this many in-view links, links are not drawn at all until the user
/// zooms in; thousands of overlapping lines are unreadable and costly.
const int networkMapMaxLinkCount = 1500;
/// Full style is a 3.5 px confirmed stroke or a 2.5 px unconfirmed stroke,
/// each with a 1 px border. Simple style keeps the pattern and drops the
/// border, so the painter records the line once, at half the stroke width.
@@ -126,9 +140,13 @@ Polyline _onlineLinkPolyline(NetworkMapLink link, {required bool simple}) {
return Polyline(
points: [link.aCell.center, link.bCell.center],
strokeWidth: simple ? strokeWidth / 2 : strokeWidth,
color: MapPalette.router.withValues(alpha: confirmed ? 0.85 : 0.6),
// Keep links opaque. flutter_map draws a translucent line that also has
// a border through a full-viewport saveLayer, once per line; with dozens
// of links that exhausted GPU memory and crashed the Impeller (Vulkan)
// raster thread in Canvas::DrawLine on Android.
color: MapPalette.router,
borderStrokeWidth: simple ? 0 : 1,
borderColor: MapPalette.markerOutline.withValues(alpha: 0.7),
borderColor: MapPalette.markerOutline,
pattern: confirmed
? const StrokePattern.solid()
: StrokePattern.dashed(segments: const [10, 8]),
@@ -151,12 +169,18 @@ List<Widget> buildNetworkMapOnlineLayers({
final visibleKeys = {for (final repeater in visibleRepeaters) repeater.key};
final links = [
for (final link in controller.links)
if (visibleKeys.contains(link.a) && visibleKeys.contains(link.b)) link,
if (visibleKeys.contains(link.a) &&
visibleKeys.contains(link.b) &&
// Both ends in one cell: a zero-length line draws nothing useful
// and is a degenerate stroke for the renderer.
link.aCell.center != link.bCell.center)
link,
];
final dropHexagons = visibleRepeaters.length > networkMapDenseNodeCount;
final simpleLines = links.length > networkMapDenseLinkCount;
final useDots = visibleRepeaters.length > networkMapMarkerWidgetLimit;
return [
if (showLinks)
if (showLinks && links.length <= networkMapMaxLinkCount)
PolylineLayer(
polylines: [
for (final link in links)
@@ -191,46 +215,69 @@ List<Widget> buildNetworkMapOnlineLayers({
],
),
),
MarkerLayer(
markers: [
for (final repeater in visibleRepeaters)
if (!localMarkerKeys.contains(repeater.key))
Marker(
point: repeater.cell.center,
width: 34,
height: 34,
child: GestureDetector(
onTap: () => onTap(repeater),
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: networkMapStatusColor(repeater.status),
border: Border.all(
color: MapPalette.markerOutline,
width: 2.5,
if (useDots)
GestureDetector(
onTap: () {
final hits = controller.dotHitNotifier.value?.hitValues;
if (hits != null && hits.isNotEmpty) onTap(hits.first);
},
child: CircleLayer<NetworkMapRepeater>(
hitNotifier: controller.dotHitNotifier,
circles: [
for (final repeater in visibleRepeaters)
if (!localMarkerKeys.contains(repeater.key))
CircleMarker<NetworkMapRepeater>(
point: repeater.cell.center,
radius: 7,
color: networkMapStatusColor(repeater.status),
borderColor: MapPalette.markerOutline,
borderStrokeWidth: 1.5,
hitValue: repeater,
),
],
),
)
else
MarkerLayer(
markers: [
for (final repeater in visibleRepeaters)
if (!localMarkerKeys.contains(repeater.key))
Marker(
point: repeater.cell.center,
width: 34,
height: 34,
child: GestureDetector(
onTap: () => onTap(repeater),
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: networkMapStatusColor(repeater.status),
border: Border.all(
color: MapPalette.markerOutline,
width: 2.5,
),
boxShadow: dropHexagons
? null
: const [
BoxShadow(
color: MapPalette.markerShadow,
blurRadius: 6,
offset: Offset(0, 2),
),
],
),
child: Icon(
repeater.type == advTypeRoom
? Icons.meeting_room
: Icons.router,
color: MapPalette.markerOutline,
size: 20,
),
boxShadow: dropHexagons
? null
: const [
BoxShadow(
color: MapPalette.markerShadow,
blurRadius: 6,
offset: Offset(0, 2),
),
],
),
child: Icon(
repeater.type == advTypeRoom
? Icons.meeting_room
: Icons.router,
color: MapPalette.markerOutline,
size: 20,
),
),
),
),
],
),
],
),
];
}
+108 -51
View File
@@ -304,6 +304,11 @@ class PathMapBottomPanel extends StatelessWidget {
final Widget? summary;
final Widget hopList;
/// Grows the panel to the full map height so the hop list is readable when
/// the map is of little use (e.g. repeaters without locations).
final bool expanded;
final VoidCallback? onToggleExpanded;
const PathMapBottomPanel({
super.key,
required this.header,
@@ -322,6 +327,8 @@ class PathMapBottomPanel extends StatelessWidget {
required this.hopRowCount,
required this.summary,
required this.hopList,
this.expanded = false,
this.onToggleExpanded,
});
@override
@@ -330,9 +337,10 @@ class PathMapBottomPanel extends StatelessWidget {
final maxHeight =
MediaQuery.of(context).size.height * (combined ? 0.45 : 0.35);
const hopRowHeight = 60.0;
final isExpanded = expanded && !collapsed && onToggleExpanded != null;
double? cardHeight;
if (!collapsed) {
if (!collapsed && !isExpanded) {
final summaryHeight = combined ? 34.0 + pathCount * 40.0 : 0.0;
final noteHeight = showNoSelfGpsNote ? 22.0 : 0.0;
final estimatedHeight =
@@ -347,6 +355,7 @@ class PathMapBottomPanel extends StatelessWidget {
left: 16,
right: 16,
bottom: 16,
top: isExpanded ? 16 : null,
child: SizedBox(
height: cardHeight,
child: Container(
@@ -380,66 +389,95 @@ class PathMapBottomPanel extends StatelessWidget {
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: max(
0.0,
constraints.maxHeight -
(collapsed ? 0.0 : hopRowHeight + 1.0),
),
maxHeight: isExpanded
? constraints.maxHeight * 0.4
: max(
0.0,
constraints.maxHeight -
(collapsed
? 0.0
: hopRowHeight + 1.0),
),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
12,
8,
4,
0,
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
header,
const SizedBox(height: 4),
PathMiniLegend(
combined: combined,
showInferred:
showInferredLegend,
GestureDetector(
behavior: HitTestBehavior.translucent,
onVerticalDragEnd: (details) =>
_handleHeaderDrag(
details.primaryVelocity ?? 0,
isExpanded,
),
child: Padding(
padding: const EdgeInsets.fromLTRB(
12,
8,
4,
0,
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
header,
const SizedBox(height: 4),
PathMiniLegend(
combined: combined,
showInferred:
showInferredLegend,
),
],
),
),
if (onToggleExpanded != null &&
!collapsed)
IconButton(
icon: Icon(
isExpanded
? Icons.close_fullscreen
: Icons.open_in_full,
),
],
color: MeshPalette.ink,
tooltip: isExpanded
? l10n.pathMap_showMap
: l10n.pathMap_expandHopList,
onPressed: onToggleExpanded,
),
IconButton(
icon: Icon(
collapsed
? Icons.expand_less
: Icons.expand_more,
),
color: MeshPalette.ink,
tooltip: collapsed
? l10n.pathMap_expandPanel
: l10n.pathMap_collapsePanel,
onPressed: onToggleCollapsed,
),
),
IconButton(
icon: Icon(
collapsed
? Icons.expand_less
: Icons.expand_more,
),
color: MeshPalette.ink,
tooltip: collapsed
? l10n.pathMap_expandPanel
: l10n.pathMap_collapsePanel,
onPressed: onToggleCollapsed,
),
],
],
),
),
),
PathAnimationControls(
playback: playback,
selected: selected,
animationEnabled: animationEnabled,
onToggleAnimation: onToggleAnimation,
followEnabled: followEnabled,
onToggleFollow: onToggleFollow,
),
// The map is covered while expanded, so
// the animation controls are pointless.
if (!isExpanded)
PathAnimationControls(
playback: playback,
selected: selected,
animationEnabled: animationEnabled,
onToggleAnimation: onToggleAnimation,
followEnabled: followEnabled,
onToggleFollow: onToggleFollow,
),
if (!collapsed) ...[
if (showNoSelfGpsNote)
Padding(
@@ -503,4 +541,23 @@ class PathMapBottomPanel extends StatelessWidget {
),
);
}
/// Swipe up on the header grows the panel (collapsed -> normal ->
/// expanded); swipe down shrinks it the other way.
void _handleHeaderDrag(double velocity, bool isExpanded) {
const minVelocity = 150.0;
if (velocity < -minVelocity) {
if (collapsed) {
onToggleCollapsed();
} else if (!isExpanded) {
onToggleExpanded?.call();
}
} else if (velocity > minVelocity) {
if (isExpanded) {
onToggleExpanded?.call();
} else if (!collapsed) {
onToggleCollapsed();
}
}
}
}
+90 -39
View File
@@ -12,7 +12,7 @@ import '../screens/path_trace_map.dart';
import '../services/path_history_service.dart';
import 'path_editor_sheet.dart';
enum _RoutingMode { auto, flood, manual }
enum _RoutingMode { auto, flood, direct, manual }
enum _PathQuality { strong, good, fair, proven, flood, untested }
@@ -72,7 +72,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
_RoutingMode _modeOf(Contact contact) {
final override = contact.pathOverride;
if (override == null) return _RoutingMode.auto;
return override < 0 ? _RoutingMode.flood : _RoutingMode.manual;
if (override < 0) return _RoutingMode.flood;
return override == 0 ? _RoutingMode.direct : _RoutingMode.manual;
}
Future<void> _selectMode(
@@ -87,6 +88,13 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
case _RoutingMode.flood:
setState(() => _syncStatus = null);
await connector.setPathOverride(contact, pathLen: -1);
case _RoutingMode.direct:
setState(() => _syncStatus = null);
await connector.setPathOverride(
contact,
pathLen: 0,
pathBytes: Uint8List(0),
);
case _RoutingMode.manual:
await _editManualPath(connector, contact);
}
@@ -224,6 +232,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
return switch (mode) {
_RoutingMode.auto => l10n.routing_modeAutoHint,
_RoutingMode.flood => l10n.routing_modeFloodHint,
_RoutingMode.direct => l10n.routing_modeDirectHint,
_RoutingMode.manual => l10n.routing_modeManualHint,
};
}
@@ -238,6 +247,8 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
switch (mode) {
case _RoutingMode.flood:
return l10n.routing_floodBroadcast;
case _RoutingMode.direct:
return l10n.routing_directNoHops;
case _RoutingMode.manual:
final bytes = contact.pathOverrideBytes ?? Uint8List(0);
if (bytes.isEmpty) return l10n.routing_directNoHops;
@@ -262,7 +273,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
Uint8List _displayBytes(Contact contact, _RoutingMode mode) {
return switch (mode) {
_RoutingMode.flood => Uint8List(0),
_RoutingMode.flood || _RoutingMode.direct => Uint8List(0),
_RoutingMode.manual => contact.pathOverrideBytes ?? Uint8List(0),
_RoutingMode.auto => contact.path,
};
@@ -378,9 +389,11 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
color: scheme.primary,
),
const SizedBox(width: 8),
Text(
l10n.routing_currentRoute,
style: theme.textTheme.titleSmall,
Flexible(
child: Text(
l10n.routing_currentRoute,
style: theme.textTheme.titleSmall,
),
),
],
),
@@ -543,14 +556,24 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
};
final hasBytes = record.pathBytes.isNotEmpty;
final inUse =
hasBytes &&
((mode == _RoutingMode.manual &&
listEquals(record.pathBytes, contact.pathOverrideBytes)) ||
(mode == _RoutingMode.auto &&
listEquals(record.pathBytes, contact.path)));
// A zero-hop record is the direct path: usable even without hop bytes.
final isDirect = !hasBytes && record.hopCount == 0;
final usable = hasBytes || isDirect;
final inUse = isDirect
? mode == _RoutingMode.direct ||
(mode == _RoutingMode.auto && contact.pathLength == 0)
: hasBytes &&
((mode == _RoutingMode.manual &&
listEquals(
record.pathBytes,
contact.pathOverrideBytes,
)) ||
(mode == _RoutingMode.auto &&
listEquals(record.pathBytes, contact.path)));
final title = hasBytes
final title = isDirect
? l10n.routing_directNoHops
: hasBytes
? PathHelper.resolvePathNames(
record.pathBytes,
connector.allContacts,
@@ -583,7 +606,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
child: Card(
margin: const EdgeInsets.symmetric(vertical: 4),
child: ListTile(
enabled: hasBytes,
enabled: usable,
leading: CircleAvatar(
radius: 18,
backgroundColor: bg,
@@ -623,7 +646,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
),
],
),
onTap: hasBytes && !inUse
onTap: usable && !inUse
? () => _applyHistoryPath(connector, contact, record)
: null,
onLongPress: hasBytes
@@ -698,30 +721,58 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
),
),
const SizedBox(height: 16),
SegmentedButton<_RoutingMode>(
style: const ButtonStyle(
minimumSize: WidgetStatePropertyAll(Size.fromHeight(44)),
),
segments: [
ButtonSegment(
value: _RoutingMode.auto,
icon: const Icon(Icons.auto_mode),
label: Text(l10n.routing_modeAuto),
),
ButtonSegment(
value: _RoutingMode.flood,
icon: const Icon(Icons.waves),
label: Text(l10n.routing_modeFlood),
),
ButtonSegment(
value: _RoutingMode.manual,
icon: const Icon(Icons.edit_road),
label: Text(l10n.routing_modeManual),
),
],
selected: {mode},
onSelectionChanged: (selection) =>
_selectMode(connector, contact, selection.first),
LayoutBuilder(
builder: (context, constraints) {
// Four modes share one row: on phones drop the icons and let
// labels shrink rather than clip, so every word stays whole.
final showIcons = constraints.maxWidth >= 480;
ButtonSegment<_RoutingMode> segment(
_RoutingMode value,
IconData icon,
String label,
) => ButtonSegment(
value: value,
icon: showIcons ? Icon(icon) : null,
label: FittedBox(
fit: BoxFit.scaleDown,
child: Text(label, maxLines: 1, softWrap: false),
),
);
return SegmentedButton<_RoutingMode>(
showSelectedIcon: false,
style: const ButtonStyle(
minimumSize: WidgetStatePropertyAll(Size.fromHeight(48)),
padding: WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 6),
),
),
segments: [
segment(
_RoutingMode.auto,
Icons.auto_mode,
l10n.routing_modeAuto,
),
segment(
_RoutingMode.flood,
Icons.waves,
l10n.routing_modeFlood,
),
segment(
_RoutingMode.direct,
Icons.near_me,
l10n.routing_modeDirect,
),
segment(
_RoutingMode.manual,
Icons.edit_road,
l10n.routing_modeManual,
),
],
selected: {mode},
onSelectionChanged: (selection) =>
_selectMode(connector, contact, selection.first),
);
},
),
const SizedBox(height: 8),
Text(
+28 -1
View File
@@ -82,7 +82,34 @@ class _SharedContactCardState extends State<SharedContactCard> {
if (isSelf) {
action = _status(Icons.person_outline, l10n.contactShare_isYou);
} else if (isSaved) {
action = _status(Icons.check_circle_outline, l10n.contactShare_saved);
// Still offer a re-add: the app's list can lag the radio (e.g. the
// contact was dropped on the radio or by another client), and adding
// again just refreshes an existing entry.
action = Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8,
children: [
_status(Icons.check_circle_outline, l10n.contactShare_saved),
TextButton(
onPressed: connector.isConnected && !_adding
? () => _add(connector)
: null,
style: TextButton.styleFrom(
foregroundColor: widget.textColor,
minimumSize: const Size(48, 48),
),
child: Text(
_adding ? l10n.contactShare_adding : l10n.contactShare_addAgain,
style: TextStyle(
fontSize: 14 * scale,
fontWeight: FontWeight.w600,
decoration: TextDecoration.underline,
decorationColor: widget.textColor,
),
),
),
],
);
} else {
action = SizedBox(
width: double.infinity,