Add opt-in network map uploads and online map view

- Opt-in upload of header-only packet records and repeater/room server
  adverts to map.meshcoreopen.org about once a minute; payloads, channel
  and DM hashes and transport codes are stripped on the phone, locations
  snapped to a ~2 km grid, install ID rotates daily
- One-time opt-in dialog on first radio connection; toggle and status in
  App settings
- Local / Online / Both switch on the map screen with online repeater
  hexagons, links, add-to-contacts and manage
- Node purchase banner on the connect screen (affiliate link, disclosed)
- Privacy policy and network map documentation
- Translations for all locales
This commit is contained in:
zjs81 committed 2026-10-11 21:54:16 -07:00
1 parent d30744aa31
commit bc14de586f
68 files changed
+6719 -76

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/l10n/app_localizations.dart';
import 'package:meshcore_open/widgets/get_node_banner.dart';
void main() {
Future<void> pumpBanner(
WidgetTester tester, {
required Size size,
required double textScale,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: MediaQuery(
data: MediaQueryData(
size: size,
textScaler: TextScaler.linear(textScale),
),
child: const Scaffold(bottomNavigationBar: GetNodeBanner()),
),
),
);
}
testWidgets('shows the pitch and affiliate link', (tester) async {
await pumpBanner(tester, size: const Size(390, 844), textScale: 1);
expect(find.text('Need a new node?'), findsOneWidget);
expect(find.text('Get one here'), findsOneWidget);
expect(find.textContaining('Affiliate link'), findsOneWidget);
expect(getNodeUrl, contains('sensecap_affiliate=JFWID0g'));
// Leaves most of the screen for the device list.
expect(
tester.getSize(find.byType(GetNodeBanner)).height,
lessThan(844 * 0.4),
);
});
testWidgets('lays out on a narrow phone with large text', (tester) async {
await pumpBanner(tester, size: const Size(320, 800), textScale: 1.5);
expect(tester.takeException(), isNull);
});
}
@@ -0,0 +1,99 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/connector/meshcore_connector.dart';
import 'package:meshcore_open/l10n/app_localizations.dart';
import 'package:meshcore_open/services/app_settings_service.dart';
import 'package:meshcore_open/storage/prefs_manager.dart';
import 'package:meshcore_open/widgets/network_map_opt_in_dialog.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class _ConnectedConnector extends MeshCoreConnector {
@override
bool get isConnected => true;
}
void main() {
late AppSettingsService settings;
late MeshCoreConnector connector;
setUp(() async {
SharedPreferences.setMockInitialValues({});
PrefsManager.reset();
await PrefsManager.initialize();
settings = AppSettingsService();
await settings.loadSettings();
connector = _ConnectedConnector();
});
tearDown(() => connector.dispose());
Future<void> pumpHost(WidgetTester tester) async {
await tester.pumpWidget(
MultiProvider(
providers: [
ChangeNotifierProvider<AppSettingsService>.value(value: settings),
ChangeNotifierProvider<MeshCoreConnector>.value(value: connector),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Builder(
builder: (context) => TextButton(
onPressed: () => maybeShowNetworkMapOptInDialog(context),
child: const Text('open'),
),
),
),
),
);
}
testWidgets('Share turns uploading on and the prompt never returns', (
tester,
) async {
await pumpHost(tester);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
expect(find.text('Help build the network map?'), findsOneWidget);
await tester.tap(find.text('Share'));
await tester.pumpAndSettle();
expect(settings.settings.networkMapUploadEnabled, isTrue);
expect(settings.settings.networkMapPromptShown, isTrue);
await settings.setNetworkMapUploadEnabled(false);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
expect(find.text('Help build the network map?'), findsNothing);
});
testWidgets('No thanks leaves uploading off and is remembered', (
tester,
) async {
await pumpHost(tester);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
await tester.tap(find.text('No thanks'));
await tester.pumpAndSettle();
expect(settings.settings.networkMapUploadEnabled, isFalse);
expect(settings.settings.networkMapPromptShown, isTrue);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
expect(find.text('Help build the network map?'), findsNothing);
});
testWidgets('not shown while no radio is connected', (tester) async {
connector.dispose();
connector = MeshCoreConnector();
await pumpHost(tester);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
expect(find.text('Help build the network map?'), findsNothing);
expect(settings.settings.networkMapPromptShown, isFalse);
});
}