diff --git a/CHANGES.md b/CHANGES.md index 30af5da..6636c4c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1093,3 +1093,11 @@ 2026-07-03 06:24 [Edit] /home/steggi/pyramid/lib/core/background_push.dart 2026-07-03 06:24 [Edit] /home/steggi/pyramid/lib/core/background_push.dart 2026-07-03 06:24 [Edit] /home/steggi/pyramid/lib/core/livekit_call_manager.dart +2026-07-03 06:26 [Write] /home/steggi/.claude/projects/-home-steggi-pyramid/memory/pyramid_push.md +2026-07-03 06:27 [Edit] /home/steggi/.claude/projects/-home-steggi-pyramid/memory/pyramid_push.md +2026-07-03 06:27 [Write] /home/steggi/.claude/projects/-home-steggi-pyramid/memory/MEMORY.md +2026-07-03 06:28 [Edit] /home/steggi/pyramid/lib/core/livekit_call_manager.dart +2026-07-03 06:28 [Edit] /home/steggi/pyramid/lib/core/notification_service.dart +2026-07-03 06:29 [Edit] /home/steggi/pyramid/lib/core/background_push.dart +2026-07-03 06:29 [Edit] /home/steggi/pyramid/lib/core/background_push.dart +2026-07-03 06:29 [Edit] /home/steggi/pyramid/lib/core/voip_manager.dart diff --git a/lib/core/background_push.dart b/lib/core/background_push.dart index 452ac29..d7b28c0 100644 --- a/lib/core/background_push.dart +++ b/lib/core/background_push.dart @@ -67,7 +67,7 @@ void notificationEngineMain() { ); } } catch (e) { - print('[NOTIF-BGENGINE] handler error: $e'); + debugPrint('[NOTIF-BGENGINE] handler error: $e'); } return false; }); @@ -111,7 +111,7 @@ Future _bgDecryptAndShow(String? roomId, String? eventId, int? notifId) as }); return true; } catch (e) { - print('[NOTIF-BGENGINE] decryptAndShow error: $e'); + debugPrint('[NOTIF-BGENGINE] decryptAndShow error: $e'); return false; } finally { // Let the async key-backup upload settle before closing the DB — otherwise @@ -138,10 +138,10 @@ Future _bgSendReply(String? roomId, String? text) async { return false; } await room.sendTextEvent(text.trim()); - print('[NOTIF-BGENGINE] encrypted reply sent to $roomId'); + debugPrint('[NOTIF-BGENGINE] encrypted reply sent to $roomId'); return true; } catch (e) { - print('[NOTIF-BGENGINE] sendReply error: $e'); + debugPrint('[NOTIF-BGENGINE] sendReply error: $e'); final prefs = await SharedPreferences.getInstance(); await prefs.setString('notif_pending_reply_room', roomId); await prefs.setString('notif_pending_reply_text', text); @@ -163,7 +163,7 @@ Future registerBgEngineHandle() async { final prefs = await SharedPreferences.getInstance(); await prefs.setInt('bg_engine_handle', handle.toRawHandle()); } catch (e) { - print('[NOTIF-BGENGINE] registerBgEngineHandle failed: $e'); + debugPrint('[NOTIF-BGENGINE] registerBgEngineHandle failed: $e'); } } @@ -212,7 +212,7 @@ Future _buildClient() async { return client; } catch (e) { - print('[NOTIF-BGENGINE] _buildClient failed: $e'); + debugPrint('[NOTIF-BGENGINE] _buildClient failed: $e'); return null; } } @@ -241,8 +241,8 @@ Future handleBackgroundNotificationResponse( NotificationResponse details) async { WidgetsFlutterBinding.ensureInitialized(); - print('[NOTIF-BG] handleBackgroundNotificationResponse fired'); - print('[NOTIF-BG] actionId=${details.actionId} payload=${details.payload} input=${details.input} id=${details.id}'); + debugPrint('[NOTIF-BG] handleBackgroundNotificationResponse fired'); + debugPrint('[NOTIF-BG] actionId=${details.actionId} payload=${details.payload} input=${details.input} id=${details.id}'); // ── Fast path: main isolate is running ─────────────────────────────────── // If the Pyramid UI process is alive (app is backgrounded but not killed), @@ -250,7 +250,7 @@ Future handleBackgroundNotificationResponse( // any new engine and works silently without bringing the app to foreground. final sendPort = IsolateNameServer.lookupPortByName(kMainIsolateName); if (sendPort != null) { - print('[NOTIF-BG] main isolate alive → forwarding via IsolateNameServer'); + debugPrint('[NOTIF-BG] main isolate alive → forwarding via IsolateNameServer'); sendPort.send({ 'actionId': details.actionId, 'payload': details.payload, @@ -264,7 +264,7 @@ Future handleBackgroundNotificationResponse( // Main isolate is gone. Dismiss the notification and, for reply actions, // persist the text in SharedPreferences so _sendPendingReply picks it up // the next time the app opens (via getInitialReply cold-start flow). - print('[NOTIF-BG] main isolate not running → SharedPreferences fallback'); + debugPrint('[NOTIF-BG] main isolate not running → SharedPreferences fallback'); final plugin = FlutterLocalNotificationsPlugin(); await plugin.initialize( @@ -276,20 +276,20 @@ Future handleBackgroundNotificationResponse( final roomId = details.payload; if (roomId != null) { await plugin.cancel(_stableId(roomId)); - print('[NOTIF-BG] cancelled notification for room $roomId'); + debugPrint('[NOTIF-BG] cancelled notification for room $roomId'); } else if (details.id != null) { await plugin.cancel(details.id!); - print('[NOTIF-BG] cancelled notification id ${details.id}'); + debugPrint('[NOTIF-BG] cancelled notification id ${details.id}'); } if (details.actionId != 'reply') { - print('[NOTIF-BG] not a reply action, done'); + debugPrint('[NOTIF-BG] not a reply action, done'); return; } final text = details.input?.trim() ?? ''; if (text.isEmpty || roomId == null) { - print('[NOTIF-BG] text empty or roomId null, aborting'); + debugPrint('[NOTIF-BG] text empty or roomId null, aborting'); return; } @@ -297,6 +297,6 @@ Future handleBackgroundNotificationResponse( // _bgSendReply falls back to the prefs queue if it can't send (so the main app // delivers it on next launch). final sent = await _bgSendReply(roomId, text); - print('[NOTIF-BG] background reply sent=$sent room=$roomId'); + debugPrint('[NOTIF-BG] background reply sent=$sent room=$roomId'); } diff --git a/lib/core/livekit_call_manager.dart b/lib/core/livekit_call_manager.dart index 67f88e0..025c018 100644 --- a/lib/core/livekit_call_manager.dart +++ b/lib/core/livekit_call_manager.dart @@ -1,4 +1,3 @@ -// ignore_for_file: avoid_print import 'dart:async'; import 'package:flutter/foundation.dart'; @@ -119,7 +118,7 @@ class LiveKitCallManager with ChangeNotifier { } await client.setRoomStateWithKey(roomId, _kVoicePresenceType, userId, content); } catch (e) { - print('[VoicePresence] $e'); + debugPrint('[VoicePresence] $e'); } } @@ -185,7 +184,7 @@ class LiveKitCallManager with ChangeNotifier { .toList(), ); } catch (e) { - print('[LiveKit] ICE server fetch error: $e'); + debugPrint('[LiveKit] ICE server fetch error: $e'); } await room.connect( @@ -252,7 +251,7 @@ class LiveKitCallManager with ChangeNotifier { final devices = await rtc.navigator.mediaDevices.enumerateDevices(); deviceIds = devices.map((d) => d.deviceId).toSet(); } catch (e) { - print('[LiveKit] Device prefs/enumerate error: $e'); + debugPrint('[LiveKit] Device prefs/enumerate error: $e'); } if (prefMic != null && !deviceIds.contains(prefMic)) prefMic = null; if (prefSpeaker != null && !deviceIds.contains(prefSpeaker)) prefSpeaker = null; @@ -268,7 +267,7 @@ class LiveKitCallManager with ChangeNotifier { try { await rtc.Helper.selectAudioOutput(prefSpeaker); } catch (e) { - print('[LiveKit] selectAudioOutput error: $e'); + debugPrint('[LiveKit] selectAudioOutput error: $e'); } } @@ -282,13 +281,13 @@ class LiveKitCallManager with ChangeNotifier { ), ); } catch (e) { - print('[LiveKit] Failed to enable camera: $e'); + debugPrint('[LiveKit] Failed to enable camera: $e'); } } _startStatsLogging(); } catch (e) { - print('[VOIP] Start call error: $e'); + debugPrint('[VOIP] Start call error: $e'); isConnecting = false; error = e.toString(); _cleanUpAfterDisconnect(); @@ -325,7 +324,7 @@ class LiveKitCallManager with ChangeNotifier { } Future setSubscribeQuality(String key) async { - print('[LiveKit] Viewer changing subscribe quality to: $key'); + debugPrint('[LiveKit] Viewer changing subscribe quality to: $key'); _subscribeQualityKey = key; if (_room == null) { notifyListeners(); return; } @@ -333,7 +332,7 @@ class LiveKitCallManager with ChangeNotifier { for (final p in _room!.remoteParticipants.values) { for (final pub in p.videoTrackPublications) { if (pub.kind == TrackType.VIDEO) { - print('[LiveKit] Setting subscription quality for ${p.identity} to $quality'); + debugPrint('[LiveKit] Setting subscription quality for ${p.identity} to $quality'); pub.setVideoQuality(quality); } } @@ -387,13 +386,13 @@ class LiveKitCallManager with ChangeNotifier { ); isCameraOff = false; } catch (e) { - print('[LiveKit] toggleCamera ON error: $e'); + debugPrint('[LiveKit] toggleCamera ON error: $e'); } } else { try { await _room?.localParticipant?.setCameraEnabled(false); } catch (e) { - print('[LiveKit] toggleCamera OFF error: $e'); + debugPrint('[LiveKit] toggleCamera OFF error: $e'); } isCameraOff = true; } @@ -417,7 +416,7 @@ class LiveKitCallManager with ChangeNotifier { isScreenSharing = true; notifyListeners(); } catch (e) { - print('[ScreenShare] Toggle error: $e'); + debugPrint('[ScreenShare] Toggle error: $e'); } } } @@ -455,7 +454,7 @@ class LiveKitCallManager with ChangeNotifier { notifyListeners(); unawaited(_applyFpsToAllSimulcastLayers(track)); } catch (e) { - print('[ScreenShare] ERROR: $e'); + debugPrint('[ScreenShare] ERROR: $e'); } } @@ -531,7 +530,7 @@ class LiveKitCallManager with ChangeNotifier { } Future changeQuality(String qualityKey) async { - print('[LiveKit] Streamer changing publish quality to: $qualityKey'); + debugPrint('[LiveKit] Streamer changing publish quality to: $qualityKey'); _localQualityKey = qualityKey; final params = qualityPresets[qualityKey]; if (params == null) { notifyListeners(); return; } @@ -549,7 +548,7 @@ class LiveKitCallManager with ChangeNotifier { cameraCaptureOptions: CameraCaptureOptions(params: params), ); } catch (e) { - print('[LiveKit] Camera restart error: $e'); + debugPrint('[LiveKit] Camera restart error: $e'); isCameraOff = true; } } @@ -573,7 +572,7 @@ class LiveKitCallManager with ChangeNotifier { } await participant.publishAudioTrack(track); if (isMuted) await participant.setMicrophoneEnabled(false); - } catch (e) { print('[Audio] error: $e'); } + } catch (e) { debugPrint('[Audio] error: $e'); } } void setRemoteVolume(double volume) { @@ -599,6 +598,6 @@ class LiveKitCallManager with ChangeNotifier { Future _logStats() async { if (_room == null) return; // Basic stats logging... - print('[Stats] SubQuality: $_subscribeQualityKey | PubQuality: $_localQualityKey'); + debugPrint('[Stats] SubQuality: $_subscribeQualityKey | PubQuality: $_localQualityKey'); } } diff --git a/lib/core/matrix_client.dart b/lib/core/matrix_client.dart index 24402dc..3622917 100644 --- a/lib/core/matrix_client.dart +++ b/lib/core/matrix_client.dart @@ -36,7 +36,7 @@ final matrixClientProvider = FutureProvider((ref) async { await db.execute('PRAGMA journal_mode=WAL'); await db.execute('PRAGMA busy_timeout = 5000'); } catch (e) { - if (kDebugMode) print('Could not set PRAGMAs: $e'); + if (kDebugMode) debugPrint('Could not set PRAGMAs: $e'); } final sdkDb = await MatrixSdkDatabase.init('pyramid', database: db); diff --git a/lib/core/notification_service.dart b/lib/core/notification_service.dart index 9173185..60a800a 100644 --- a/lib/core/notification_service.dart +++ b/lib/core/notification_service.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'dart:isolate'; import 'dart:ui'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -72,61 +73,61 @@ Future _initAndroid(WidgetRef ref) async { IsolateNameServer.registerPortWithName( _mainIsolatePort!.sendPort, kMainIsolateName); _mainIsolatePort!.listen((msg) => _onIsolateMessage(msg, ref)); - print('[NOTIF] IsolateNameServer port registered: $kMainIsolateName'); + debugPrint('[NOTIF] IsolateNameServer port registered: $kMainIsolateName'); await _androidPlugin.initialize( const InitializationSettings( android: AndroidInitializationSettings('@drawable/ic_notification'), ), onDidReceiveNotificationResponse: (details) { - print('[NOTIF-FG] onDidReceiveNotificationResponse fired'); - print('[NOTIF-FG] actionId=${details.actionId} payload=${details.payload} input=${details.input}'); + debugPrint('[NOTIF-FG] onDidReceiveNotificationResponse fired'); + debugPrint('[NOTIF-FG] actionId=${details.actionId} payload=${details.payload} input=${details.input}'); if (details.actionId == 'reply') { final text = details.input?.trim() ?? ''; final roomId = details.payload; - print('[NOTIF-FG] reply: text="$text" roomId=$roomId'); + debugPrint('[NOTIF-FG] reply: text="$text" roomId=$roomId'); if (text.isNotEmpty && roomId != null && roomId.isNotEmpty) { _androidPlugin.cancel(_stableRoomId(roomId)); ref.read(matrixClientProvider.future).then((client) async { final room = client.getRoomById(roomId); - print('[NOTIF-FG] getRoomById → ${room != null ? 'found' : 'null'}'); + debugPrint('[NOTIF-FG] getRoomById → ${room != null ? 'found' : 'null'}'); if (room != null) { try { await room.sendTextEvent(text); - print('[NOTIF-FG] sendTextEvent OK'); + debugPrint('[NOTIF-FG] sendTextEvent OK'); } catch (e) { - print('[NOTIF-FG] sendTextEvent failed: $e — storing in prefs'); + debugPrint('[NOTIF-FG] sendTextEvent failed: $e — storing in prefs'); final prefs = await SharedPreferences.getInstance(); await prefs.setString('notif_pending_reply_room', roomId); await prefs.setString('notif_pending_reply_text', text); } } else { - print('[NOTIF-FG] room null — storing in prefs, waiting for sync'); + debugPrint('[NOTIF-FG] room null — storing in prefs, waiting for sync'); final prefs = await SharedPreferences.getInstance(); await prefs.setString('notif_pending_reply_room', roomId); await prefs.setString('notif_pending_reply_text', text); try { await client.onSync.stream.first; - print('[NOTIF-FG] sync arrived — retrying _sendPendingReply'); + debugPrint('[NOTIF-FG] sync arrived — retrying _sendPendingReply'); await _sendPendingReply(ref); } catch (e) { - print('[NOTIF-FG] sync/send error: $e'); + debugPrint('[NOTIF-FG] sync/send error: $e'); } } }); } else { - print('[NOTIF-FG] reply skipped: text empty or roomId null'); + debugPrint('[NOTIF-FG] reply skipped: text empty or roomId null'); } return; } if (details.actionId == 'read') { final roomId = details.payload; if (roomId != null) _androidPlugin.cancel(_stableRoomId(roomId)); - print('[NOTIF-FG] read action — dismissed'); + debugPrint('[NOTIF-FG] read action — dismissed'); return; } final roomId = details.payload; - print('[NOTIF-FG] tap → opening room $roomId'); + debugPrint('[NOTIF-FG] tap → opening room $roomId'); if (roomId != null && roomId.isNotEmpty) { ref.read(activeRoomIdProvider.notifier).state = roomId; ref.read(viewModeProvider.notifier).state = ViewMode.chat; @@ -145,7 +146,7 @@ Future _initAndroid(WidgetRef ref) async { final args = call.arguments; if (call.method == 'openRoom') { final roomId = (args is Map ? args['room_id'] : null) as String?; - print('[NOTIF-FG] openRoom: $roomId'); + debugPrint('[NOTIF-FG] openRoom: $roomId'); if (roomId != null && roomId.isNotEmpty) { ref.read(activeRoomIdProvider.notifier).state = roomId; ref.read(viewModeProvider.notifier).state = ViewMode.chat; @@ -156,7 +157,7 @@ Future _initAndroid(WidgetRef ref) async { // MethodChannel — no Activity was opened. final roomId = (args is Map ? args['room_id'] : null) as String?; final text = (args is Map ? args['text'] : null) as String?; - print('[NOTIF-FG] replyFromNotification: room=$roomId text=$text'); + debugPrint('[NOTIF-FG] replyFromNotification: room=$roomId text=$text'); if (roomId != null && roomId.isNotEmpty && text != null && text.isNotEmpty) { _androidPlugin.cancel(_stableRoomId(roomId)); Future storePending() async { @@ -170,9 +171,9 @@ Future _initAndroid(WidgetRef ref) async { final room = client.getRoomById(roomId); if (room != null) { await room.sendTextEvent(text); - print('[NOTIF-FG] replyFromNotification: sent OK'); + debugPrint('[NOTIF-FG] replyFromNotification: sent OK'); } else { - print('[NOTIF-FG] replyFromNotification: room null, storing in prefs'); + debugPrint('[NOTIF-FG] replyFromNotification: room null, storing in prefs'); await storePending(); // Retry on the next sync — room list is populated after first sync. client.onSync.stream.first @@ -180,7 +181,7 @@ Future _initAndroid(WidgetRef ref) async { .catchError((_) {}); } } catch (e) { - print('[NOTIF-FG] replyFromNotification error: $e — storing in prefs'); + debugPrint('[NOTIF-FG] replyFromNotification error: $e — storing in prefs'); await storePending(); // Resume-based retry (checkPendingReply in app.dart) will pick this up. } @@ -225,7 +226,7 @@ Future _initAndroid(WidgetRef ref) async { if (reply is Map) { final roomId = reply['room_id'] as String?; final text = reply['text'] as String?; - print('[NOTIF-REPLY] getInitialReply: roomId=$roomId text=$text'); + debugPrint('[NOTIF-REPLY] getInitialReply: roomId=$roomId text=$text'); if (roomId != null && roomId.isNotEmpty && text != null && text.isNotEmpty) { // Persist so _sendPendingReply sends it after the first sync. final prefs = await SharedPreferences.getInstance(); @@ -302,7 +303,7 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) { final input = message['input'] as String?; final id = message['id'] as int?; - print('[NOTIF-ISOLATE] action=$actionId payload=$payload input=$input'); + debugPrint('[NOTIF-ISOLATE] action=$actionId payload=$payload input=$input'); switch (actionId) { case 'reply': @@ -315,9 +316,9 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) { if (room != null) { try { await room.sendTextEvent(text); - print('[NOTIF-ISOLATE] reply sent OK'); + debugPrint('[NOTIF-ISOLATE] reply sent OK'); } catch (e) { - print('[NOTIF-ISOLATE] sendTextEvent failed: $e — storing in prefs'); + debugPrint('[NOTIF-ISOLATE] sendTextEvent failed: $e — storing in prefs'); final prefs = await SharedPreferences.getInstance(); await prefs.setString('notif_pending_reply_room', roomId); await prefs.setString('notif_pending_reply_text', text); @@ -326,7 +327,7 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) { .catchError((_) {}); } } else { - print('[NOTIF-ISOLATE] room not in memory — storing in prefs'); + debugPrint('[NOTIF-ISOLATE] room not in memory — storing in prefs'); final prefs = await SharedPreferences.getInstance(); await prefs.setString('notif_pending_reply_room', roomId); await prefs.setString('notif_pending_reply_text', text); @@ -342,14 +343,14 @@ void _onIsolateMessage(dynamic message, WidgetRef ref) { } else if (id != null) { _androidPlugin.cancel(id); } - print('[NOTIF-ISOLATE] read → notification dismissed'); + debugPrint('[NOTIF-ISOLATE] read → notification dismissed'); default: // Plain notification tap → navigate to room. if (payload != null && payload.isNotEmpty) { ref.read(activeRoomIdProvider.notifier).state = payload; ref.read(viewModeProvider.notifier).state = ViewMode.chat; - print('[NOTIF-ISOLATE] tap → navigated to $payload'); + debugPrint('[NOTIF-ISOLATE] tap → navigated to $payload'); } } } @@ -361,16 +362,16 @@ Future _sendPendingReply(WidgetRef ref) async { final prefs = await SharedPreferences.getInstance(); final roomId = prefs.getString('notif_pending_reply_room'); final text = prefs.getString('notif_pending_reply_text'); - print('[NOTIF-REPLY] _sendPendingReply: roomId=$roomId text=$text'); + debugPrint('[NOTIF-REPLY] _sendPendingReply: roomId=$roomId text=$text'); if (roomId == null || text == null || text.isEmpty) return; final client = await ref.read(matrixClientProvider.future); - print('[NOTIF-REPLY] client ready, rooms=${client.rooms.length}'); + debugPrint('[NOTIF-REPLY] client ready, rooms=${client.rooms.length}'); final room = client.getRoomById(roomId); - print('[NOTIF-REPLY] getRoomById → ${room != null ? 'found' : 'null'}'); + debugPrint('[NOTIF-REPLY] getRoomById → ${room != null ? 'found' : 'null'}'); if (room == null) { - print('[NOTIF-REPLY] room not in memory yet, retrying after next sync'); + debugPrint('[NOTIF-REPLY] room not in memory yet, retrying after next sync'); client.onSync.stream.first .then((_) => _sendPendingReply(ref)) .catchError((_) {}); @@ -378,11 +379,11 @@ Future _sendPendingReply(WidgetRef ref) async { } await room.sendTextEvent(text); - print('[NOTIF-REPLY] sendTextEvent OK, clearing prefs'); + debugPrint('[NOTIF-REPLY] sendTextEvent OK, clearing prefs'); await prefs.remove('notif_pending_reply_room'); await prefs.remove('notif_pending_reply_text'); } catch (e) { - print('[NOTIF-REPLY] error: $e — prefs kept for retry'); + debugPrint('[NOTIF-REPLY] error: $e — prefs kept for retry'); } } @@ -459,7 +460,7 @@ Future _decryptAndUpdateNotification( .timeout(const Duration(seconds: 5)); var room = client.getRoomById(roomId); if (room == null) { - print('[NOTIF] decryptAndUpdate: room $roomId not found'); + debugPrint('[NOTIF] decryptAndUpdate: room $roomId not found'); return; } @@ -469,7 +470,7 @@ Future _decryptAndUpdateNotification( final bool alreadyHave = eventId == null || event?.eventId == eventId; if (!alreadyHave || event == null) { - print('[NOTIF] decryptAndUpdate: waiting for sync to deliver $eventId'); + debugPrint('[NOTIF] decryptAndUpdate: waiting for sync to deliver $eventId'); await client.onSync.stream.first.timeout(const Duration(seconds: 12)); room = client.getRoomById(roomId); if (room == null) return; @@ -477,7 +478,7 @@ Future _decryptAndUpdateNotification( } if (event == null) { - print('[NOTIF] decryptAndUpdate: event still null after sync'); + debugPrint('[NOTIF] decryptAndUpdate: event still null after sync'); return; } if (event.type != EventTypes.Message) return; @@ -486,7 +487,7 @@ Future _decryptAndUpdateNotification( final rawBody = event.body; // If decryption failed the body starts with "** Unable to decrypt" if (rawBody.isEmpty || rawBody.startsWith('**')) { - print('[NOTIF] decryptAndUpdate: decryption failed, keeping placeholder'); + debugPrint('[NOTIF] decryptAndUpdate: decryption failed, keeping placeholder'); return; } @@ -507,9 +508,9 @@ Future _decryptAndUpdateNotification( 'roomId': roomId, 'notifId': notifId ?? _stableRoomId(roomId), }); - print('[NOTIF] decryptAndUpdate: updated notification → "$title: $notifBody"'); + debugPrint('[NOTIF] decryptAndUpdate: updated notification → "$title: $notifBody"'); } catch (e) { - print('[NOTIF] decryptAndUpdate error: $e'); + debugPrint('[NOTIF] decryptAndUpdate error: $e'); } } @@ -533,7 +534,7 @@ Future showMessageNotification({ 'notifId': _stableRoomId(roomId), }); } catch (e) { - print('[NOTIF] showNativeNotification failed: $e'); + debugPrint('[NOTIF] showNativeNotification failed: $e'); } } else if (Platform.isWindows) { // Close the previous notification for this room before showing a new one. diff --git a/lib/core/voip_manager.dart b/lib/core/voip_manager.dart index 826bd19..01a8fde 100644 --- a/lib/core/voip_manager.dart +++ b/lib/core/voip_manager.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc; import 'package:matrix/matrix.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -54,7 +53,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { await remoteRenderer.initialize(); _renderersInitialized = true; } catch (e) { - print('[VOIP] Renderer init error: $e'); + debugPrint('[VOIP] Renderer init error: $e'); } } @@ -80,14 +79,14 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { merged['iceServers'] = [...existing, ...extra]; configuration = merged; } catch (e) { - print('[VOIP] ICE server merge error: $e'); + debugPrint('[VOIP] ICE server merge error: $e'); } return rtc.createPeerConnection(configuration, constraints); } @override Future handleNewCall(CallSession call) async { - print('[VOIP] Incoming call ${call.callId} (type: ${call.type})'); + debugPrint('[VOIP] Incoming call ${call.callId} (type: ${call.type})'); await _ensureRenderers(); currentCall = call; _isCameraMuted = call.type == CallType.kVoice; @@ -99,12 +98,12 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { Timer? _renderRefreshTimer; void _setupCallListeners(CallSession call) { call.onCallStateChanged.stream.listen((state) { - print('[VOIP] State: $state'); + debugPrint('[VOIP] State: $state'); _updateInternalStates(); if (state == CallState.kConnected) { if (!_isCameraMuted) { - print('[VOIP] Ensuring camera is unmuted on connect'); + debugPrint('[VOIP] Ensuring camera is unmuted on connect'); call.setLocalVideoMuted(false); } } @@ -204,7 +203,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { bool changed = false; if (remote != null && remote.getVideoTracks().isNotEmpty) { if (remoteRenderer.srcObject?.id != remote.id) { - print('[VOIP] Assigning Remote Renderer: ${remote.id} (${remote.getVideoTracks().length} video tracks)'); + debugPrint('[VOIP] Assigning Remote Renderer: ${remote.id} (${remote.getVideoTracks().length} video tracks)'); remoteRenderer.srcObject = remote; changed = true; } @@ -215,7 +214,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { if (local != null && local.getVideoTracks().isNotEmpty) { if (localRenderer.srcObject?.id != local.id) { - print('[VOIP] Assigning Local Renderer: ${local.id} (${local.getVideoTracks().length} video tracks)'); + debugPrint('[VOIP] Assigning Local Renderer: ${local.id} (${local.getVideoTracks().length} video tracks)'); localRenderer.srcObject = local; changed = true; } @@ -226,7 +225,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { if (changed) notifyListeners(); } catch (e) { - print('[VOIP] Error in _updateRenderers: $e'); + debugPrint('[VOIP] Error in _updateRenderers: $e'); } finally { _isUpdating = false; } @@ -301,7 +300,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { await action(); await Future.delayed(const Duration(milliseconds: 1000)); } catch (e) { - print('[VOIP] Action error: $e'); + debugPrint('[VOIP] Action error: $e'); } _updateInternalStates(); _updateRenderers(); @@ -330,7 +329,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { await _updateRenderers(); } } catch (e) { - print('[VOIP] toggleCamera error: $e'); + debugPrint('[VOIP] toggleCamera error: $e'); _isCameraMuted = !_isCameraMuted; notifyListeners(); } @@ -379,7 +378,7 @@ class PyramidVoipManager extends ChangeNotifier implements WebRTCDelegate { await _ensureRenderers(); _isCameraMuted = !video; - print('[VOIP] Starting call in room $roomId (video=$video)'); + debugPrint('[VOIP] Starting call in room $roomId (video=$video)'); final call = await voip.inviteToCall(room, video ? CallType.kVideo : CallType.kVoice); currentCall = call; diff --git a/lib/widgets/screen_share_picker.dart b/lib/widgets/screen_share_picker.dart index 3df258e..07116d9 100644 --- a/lib/widgets/screen_share_picker.dart +++ b/lib/widgets/screen_share_picker.dart @@ -42,7 +42,7 @@ class _ScreenSharePickerState extends State with SingleTicker }); } } catch (e) { - print('[Picker] Error loading sources: $e'); + debugPrint('[Picker] Error loading sources: $e'); if (mounted) setState(() => _loading = false); } }