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
@@ -690,6 +690,46 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.image_search_outlined, size: 24),
|
||||
title: Text(context.l10n.appSettings_loadLinkImages),
|
||||
subtitle: Text(context.l10n.appSettings_loadLinkImagesSubtitle),
|
||||
value: settingsService.settings.loadLinkImages,
|
||||
onChanged: settingsService.setLoadLinkImages,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
secondary: const Icon(Icons.collections_outlined, size: 24),
|
||||
title: Text(context.l10n.appSettings_showLinkImagesByDefault),
|
||||
subtitle: Text(
|
||||
context.l10n.appSettings_showLinkImagesByDefaultSubtitle,
|
||||
),
|
||||
value: settingsService.settings.showLinkImagesByDefault,
|
||||
onChanged: settingsService.settings.loadLinkImages
|
||||
? settingsService.setShowLinkImagesByDefault
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
leading: const Icon(Icons.link_outlined, size: 20),
|
||||
title: Text(context.l10n.appSettings_ipfsImageLinks),
|
||||
subtitle: Text(context.l10n.appSettings_ipfsImageLinksSubtitle),
|
||||
trailing: const Icon(Icons.chevron_right, size: 18),
|
||||
onTap: () => _showIpfsImageLinksDialog(context, settingsService),
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
_ScrollIntoViewOnce(
|
||||
enabled: focusImageMessages,
|
||||
child: SwitchListTile(
|
||||
@@ -712,7 +752,6 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
if (settingsService.settings.imageMessagesEnabled) ...[
|
||||
const Divider(height: 1, indent: 16),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
@@ -740,6 +779,16 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
void _showIpfsImageLinksDialog(
|
||||
BuildContext context,
|
||||
AppSettingsService settingsService,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => _IpfsImageLinksDialog(settingsService: settingsService),
|
||||
);
|
||||
}
|
||||
|
||||
/// Model registry for image messages: the download entry point, the
|
||||
/// downloaded weights, and — when the build simply cannot run the codec —
|
||||
/// [ImageCodecService.unavailableReason] instead of a dead download button.
|
||||
@@ -1496,6 +1545,340 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _IpfsImageLinksDialog extends StatefulWidget {
|
||||
const _IpfsImageLinksDialog({required this.settingsService});
|
||||
|
||||
final AppSettingsService settingsService;
|
||||
|
||||
@override
|
||||
State<_IpfsImageLinksDialog> createState() => _IpfsImageLinksDialogState();
|
||||
}
|
||||
|
||||
class _IpfsImageLinksDialogState extends State<_IpfsImageLinksDialog> {
|
||||
late final TextEditingController _publicController;
|
||||
late final TextEditingController _uploadGatewayController;
|
||||
late final TextEditingController _endpointController;
|
||||
late final TextEditingController _apiKeyController;
|
||||
final FocusNode _apiKeyFocus = FocusNode();
|
||||
late final String _currentApiKey;
|
||||
late final String _maskedApiKey;
|
||||
late String _selectedGateway;
|
||||
late String _selectedUploadProvider;
|
||||
bool _apiKeyChanged = false;
|
||||
bool _apiKeyObscured = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final settings = widget.settingsService.settings;
|
||||
_publicController = TextEditingController(
|
||||
text: normalizeIpfsGateway(settings.publicIpfsGateway),
|
||||
);
|
||||
_uploadGatewayController = TextEditingController(
|
||||
text: normalizeIpfsGateway(settings.uploadIpfsGateway),
|
||||
);
|
||||
_endpointController = TextEditingController(
|
||||
text: settings.uploadIpfsEndpoint,
|
||||
);
|
||||
_currentApiKey = settings.uploadIpfsApiKey.trim();
|
||||
_maskedApiKey = _currentApiKey.isEmpty ? '' : _maskApiKey(_currentApiKey);
|
||||
_apiKeyController = TextEditingController(text: _maskedApiKey);
|
||||
_apiKeyFocus.addListener(_onApiKeyFocusChanged);
|
||||
_selectedGateway = _gatewayPreset(_publicController.text);
|
||||
_selectedUploadProvider = _uploadProvider(
|
||||
_uploadGatewayController.text,
|
||||
_endpointController.text,
|
||||
_currentApiKey,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_publicController.dispose();
|
||||
_uploadGatewayController.dispose();
|
||||
_endpointController.dispose();
|
||||
_apiKeyController.dispose();
|
||||
_apiKeyFocus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Swaps the masked key out while the field has focus (by tap, Tab or
|
||||
/// keyboard) so typing never appends to the mask, and puts it back if the
|
||||
/// user leaves without editing.
|
||||
void _onApiKeyFocusChanged() {
|
||||
if (_apiKeyChanged) return;
|
||||
_apiKeyController.text = _apiKeyFocus.hasFocus ? '' : _maskedApiKey;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return AlertDialog(
|
||||
title: Text(l10n.appSettings_ipfsImageLinks),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(l10n.appSettings_ipfsImageLinksDescription),
|
||||
const SizedBox(height: 12),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: _selectedGateway,
|
||||
isExpanded: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.appSettings_publicIpfsGateway,
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: 'deactivated',
|
||||
child: Text(l10n.appSettings_ipfsGatewayDeactivated),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'ipfsio',
|
||||
child: Text(l10n.appSettings_ipfsGatewayIpfsIo),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'pinata',
|
||||
child: Text(l10n.appSettings_ipfsGatewayPinata),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'filebase',
|
||||
child: Text(l10n.appSettings_ipfsGatewayFilebase),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'custom',
|
||||
child: Text(l10n.appSettings_ipfsGatewayCustom),
|
||||
),
|
||||
],
|
||||
onChanged: _selectGateway,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: _publicController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.appSettings_publicIpfsGateway,
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
autocorrect: false,
|
||||
onChanged: (_) {
|
||||
if (_selectedGateway != 'custom') {
|
||||
setState(() => _selectedGateway = 'custom');
|
||||
}
|
||||
},
|
||||
),
|
||||
const Divider(height: 20),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: _selectedUploadProvider,
|
||||
isExpanded: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.appSettings_uploadIpfsProvider,
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: 'pinata',
|
||||
child: Text(l10n.appSettings_ipfsGatewayPinata),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'filebase',
|
||||
child: Text(l10n.appSettings_ipfsGatewayFilebase),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'custom',
|
||||
child: Text(l10n.appSettings_ipfsGatewayCustom),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'deactivated',
|
||||
child: Text(l10n.appSettings_ipfsGatewayDeactivated),
|
||||
),
|
||||
],
|
||||
onChanged: _selectUploadProvider,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: _uploadGatewayController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.appSettings_uploadIpfsGateway,
|
||||
helperText: l10n.appSettings_uploadIpfsGatewaySubtitle,
|
||||
helperMaxLines: 3,
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
autocorrect: false,
|
||||
onChanged: (_) => _markCustomUploadProvider(),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: _endpointController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.appSettings_uploadIpfsEndpoint,
|
||||
helperText: l10n.appSettings_uploadIpfsEndpointSubtitle,
|
||||
helperMaxLines: 3,
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
autocorrect: false,
|
||||
onChanged: (_) => _markCustomUploadProvider(),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: _apiKeyController,
|
||||
focusNode: _apiKeyFocus,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.appSettings_uploadIpfsApiKey,
|
||||
suffixIcon: IconButton(
|
||||
tooltip: _apiKeyObscured
|
||||
? l10n.appSettings_showApiKey
|
||||
: l10n.appSettings_hideApiKey,
|
||||
icon: Icon(
|
||||
_apiKeyObscured
|
||||
? Icons.visibility_outlined
|
||||
: Icons.visibility_off_outlined,
|
||||
),
|
||||
onPressed: () =>
|
||||
setState(() => _apiKeyObscured = !_apiKeyObscured),
|
||||
),
|
||||
),
|
||||
autocorrect: false,
|
||||
enableSuggestions: false,
|
||||
obscureText: _apiKeyObscured,
|
||||
onChanged: (_) {
|
||||
_apiKeyChanged = true;
|
||||
_markCustomUploadProvider();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(l10n.common_cancel),
|
||||
),
|
||||
TextButton(onPressed: _save, child: Text(l10n.common_save)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _selectGateway(String? value) {
|
||||
if (value == null) return;
|
||||
setState(() {
|
||||
_selectedGateway = value;
|
||||
final preset = _gatewayValue(value);
|
||||
if (preset != null) _publicController.text = preset;
|
||||
});
|
||||
}
|
||||
|
||||
void _selectUploadProvider(String? value) {
|
||||
if (value == null) return;
|
||||
setState(() {
|
||||
_selectedUploadProvider = value;
|
||||
final preset = _uploadPreset(value);
|
||||
if (preset != null) {
|
||||
_uploadGatewayController.text = preset.gateway;
|
||||
_endpointController.text = preset.endpoint;
|
||||
if (value == 'deactivated') _apiKeyController.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _markCustomUploadProvider() {
|
||||
if (_selectedUploadProvider != 'custom') {
|
||||
setState(() => _selectedUploadProvider = 'custom');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _save() async {
|
||||
final deactivated = _selectedUploadProvider == 'deactivated';
|
||||
final apiKey = _apiKeyController.text.trim();
|
||||
await widget.settingsService.setIpfsImageSettings(
|
||||
publicGateway: _publicController.text,
|
||||
uploadGateway: deactivated ? '' : _uploadGatewayController.text,
|
||||
uploadEndpoint: deactivated ? '' : _endpointController.text,
|
||||
uploadApiKey: deactivated
|
||||
? ''
|
||||
: _apiKeyChanged && apiKey != _maskedApiKey
|
||||
? apiKey
|
||||
: _currentApiKey,
|
||||
);
|
||||
if (mounted) Navigator.pop(context);
|
||||
}
|
||||
|
||||
String _gatewayPreset(String value) {
|
||||
if (value.isEmpty) return 'deactivated';
|
||||
if (value == AppSettings.defaultPublicIpfsGateway ||
|
||||
value == 'https://ipfs.io/ipfs') {
|
||||
return 'ipfsio';
|
||||
}
|
||||
if (value == 'https://gateway.pinata.cloud/ipfs/' ||
|
||||
value == 'https://gateway.pinata.cloud/ipfs') {
|
||||
return 'pinata';
|
||||
}
|
||||
if (value == 'https://ipfs.filebase.io/ipfs/' ||
|
||||
value == 'https://ipfs.filebase.io/ipfs') {
|
||||
return 'filebase';
|
||||
}
|
||||
return 'custom';
|
||||
}
|
||||
|
||||
String? _gatewayValue(String preset) {
|
||||
switch (preset) {
|
||||
case 'deactivated':
|
||||
return '';
|
||||
case 'ipfsio':
|
||||
return AppSettings.defaultPublicIpfsGateway;
|
||||
case 'pinata':
|
||||
return 'https://gateway.pinata.cloud/ipfs/';
|
||||
case 'filebase':
|
||||
return 'https://ipfs.filebase.io/ipfs/';
|
||||
case 'custom':
|
||||
return 'http://127.0.0.1:8080/ipfs/';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String _uploadProvider(String gateway, String endpoint, String apiKey) {
|
||||
if (gateway.isEmpty && endpoint.isEmpty && apiKey.isEmpty) {
|
||||
return 'deactivated';
|
||||
}
|
||||
if (gateway == 'https://gateway.pinata.cloud/ipfs/' &&
|
||||
endpoint == 'https://api.pinata.cloud/pinning/pinFileToIPFS') {
|
||||
return 'pinata';
|
||||
}
|
||||
if (gateway == 'https://ipfs.filebase.io/ipfs/' &&
|
||||
endpoint == 'https://rpc.filebase.io/api/v0/add') {
|
||||
return 'filebase';
|
||||
}
|
||||
return 'custom';
|
||||
}
|
||||
|
||||
({String gateway, String endpoint})? _uploadPreset(String preset) {
|
||||
switch (preset) {
|
||||
case 'pinata':
|
||||
return (
|
||||
gateway: 'https://gateway.pinata.cloud/ipfs/',
|
||||
endpoint: 'https://api.pinata.cloud/pinning/pinFileToIPFS',
|
||||
);
|
||||
case 'filebase':
|
||||
return (
|
||||
gateway: 'https://ipfs.filebase.io/ipfs/',
|
||||
endpoint: 'https://rpc.filebase.io/api/v0/add',
|
||||
);
|
||||
case 'custom':
|
||||
return (
|
||||
gateway: 'http://127.0.0.1:8080/ipfs/',
|
||||
endpoint: 'http://127.0.0.1:5001/api/v0/add',
|
||||
);
|
||||
case 'deactivated':
|
||||
return (gateway: '', endpoint: '');
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String _maskApiKey(String value) {
|
||||
if (value.length <= 8) return '********';
|
||||
return '${value.substring(0, 4)}...${value.substring(value.length - 4)}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Stadia API key editor. Owns (and disposes) its controller; the key is
|
||||
/// obscured by default with a visibility toggle. The field starts with the
|
||||
/// masked current key, and saving it unchanged keeps the current key.
|
||||
|
||||
@@ -18,6 +18,8 @@ import '../helpers/chat_scroll_controller.dart';
|
||||
import '../connector/meshcore_protocol.dart';
|
||||
import '../helpers/cyr2lat.dart';
|
||||
import '../helpers/gif_helper.dart';
|
||||
import '../helpers/ipfs_link_attach_flow.dart';
|
||||
import '../helpers/marker_message.dart';
|
||||
import '../helpers/message_url_image_helper.dart';
|
||||
import '../helpers/path_helper.dart';
|
||||
import '../helpers/reaction_helper.dart';
|
||||
@@ -26,7 +28,8 @@ import '../l10n/l10n.dart';
|
||||
import '../models/channel.dart';
|
||||
import '../models/channel_message.dart';
|
||||
import '../models/image_codec_support.dart' show aeicRatePointForUi;
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../services/app_settings_service.dart'
|
||||
show AppSettingsService, ChannelNotificationMode;
|
||||
import '../services/chat_text_scale_service.dart';
|
||||
import '../services/image_chunk_transport.dart';
|
||||
import '../services/image_codec_service.dart';
|
||||
@@ -36,9 +39,9 @@ import '../utils/image_save.dart';
|
||||
import '../utils/lora_airtime.dart';
|
||||
import '../widgets/marker_label_dialog.dart';
|
||||
import '../widgets/received_image_message.dart';
|
||||
import '../widgets/channel_notification_mode_sheet.dart';
|
||||
import '../widgets/chat_day_separator.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
|
||||
import '../widgets/chat_composer.dart';
|
||||
import '../widgets/chat_send_pipeline.dart';
|
||||
import '../widgets/chat_zoom_wrapper.dart';
|
||||
@@ -405,19 +408,22 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
Consumer<AppSettingsService>(
|
||||
builder: (context, settings, _) {
|
||||
final muteKey = widget.channel.muteKey;
|
||||
final muted = settings.isChannelMuted(muteKey);
|
||||
final notificationMode = settings.getChannelNotificationMode(
|
||||
muteKey,
|
||||
);
|
||||
return IconButton(
|
||||
tooltip: muted
|
||||
? context.l10n.channels_unmuteChannel
|
||||
: context.l10n.channels_muteChannel,
|
||||
icon: Icon(
|
||||
muted
|
||||
? Icons.notifications_off_outlined
|
||||
: Icons.notifications_outlined,
|
||||
tooltip: context.l10n.channels_notificationModeTooltip(
|
||||
channelNotificationModeLabel(context, notificationMode),
|
||||
),
|
||||
onPressed: () => muted
|
||||
? settings.unmuteChannel(muteKey)
|
||||
: settings.muteChannel(muteKey),
|
||||
icon: Icon(
|
||||
notificationMode == ChannelNotificationMode.muted
|
||||
? Icons.notifications_off
|
||||
: notificationMode == ChannelNotificationMode.mentionsOnly
|
||||
? Icons.notification_important
|
||||
: Icons.notifications,
|
||||
),
|
||||
onPressed: () =>
|
||||
showChannelNotificationModeSheet(context, muteKey),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -619,6 +625,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
return _buildTerminalMessage(message, textScale, urlImagesEnabled);
|
||||
}
|
||||
final settingsService = context.watch<AppSettingsService>();
|
||||
final publicIpfsGateway = settingsService.settings.publicIpfsGateway;
|
||||
final enableTracing = settingsService.settings.enableMessageTracing;
|
||||
final regionOnHopsLine = settingsService.settings.regionOnHopsLine;
|
||||
final isOutgoing = message.isOutgoing;
|
||||
@@ -763,6 +770,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
MessageUrlImageFutureBuilder(
|
||||
messageId: message.messageId,
|
||||
text: message.text,
|
||||
publicGateway: publicIpfsGateway,
|
||||
builder: (context, snapshot) {
|
||||
final imageAttachment = snapshot.data;
|
||||
|
||||
@@ -815,9 +823,10 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
if (settingsService.settings.loadLinkImages &&
|
||||
MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
@@ -1315,6 +1324,23 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _sendImageViaIpfs() {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
return attachIpfsLinkToDraft(
|
||||
context: context,
|
||||
controller: _textController,
|
||||
focusNode: _textFieldFocusNode,
|
||||
maxBytes: maxChannelMessageBytes(connector.selfName),
|
||||
encodeOutbound: (text) {
|
||||
final replyTo = _replyingToMessage;
|
||||
return connector.prepareChannelOutboundText(
|
||||
widget.channel.index,
|
||||
replyTo == null ? text : '${_replyPrefix(replyTo)}$text',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Takes no [BuildContext]: it uses the [State]'s own, so the `mounted`
|
||||
/// checks around each `await` are the ones that actually govern it.
|
||||
Future<void> _showImageSendPreview() async {
|
||||
@@ -2036,8 +2062,10 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
final showImageAction = context.select<AppSettingsService, bool>(
|
||||
(s) => s.settings.imageMessagesEnabled,
|
||||
);
|
||||
final showIpfsAction = context.select<AppSettingsService, bool>(
|
||||
(s) => s.settings.uploadIpfsEndpoint.trim().isNotEmpty,
|
||||
);
|
||||
final replyTo = _replyingToMessage;
|
||||
// A reply's prefix is sent too, so it counts against the limit.
|
||||
final replyPrefixBytes = replyTo == null
|
||||
? 0
|
||||
: utf8.encode(_replyPrefix(replyTo)).length;
|
||||
@@ -2077,6 +2105,12 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
icon: Icons.gif_box,
|
||||
label: context.l10n.chat_sendGif,
|
||||
),
|
||||
if (showIpfsAction)
|
||||
ChatComposerAction(
|
||||
id: 'ipfs-image',
|
||||
icon: Icons.cloud_upload_outlined,
|
||||
label: context.l10n.chat_sendImageIpfs,
|
||||
),
|
||||
if (showImageAction)
|
||||
ChatComposerAction(
|
||||
id: 'meshcore-image',
|
||||
@@ -2099,6 +2133,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
switch (action) {
|
||||
case 'gif':
|
||||
showChatGifPicker(context, _textController);
|
||||
case 'ipfs-image':
|
||||
_sendImageViaIpfs();
|
||||
case 'meshcore-image':
|
||||
_showImageSendPreview();
|
||||
case 'send-my-location':
|
||||
@@ -2320,9 +2356,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}
|
||||
|
||||
void _showEmojiPicker(ChannelMessage message) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (context) => EmojiPicker(
|
||||
onEmojiSelected: (emoji) {
|
||||
_sendReaction(message, emoji);
|
||||
|
||||
@@ -24,6 +24,7 @@ import '../widgets/adaptive_app_bar_title.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/path_map_scaffold.dart';
|
||||
import '../widgets/path_map_ui.dart';
|
||||
import '../widgets/set_my_location_dialog.dart';
|
||||
|
||||
class ChannelMessagePathScreen extends StatelessWidget {
|
||||
final ChannelMessage message;
|
||||
@@ -911,6 +912,10 @@ class _ChannelMessagePathMapScreenState
|
||||
initialCenter: model.initialCenter,
|
||||
initialZoom: model.initialZoom,
|
||||
bounds: model.bounds,
|
||||
onLongPress: (_, point) =>
|
||||
confirmAndSetMyLocation(context, connector, point),
|
||||
onSecondaryTap: (_, point) =>
|
||||
confirmAndSetMyLocation(context, connector, point),
|
||||
onPositionChanged: (camera, hasGesture) {
|
||||
if (!mounted) return;
|
||||
// A manual pan/zoom releases the follow lock.
|
||||
|
||||
@@ -10,7 +10,8 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/app_settings_service.dart';
|
||||
import '../services/app_settings_service.dart'
|
||||
show AppSettingsService, ChannelNotificationMode;
|
||||
import '../services/ui_view_state_service.dart';
|
||||
import '../models/channel.dart';
|
||||
import '../models/community.dart';
|
||||
@@ -19,6 +20,7 @@ import '../theme/mesh_theme.dart';
|
||||
import '../utils/dialog_utils.dart';
|
||||
import '../utils/disconnect_navigation_mixin.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../widgets/channel_notification_mode_sheet.dart';
|
||||
import '../widgets/list_filter_widget.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
@@ -372,9 +374,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
int listIndex = 0,
|
||||
}) {
|
||||
final unreadCount = connector.getUnreadCountForChannel(channel);
|
||||
final isMuted = context.watch<AppSettingsService>().isChannelMuted(
|
||||
channel.muteKey,
|
||||
);
|
||||
final notificationMode = context
|
||||
.watch<AppSettingsService>()
|
||||
.getChannelNotificationMode(channel.muteKey);
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
|
||||
// Determine icon and colors based on channel type
|
||||
@@ -580,9 +582,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (isMuted) ...[
|
||||
if (notificationMode != ChannelNotificationMode.all) ...[
|
||||
Icon(
|
||||
Icons.notifications_off,
|
||||
channelNotificationModeIcon(notificationMode),
|
||||
size: 18,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
@@ -625,8 +627,6 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Channel channel,
|
||||
) {
|
||||
final parentContext = context;
|
||||
final settingsService = context.read<AppSettingsService>();
|
||||
final isMuted = settingsService.isChannelMuted(channel.muteKey);
|
||||
|
||||
showMeshSheet(
|
||||
parentContext,
|
||||
@@ -645,23 +645,19 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
}
|
||||
},
|
||||
),
|
||||
// Notification mode selection
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
isMuted
|
||||
? Icons.notifications_outlined
|
||||
: Icons.notifications_off_outlined,
|
||||
),
|
||||
title: Text(
|
||||
isMuted
|
||||
? sheetContext.l10n.channels_unmuteChannel
|
||||
: sheetContext.l10n.channels_muteChannel,
|
||||
),
|
||||
leading: const Icon(Icons.notifications_outlined),
|
||||
title: Text(sheetContext.l10n.channels_notificationSettings),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetContext);
|
||||
if (isMuted) {
|
||||
await settingsService.unmuteChannel(channel.muteKey);
|
||||
} else {
|
||||
await settingsService.muteChannel(channel.muteKey);
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (parentContext.mounted) {
|
||||
showChannelNotificationModeSheet(
|
||||
parentContext,
|
||||
channel.muteKey,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -1401,7 +1397,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.qr_code_scanner),
|
||||
label: Text(sheetContext.l10n.community_scanQr),
|
||||
label: Text(
|
||||
sheetContext.l10n.channels_scanQrCode,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1605,8 +1603,8 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
buildOptionCard(
|
||||
optionIndex: 4,
|
||||
icon: Icons.qr_code_scanner,
|
||||
title: sheetContext.l10n.community_scanQr,
|
||||
subtitle: sheetContext.l10n.community_join,
|
||||
title: sheetContext.l10n.channels_scanQrCode,
|
||||
subtitle: sheetContext.l10n.channels_scanQrCodeDesc,
|
||||
),
|
||||
if (selectedOption == 4) buildExpandedContent()!,
|
||||
SectionHeader(
|
||||
@@ -1653,7 +1651,11 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
);
|
||||
bool smazEnabled = connector.isChannelSmazEnabled(channel.index);
|
||||
bool cyr2latEnabled = connector.isChannelCyr2LatEnabled(channel.index);
|
||||
bool urlImagesEnabled = connector.isChannelUrlImagesEnabled(channel.index);
|
||||
final initialUrlImagesEnabled = connector.isChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
);
|
||||
bool urlImagesEnabled = initialUrlImagesEnabled;
|
||||
final loadLinkImages = appSettingsService.settings.loadLinkImages;
|
||||
String? selectedCyr2LatProfileId = connector.getChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
);
|
||||
@@ -1773,9 +1775,19 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(sheetContext.l10n.urlImage_enable),
|
||||
subtitle: loadLinkImages
|
||||
? null
|
||||
: Text(
|
||||
sheetContext
|
||||
.l10n
|
||||
.urlImage_disabledInAppSettings,
|
||||
),
|
||||
value: urlImagesEnabled,
|
||||
onChanged: (value) =>
|
||||
setSheetState(() => urlImagesEnabled = value),
|
||||
onChanged: loadLinkImages
|
||||
? (value) => setSheetState(
|
||||
() => urlImagesEnabled = value,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
@@ -1835,10 +1847,13 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
channel.index,
|
||||
cyr2latEnabled,
|
||||
);
|
||||
await connector.setChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
urlImagesEnabled,
|
||||
);
|
||||
if (urlImagesEnabled !=
|
||||
initialUrlImagesEnabled) {
|
||||
await connector.setChannelUrlImagesEnabled(
|
||||
channel.index,
|
||||
urlImagesEnabled,
|
||||
);
|
||||
}
|
||||
await connector.setChannelCyr2LatProfileId(
|
||||
channel.index,
|
||||
selectedCyr2LatProfileId,
|
||||
|
||||
@@ -20,6 +20,8 @@ import '../widgets/message_status_icon.dart';
|
||||
import '../widgets/empty_state.dart';
|
||||
import '../helpers/chat_scroll_controller.dart';
|
||||
import '../helpers/gif_helper.dart';
|
||||
import '../helpers/ipfs_link_attach_flow.dart';
|
||||
import '../helpers/marker_message.dart';
|
||||
import '../models/channel_message.dart';
|
||||
import '../models/contact.dart';
|
||||
import '../l10n/contact_localization.dart';
|
||||
@@ -524,26 +526,39 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
sendTooltip: context.l10n.chat_sendMessageTo(
|
||||
_resolveContact(connector).name,
|
||||
),
|
||||
// No image action here: the image wire format is GRP_DATA, a channel
|
||||
// primitive with no DM equivalent (see the note at the top of this
|
||||
// file).
|
||||
actionsBuilder: () => [
|
||||
ChatComposerAction(
|
||||
id: 'gif',
|
||||
icon: Icons.gif_box,
|
||||
label: context.l10n.chat_sendGif,
|
||||
),
|
||||
ChatComposerAction(
|
||||
id: 'send-my-location',
|
||||
icon: Icons.my_location,
|
||||
label: context.l10n.chat_shareMyLocation,
|
||||
),
|
||||
],
|
||||
actionsBuilder: () {
|
||||
final showIpfsAction = context
|
||||
.read<AppSettingsService>()
|
||||
.settings
|
||||
.uploadIpfsEndpoint
|
||||
.trim()
|
||||
.isNotEmpty;
|
||||
return [
|
||||
ChatComposerAction(
|
||||
id: 'gif',
|
||||
icon: Icons.gif_box,
|
||||
label: context.l10n.chat_sendGif,
|
||||
),
|
||||
if (showIpfsAction)
|
||||
ChatComposerAction(
|
||||
id: 'ipfs-image',
|
||||
icon: Icons.cloud_upload_outlined,
|
||||
label: context.l10n.chat_sendImageIpfs,
|
||||
),
|
||||
ChatComposerAction(
|
||||
id: 'send-my-location',
|
||||
icon: Icons.my_location,
|
||||
label: context.l10n.chat_shareMyLocation,
|
||||
),
|
||||
];
|
||||
},
|
||||
onAction: (action) {
|
||||
if (!mounted) return;
|
||||
switch (action) {
|
||||
case 'gif':
|
||||
showChatGifPicker(context, _textController);
|
||||
case 'ipfs-image':
|
||||
_sendImageViaIpfs();
|
||||
case 'send-my-location':
|
||||
_shareMyLocation(context.read<MeshCoreConnector>());
|
||||
}
|
||||
@@ -551,6 +566,19 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _sendImageViaIpfs() {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final contact = _resolveContact(connector);
|
||||
return attachIpfsLinkToDraft(
|
||||
context: context,
|
||||
controller: _textController,
|
||||
focusNode: _textFieldFocusNode,
|
||||
maxBytes: maxContactMessageBytes(),
|
||||
encodeOutbound: (text) =>
|
||||
connector.prepareContactOutboundText(contact, text),
|
||||
);
|
||||
}
|
||||
|
||||
/// Shares the radio's own position as a map marker. Shares the text send
|
||||
/// guard and cooldown so it can't race or flood alongside typed messages.
|
||||
Future<void> _shareMyLocation(MeshCoreConnector connector) {
|
||||
@@ -758,6 +786,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
bool urlImagesEnabled = connector.isContactUrlImagesEnabled(
|
||||
contact.publicKeyHex,
|
||||
);
|
||||
final loadLinkImages = context
|
||||
.read<AppSettingsService>()
|
||||
.settings
|
||||
.loadLinkImages;
|
||||
String? selectedCyr2LatProfileId = connector.getContactCyr2LatProfileId(
|
||||
contact.publicKeyHex,
|
||||
);
|
||||
@@ -872,14 +904,19 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(context.l10n.urlImage_enable),
|
||||
subtitle: loadLinkImages
|
||||
? null
|
||||
: Text(context.l10n.urlImage_disabledInAppSettings),
|
||||
value: urlImagesEnabled,
|
||||
onChanged: (value) {
|
||||
connector.setContactUrlImagesEnabled(
|
||||
contact.publicKeyHex,
|
||||
value,
|
||||
);
|
||||
setDialogState(() => urlImagesEnabled = value);
|
||||
},
|
||||
onChanged: loadLinkImages
|
||||
? (value) {
|
||||
connector.setContactUrlImagesEnabled(
|
||||
contact.publicKeyHex,
|
||||
value,
|
||||
);
|
||||
setDialogState(() => urlImagesEnabled = value);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 8),
|
||||
SwitchListTile(
|
||||
@@ -1165,9 +1202,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _showEmojiPicker(Message message, Contact senderContact) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showMeshSheet(
|
||||
context,
|
||||
builder: (context) => EmojiPicker(
|
||||
onEmojiSelected: (emoji) {
|
||||
_sendReaction(message, senderContact, emoji);
|
||||
@@ -1229,6 +1265,7 @@ class _MessageBubble extends StatelessWidget {
|
||||
final urlImagesEnabled = context.select<MeshCoreConnector, bool>(
|
||||
(connector) => connector.isContactUrlImagesEnabled(sourceId),
|
||||
);
|
||||
final publicIpfsGateway = settingsService.settings.publicIpfsGateway;
|
||||
|
||||
final colors = MessageBubbleColors.of(
|
||||
scheme,
|
||||
@@ -1357,6 +1394,7 @@ class _MessageBubble extends StatelessWidget {
|
||||
MessageUrlImageFutureBuilder(
|
||||
messageId: message.messageId,
|
||||
text: message.text,
|
||||
publicGateway: publicIpfsGateway,
|
||||
builder: (context, snapshot) {
|
||||
final imageAttachment = snapshot.data;
|
||||
|
||||
@@ -1409,9 +1447,10 @@ class _MessageBubble extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
if (settingsService.settings.loadLinkImages &&
|
||||
MessageUrlImageHelper.hasPotentialImageUrl(
|
||||
message.text,
|
||||
))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@@ -11,15 +12,20 @@ import '../l10n/l10n.dart';
|
||||
import '../models/community.dart';
|
||||
import '../storage/community_store.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../utils/channel_qr.dart';
|
||||
import '../widgets/adaptive_app_bar_title.dart';
|
||||
import '../widgets/mesh_ui.dart';
|
||||
import '../widgets/qr_scanner_widget.dart';
|
||||
|
||||
/// Screen for scanning community QR codes to join communities.
|
||||
/// Screen for scanning community and channel QR codes.
|
||||
///
|
||||
/// After successful scan, the user can:
|
||||
/// After scanning a community QR code, the user can:
|
||||
/// 1. Join the community (saves to local storage)
|
||||
/// 2. Optionally add the Community Public Channel to the device
|
||||
///
|
||||
/// After scanning an official channel QR code
|
||||
/// (`meshcore://channel/add?name=…&secret=…`), the user can add that
|
||||
/// channel to a free slot on the device.
|
||||
class CommunityQrScannerScreen extends StatefulWidget {
|
||||
const CommunityQrScannerScreen({super.key});
|
||||
|
||||
@@ -54,7 +60,7 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: AdaptiveAppBarTitle(context.l10n.community_scanQr),
|
||||
title: AdaptiveAppBarTitle(context.l10n.channels_scanQrCode),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: _isProcessing
|
||||
@@ -62,12 +68,14 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
: QrScannerWidget(
|
||||
onScanned: (data) => _handleScannedData(context, data),
|
||||
validator: (data) =>
|
||||
Community.isValidQrData(data) && !_isRecentlyCancelled(data),
|
||||
(Community.isValidQrData(data) ||
|
||||
parseChannelQr(data) != null) &&
|
||||
!_isRecentlyCancelled(data),
|
||||
onValidationFailed: (data) {
|
||||
if (_isRecentlyCancelled(data)) return;
|
||||
_showInvalidQrError(context);
|
||||
},
|
||||
instructions: context.l10n.community_scanInstructions,
|
||||
instructions: context.l10n.channels_scanQrInstructions,
|
||||
themed: true,
|
||||
),
|
||||
);
|
||||
@@ -87,6 +95,14 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
var leaving = false;
|
||||
|
||||
try {
|
||||
final channel = parseChannelQr(data);
|
||||
if (channel != null) {
|
||||
if (context.mounted) {
|
||||
leaving = await _showJoinChannelDialog(context, channel, data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse the community data
|
||||
final community = Community.fromQrData(const Uuid().v4(), data);
|
||||
|
||||
@@ -111,7 +127,7 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
if (context.mounted) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.community_invalidQrCode),
|
||||
content: Text(context.l10n.channels_invalidQrCode),
|
||||
backgroundColor: MeshPalette.alert,
|
||||
);
|
||||
}
|
||||
@@ -125,7 +141,125 @@ class _CommunityQrScannerScreenState extends State<CommunityQrScannerScreen> {
|
||||
}
|
||||
|
||||
void _showInvalidQrError(BuildContext context) {
|
||||
showInvalidQrSnackBar(context, context.l10n.community_invalidQrCode);
|
||||
showInvalidQrSnackBar(context, context.l10n.channels_invalidQrCode);
|
||||
}
|
||||
|
||||
/// Returns true when the channel was added and the screen popped.
|
||||
Future<bool> _showJoinChannelDialog(
|
||||
BuildContext context,
|
||||
ScannedChannel channel,
|
||||
String data,
|
||||
) async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final name = truncateUtf8(channel.name, maxRadioNameBytes);
|
||||
final alreadyOnRadio = connector.channels.any(
|
||||
(c) => listEquals(c.psk, channel.psk),
|
||||
);
|
||||
if (alreadyOnRadio) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.channels_alreadyOnRadio(name)),
|
||||
);
|
||||
_markCancelled(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
final confirmed = await showMeshSheet<bool>(
|
||||
context,
|
||||
builder: (sheetContext) {
|
||||
final sheetScheme = Theme.of(sheetContext).colorScheme;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
BottomSheetHeader(title: context.l10n.channels_joinChannelTitle),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 0, 20, 4),
|
||||
child: Text(
|
||||
context.l10n.channels_joinChannelConfirm(name),
|
||||
style: TextStyle(color: sheetScheme.onSurfaceVariant),
|
||||
),
|
||||
),
|
||||
MeshCard(
|
||||
child: Row(
|
||||
children: [
|
||||
AvatarCircle(
|
||||
name: name,
|
||||
icon: Icons.lock,
|
||||
color: MeshPalette.blue,
|
||||
size: 44,
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Text(
|
||||
name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => Navigator.pop(sheetContext, false),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.pop(sheetContext, true),
|
||||
child: Text(context.l10n.common_add),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
if (confirmed != true || !context.mounted) {
|
||||
_markCancelled(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only trust free slots after a complete channel sync; mid-sync, unfetched
|
||||
// slots look empty and writing one would overwrite an existing channel.
|
||||
final slotsKnown =
|
||||
connector.hasLoadedChannels && !connector.isSyncingChannels;
|
||||
final nextIndex = slotsKnown
|
||||
? _findNextAvailableChannelIndex(connector)
|
||||
: null;
|
||||
if (nextIndex == null) {
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
slotsKnown
|
||||
? context.l10n.channels_noFreeSlots
|
||||
: context.l10n.channels_waitForSync,
|
||||
),
|
||||
);
|
||||
_markCancelled(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
await connector.setChannel(nextIndex, name, channel.psk);
|
||||
if (!context.mounted) return false;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.channels_channelAdded(name)),
|
||||
backgroundColor: MeshPalette.signal,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Returns true when the screen popped itself (OK pressed).
|
||||
|
||||
@@ -1759,6 +1759,16 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
Text(
|
||||
context.l10n.contacts_removeFromContactsConfirm(contact.name),
|
||||
),
|
||||
if (connector.autoAddsContactType(contact.type)) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context.l10n.contacts_removeAutoAddNote,
|
||||
style: TextStyle(
|
||||
color: Theme.of(dialogContext).colorScheme.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
@@ -1775,9 +1785,24 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
connector.removeContact(contact, keepMessages: keepHistory);
|
||||
try {
|
||||
await connector.removeContact(
|
||||
contact,
|
||||
keepMessages: keepHistory,
|
||||
);
|
||||
} catch (e) {
|
||||
appLogger.warn(
|
||||
'Remove contact failed: $e',
|
||||
tag: 'ContactsScreen',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.contacts_removeFailed),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
context.l10n.contacts_remove,
|
||||
@@ -1890,9 +1915,13 @@ class _ContactTile extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
// Path / subtitle row
|
||||
// Key prefix + path / subtitle row
|
||||
Row(
|
||||
children: [
|
||||
_KeyPrefixBadge(
|
||||
prefix: contact.publicKeyPrefixHex(pathHashByteWidth),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
contact.pathLabel(
|
||||
@@ -1959,6 +1988,43 @@ class _ContactTile extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Mono pill showing the contact's routing hash (public-key prefix), so it can
|
||||
/// be matched against hops in paths.
|
||||
class _KeyPrefixBadge extends StatelessWidget {
|
||||
final String prefix;
|
||||
|
||||
const _KeyPrefixBadge({required this.prefix});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Semantics(
|
||||
label: context.l10n.contacts_keyPrefixSemantics(
|
||||
prefix.split('').join(' '),
|
||||
),
|
||||
excludeSemantics: true,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(MeshRadii.xs),
|
||||
border: Border.all(color: scheme.outline),
|
||||
),
|
||||
child: Text(
|
||||
prefix,
|
||||
maxLines: 1,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: scheme.onSurface,
|
||||
letterSpacing: 0.6,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Disposes [controller] when the dialog content unmounts, i.e. after the
|
||||
/// route's exit animation, so the TextField never sees a disposed controller.
|
||||
class _DisposeControllerOnUnmount extends StatefulWidget {
|
||||
|
||||
@@ -316,7 +316,15 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
content: Text(context.l10n.discoveredContacts_contactAdded),
|
||||
action: SnackBarAction(
|
||||
label: context.l10n.common_undo,
|
||||
onPressed: () => connector.removeContact(contact),
|
||||
onPressed: () => unawaited(
|
||||
connector.removeContact(contact).catchError((Object _) {
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.contacts_removeFailed),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (_) {
|
||||
|
||||
+250
-630
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,7 @@ import 'package:meshcore_open/helpers/snack_bar_builder.dart';
|
||||
import 'package:meshcore_open/widgets/path_map_scaffold.dart';
|
||||
import 'package:meshcore_open/widgets/path_map_ui.dart';
|
||||
import 'package:meshcore_open/widgets/snr_indicator.dart';
|
||||
import 'package:meshcore_open/widgets/set_my_location_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
|
||||
@@ -64,6 +65,13 @@ class PathTraceMapScreen extends StatefulWidget {
|
||||
final int pathHashByteWidth;
|
||||
final List<Contact>? pathContacts;
|
||||
|
||||
/// A previous PUSH_CODE_TRACE_DATA frame to show instead of sending a new
|
||||
/// trace when the screen opens.
|
||||
final Uint8List? initialTraceFrame;
|
||||
|
||||
/// Called with each trace response frame this screen receives.
|
||||
final ValueChanged<Uint8List>? onTraceFrame;
|
||||
|
||||
const PathTraceMapScreen({
|
||||
super.key,
|
||||
required this.title,
|
||||
@@ -74,6 +82,8 @@ class PathTraceMapScreen extends StatefulWidget {
|
||||
this.targetContact,
|
||||
this.pathHashByteWidth = pathHashSize,
|
||||
this.pathContacts,
|
||||
this.initialTraceFrame,
|
||||
this.onTraceFrame,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -219,7 +229,20 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
_pathHistory = context.read<PathHistoryService>();
|
||||
_pathHistory!.addListener(_onPathHistoryChanged);
|
||||
_setupFrameListener();
|
||||
_doPathTrace();
|
||||
final initialFrame = widget.initialTraceFrame;
|
||||
if (initialFrame == null) {
|
||||
_doPathTrace();
|
||||
return;
|
||||
}
|
||||
final (livePath, hopWidth) = _resolveLivePath(
|
||||
context.read<MeshCoreConnector>(),
|
||||
);
|
||||
_tracedPath = livePath;
|
||||
_tracedPathHashWidth = hopWidth;
|
||||
_isLoading = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) _handleTraceResponse(initialFrame);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -239,6 +262,16 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _setMyLocation(LatLng point) async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final ok = await confirmAndSetMyLocation(context, connector, point);
|
||||
if (!ok || !mounted || !_hasData) return;
|
||||
// Display paths start at the self position, so redraw them from it.
|
||||
setState(() {
|
||||
_rebuildDisplayPaths(connector);
|
||||
});
|
||||
}
|
||||
|
||||
/// Keeps the camera centered on the packet while the follow lock is on.
|
||||
void _followPacketCamera() {
|
||||
if (!mounted) return;
|
||||
@@ -490,6 +523,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
(listEquals(frame.sublist(4, 8), _sentTagBytes) ||
|
||||
listEquals(frame.sublist(4, 8), _sentAckTag))) {
|
||||
_timeoutTimer?.cancel();
|
||||
widget.onTraceFrame?.call(frame);
|
||||
if (!mounted) return;
|
||||
_handleTraceResponse(frame);
|
||||
}
|
||||
@@ -1497,6 +1531,8 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
initialCenter: _initialCenter!,
|
||||
initialZoom: _initialZoom,
|
||||
bounds: _bounds,
|
||||
onLongPress: (_, point) => _setMyLocation(point),
|
||||
onSecondaryTap: (_, point) => _setMyLocation(point),
|
||||
onPositionChanged: (camera, hasGesture) {
|
||||
if (!mounted) return;
|
||||
// A manual pan/zoom releases the follow lock.
|
||||
|
||||
@@ -25,9 +25,6 @@ import '../widgets/sync_progress_overlay.dart';
|
||||
import 'region_management_screen.dart';
|
||||
import '../utils/share_origin.dart';
|
||||
|
||||
/// Companion firmware version that added CMD_SET_PATH_HASH_MODE (v1.14.0).
|
||||
const int _minFirmwareVerCodeForPathHashMode = 10;
|
||||
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
||||
@@ -566,14 +563,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
title: l10n.repeater_pathHashMode,
|
||||
subtitle: !connected
|
||||
? offline
|
||||
: (connector.firmwareVerCode ?? 0) <
|
||||
_minFirmwareVerCodeForPathHashMode
|
||||
: !connector.supportsPathHashMode
|
||||
? l10n.settings_requiresFirmware('v1.14')
|
||||
: _pathHashModeSubtitle(context, connector.pathHashByteWidth),
|
||||
onTap:
|
||||
connector.isConnected &&
|
||||
(connector.firmwareVerCode ?? 0) >=
|
||||
_minFirmwareVerCodeForPathHashMode
|
||||
onTap: connector.isConnected && connector.supportsPathHashMode
|
||||
? () => _editPathHashMode(context, connector)
|
||||
: null,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user