Add Czech, in-chat search, typed-hash path trace and contact sharing

- Czech UI locale (app_cs.arb), selectable in the language picker and as a
  message translation language; language names added to every locale.
- Fix wrong language names: Slovak shown as Slovenian in it/ja/pt/sl,
  garbled Slovak/Bulgarian in pl, Ukrainian in ru, Hungarian in ko/zh.
- Search inside DM and channel chats across the full stored history, with
  highlighted matches; filtered channel messages are excluded.
- Path trace by typed hashes (e.g. A1,B2,C3) from the Contacts and map
  menus, without needing node locations; the map trace panel can hand its
  hops to it.
- Share contacts in chats using the official app's <pubkey:type:name>
  format; received cards have a one-tap Add contact button that reuses the
  QR card import path.
- Translations for all new strings in every locale; docs updated.
This commit is contained in:
zjs81 committed 2026-11-07 22:31:14 -07:00
1 parent e57f97616c
commit c939f7a29c
67 files changed
+17245 -381

No files matched your search

@@ -0,0 +1,68 @@
import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/helpers/contact_share_message.dart';
const _hex = '50ba28f599799142622d188469a63f3890d495cdcedd24239052abd364c0283d';
void main() {
test('parses the official example', () {
final s = parseContactShare('<$_hex:1:CC>')!;
expect(s.publicKeyHex, _hex);
expect(s.type, 1);
expect(s.name, 'CC');
expect(s.publicKey.length, 32);
expect(s.shortKey, '50ba28...c0283d');
final scanned = s.toScannedContact();
expect(scanned.publicKey, s.publicKey);
expect(scanned.type, 1);
expect(scanned.name, 'CC');
});
test('round trip', () {
final key = Uint8List.fromList(List.generate(32, (i) => i * 7 % 256));
final text = encodeContactShare(publicKey: key, type: 2, name: ' Hill ');
final s = parseContactShare(text)!;
expect(s.publicKey, key);
expect(s.type, 2);
expect(s.name, 'Hill');
});
test('encode strips angle brackets and newlines', () {
final text = encodeContactShare(
publicKey: Uint8List(32),
type: 1,
name: '<a>\nb\r',
);
expect(parseContactShare(text)!.name, 'ab');
});
test('uppercase hex is accepted and lowercased', () {
final s = parseContactShare('<${_hex.toUpperCase()}:3:Room>')!;
expect(s.publicKeyHex, _hex);
});
test('name may contain colons', () {
expect(parseContactShare('<$_hex:1:a:b:c>')!.name, 'a:b:c');
});
test('surrounding whitespace is ignored', () {
expect(parseContactShare(' \n<$_hex:4:S>\n ')!.type, 4);
});
test('rejects bad length, hex, type', () {
expect(parseContactShare('<${_hex.substring(2)}:1:x>'), isNull);
expect(parseContactShare('<${_hex}00:1:x>'), isNull);
expect(parseContactShare('<${"zz${_hex.substring(2)}"}:1:x>'), isNull);
expect(parseContactShare('<$_hex:0:x>'), isNull);
expect(parseContactShare('<$_hex:5:x>'), isNull);
expect(parseContactShare('<$_hex:12:x>'), isNull);
expect(parseContactShare('<$_hex:a:x>'), isNull);
});
test('token among other words is not a share', () {
expect(parseContactShare('look <$_hex:1:CC> here'), isNull);
expect(parseContactShare('<$_hex:1:CC> hi'), isNull);
expect(parseContactShare('hello'), isNull);
});
}
+59
View File
@@ -0,0 +1,59 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/helpers/message_search.dart';
ChatSearchEntry _e(
String id,
String text, {
String sender = 'Alice',
String? translated,
bool matchSender = false,
int minute = 0,
}) => ChatSearchEntry(
id: id,
sender: sender,
text: text,
translatedText: translated,
time: DateTime(2025, 1, 1, 12, minute),
matchSender: matchSender,
);
void main() {
test('matches case-insensitively', () {
final r = searchEntries([_e('1', 'Hello World')], 'wORLD');
expect(r.map((e) => e.id), ['1']);
});
test('matches translated text', () {
final r = searchEntries([
_e('1', 'hola', translated: 'hello there'),
], 'THERE');
expect(r, hasLength(1));
});
test('sender matches only when matchSender is set', () {
final entries = [
_e('1', 'x', sender: 'Bobby', matchSender: true),
_e('2', 'y', sender: 'Bobby'),
];
expect(searchEntries(entries, 'bob').map((e) => e.id), ['1']);
});
test('results are newest first', () {
final entries = [
_e('1', 'ping', minute: 1),
_e('2', 'nope', minute: 2),
_e('3', 'ping', minute: 3),
];
expect(searchEntries(entries, 'ping').map((e) => e.id), ['3', '1']);
});
test('empty or whitespace query yields no results', () {
final entries = [_e('1', 'anything')];
expect(searchEntries(entries, ''), isEmpty);
expect(searchEntries(entries, ' '), isEmpty);
});
test('query is trimmed', () {
expect(searchEntries([_e('1', 'abc def')], ' def '), hasLength(1));
});
}
+50
View File
@@ -0,0 +1,50 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/helpers/path_trace_input.dart';
void main() {
PathTraceParseResult p(String s, [int w = 1]) =>
PathTraceInputParser.parse(s, w);
test('comma separated, case-insensitive', () {
final r = p('a1,B2,c3').input!;
expect(r.hopWidth, 1);
expect(r.bytes, [0xa1, 0xb2, 0xc3]);
expect(r.hops.length, 3);
});
test('mixed separators and 0x prefixes', () {
final r = p('0xA1 > b2 → 0Xc3/d4\n-e5').input!;
expect(r.bytes, [0xa1, 0xb2, 0xc3, 0xd4, 0xe5]);
});
test('two and three byte hops define width', () {
expect(p('a1b2,c3d4', 1).input!.hopWidth, 2);
final r = p('a1b2c3 d4e5f6', 1).input!;
expect(r.hopWidth, 3);
expect(r.hops.last, [0xd4, 0xe5, 0xf6]);
});
test('continuous string splits by default width', () {
expect(p('a1b2c3d4', 1).input!.hops.length, 4);
expect(p('a1b2c3d4', 2).input!.hops.length, 2);
expect(p('a1b2c3', 3).input!.hopWidth, 3);
expect(p('a1b2c3', 2).error, PathTraceInputError.oddLength);
});
test('errors', () {
expect(p(' ').error, PathTraceInputError.empty);
expect(p('a1,zz').error, PathTraceInputError.invalidHex);
expect(p('a1,b').error, PathTraceInputError.oddLength);
expect(p('abc').error, PathTraceInputError.oddLength);
expect(p('a1,b2c3').error, PathTraceInputError.mixedWidths);
expect(p('a1b2c3d4,e5f6a7b8').error, PathTraceInputError.unsupportedWidth);
});
test('too many hops', () {
final ok = List.filled(64, 'aa').join(',');
expect(p(ok).isValid, isTrue);
expect(p('$ok,bb').error, PathTraceInputError.tooManyHops);
final wide = List.filled(22, 'aabbcc').join(',');
expect(p(wide).error, PathTraceInputError.tooManyHops);
});
}