Skip to content
19 changes: 10 additions & 9 deletions mobile-app/lib/app_lifecycle_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:resonance_network_wallet/providers/connectivity_provider.dart';
import 'package:resonance_network_wallet/providers/remote_config_provider.dart';
import 'package:resonance_network_wallet/providers/local_auth_provider.dart';
import 'package:resonance_network_wallet/services/history_polling_manager.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

/// Provider that holds the current app lifecycle state
final appLifecycleStateProvider = StateProvider<AppLifecycleState>((ref) => AppLifecycleState.resumed);
Expand Down Expand Up @@ -55,17 +56,17 @@ class _AppLifecycleManagerState extends ConsumerState<AppLifecycleManager> with
final appState = ref.read(appLifecycleStateProvider);

if (status == NetworkStatus.online && appState == AppLifecycleState.resumed) {
print('Back online - resuming polling');
quantusDebugPrint('Back online - resuming polling');
pollingManager.resumePolling();
pollingManager.triggerSilentRefresh();
} else if (status == NetworkStatus.offline) {
print('Gone offline - pausing polling');
quantusDebugPrint('Gone offline - pausing polling');
pollingManager.pausePolling();
}
},
loading: () {},
error: (e, _) {
print('Error listening to network status: $e');
quantusDebugPrint('Error listening to network status: $e');
},
);
});
Expand All @@ -87,15 +88,15 @@ class _AppLifecycleManagerState extends ConsumerState<AppLifecycleManager> with
if (state == AppLifecycleState.resumed) {
// Only resume if we were previously backgrounded
if (_isBackgrounded) {
print('AppLifecycleState.resumed - resuming from background');
quantusDebugPrint('AppLifecycleState.resumed - resuming from background');
_isBackgrounded = false;

// Only resume polling if online
if (isOnline) {
pollingManager.resumePolling();
pollingManager.triggerSilentRefresh();
} else {
print('App resumed but offline - polling paused');
quantusDebugPrint('App resumed but offline - polling paused');
}

// Check authentication ONLY on resume from background.
Expand All @@ -114,13 +115,13 @@ class _AppLifecycleManagerState extends ConsumerState<AppLifecycleManager> with
// Skip if the biometric dialog caused this lifecycle change — on some
// Android devices the prompt triggers inactive→resumed oscillation.
if (!_isBackgrounded && !ref.read(localAuthProvider).isAuthenticating) {
print('AppLifecycleState.$state - pausing (update pause time only)');
quantusDebugPrint('AppLifecycleState.$state - pausing (update pause time only)');
_isBackgrounded = true;

pollingManager.pausePolling();
localAuthNotifier.recordBackgroundTime();
} else {
print('AppLifecycleState.$state - already backgrounded, skipping actions');
quantusDebugPrint('AppLifecycleState.$state - already backgrounded, skipping actions');
}
}
}
Expand All @@ -134,10 +135,10 @@ class _AppLifecycleManagerState extends ConsumerState<AppLifecycleManager> with
if (hasWallet) {
final taskmasterService = TaskmasterService();
await taskmasterService.ensureIsLoggedIn();
print('Taskmaster login initialized');
quantusDebugPrint('Taskmaster login initialized');
}
} catch (e) {
print('Failed to initialize taskmaster login: $e');
quantusDebugPrint('Failed to initialize taskmaster login: $e');
}
}

Expand Down
5 changes: 3 additions & 2 deletions mobile-app/lib/providers/account_associations_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_riverpod/legacy.dart';
import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/providers/account_providers.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

class AccountAssociationsNotifier extends StateNotifier<AsyncValue<AccountAssociations>> {
final TaskmasterService _taskmasterService = TaskmasterService();
Expand All @@ -22,8 +23,8 @@ class AccountAssociationsNotifier extends StateNotifier<AsyncValue<AccountAssoci
state = AsyncValue.data(associations);
}
} catch (e, st) {
print('Error fetching account associations: $e');
print('Stack trace: $st');
quantusDebugPrint('Error fetching account associations: $e');
quantusDebugPrint('Stack trace: $st');

if (mounted) {
state = AsyncValue.error(e, st);
Expand Down
11 changes: 6 additions & 5 deletions mobile-app/lib/providers/account_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_riverpod/legacy.dart';
import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/providers/wallet_providers.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

class AccountsNotifier extends StateNotifier<AsyncValue<List<Account>>> {
final AccountsService _accountsService;
Expand All @@ -25,7 +26,7 @@ class AccountsNotifier extends StateNotifier<AsyncValue<List<Account>>> {
await _accountsService.addAccount(account);
state = AsyncValue.data([...accounts, account]);
} catch (e, st) {
print('error adding account $e $st');
quantusDebugPrint('error adding account $e $st');
// Handle error, maybe revert state or show a message
}
});
Expand All @@ -38,7 +39,7 @@ class AccountsNotifier extends StateNotifier<AsyncValue<List<Account>>> {
final newAccounts = accounts.where((a) => a.accountId != account.accountId).toList();
state = AsyncValue.data(newAccounts);
} catch (e, st) {
print('remove account error $e $st');
quantusDebugPrint('remove account error $e $st');
}
});
}
Expand Down Expand Up @@ -67,10 +68,10 @@ class ActiveAccountNotifier extends StateNotifier<AsyncValue<DisplayAccount?>> {
Future<void> _loadActiveAccount() async {
try {
final account = await _settingsService.getActiveAccount();
print('loaded active account: ${account?.account.name}');
quantusDebugPrint('loaded active account: ${account?.account.name}');
state = AsyncValue.data(account);
} catch (e, st) {
print('error loading active account: $e $st');
quantusDebugPrint('error loading active account: $e $st');
state = AsyncValue.error(e, st);
}
}
Expand All @@ -80,7 +81,7 @@ class ActiveAccountNotifier extends StateNotifier<AsyncValue<DisplayAccount?>> {
await _settingsService.setActiveAccount(account);
state = AsyncValue.data(account);
} catch (e, st) {
print('setActiveAccount error $e $st');
quantusDebugPrint('setActiveAccount error $e $st');
}
}

Expand Down
3 changes: 2 additions & 1 deletion mobile-app/lib/providers/entrusted_account_provider.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

final entrustedAccountsProvider = FutureProvider.family<List<EntrustedAccount>, Account>((ref, account) async {
final highSecurityService = HighSecurityService();
final interceptedAccounts = await highSecurityService.getEntrustedAccounts(account);
print('intercepted accounts: ${interceptedAccounts.map((account) => account.accountId).join(', ')}');
quantusDebugPrint('intercepted accounts: ${interceptedAccounts.map((account) => account.accountId).join(', ')}');
return interceptedAccounts;
});
5 changes: 3 additions & 2 deletions mobile-app/lib/providers/notification_config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';

import 'package:flutter_riverpod/legacy.dart';
import 'package:resonance_network_wallet/models/notification_models.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';
import 'package:shared_preferences/shared_preferences.dart';

const String notificationConfigKey = 'notification_config';
Expand Down Expand Up @@ -37,7 +38,7 @@ class NotificationConfigNotifier extends StateNotifier<NotificationConfig> {
state = NotificationConfig.fromJson(Map<String, dynamic>.from(jsonDecode(configJson)));
}
} catch (e) {
print('Error loading notification config: $e');
quantusDebugPrint('Error loading notification config: $e');
}
}

Expand All @@ -46,7 +47,7 @@ class NotificationConfigNotifier extends StateNotifier<NotificationConfig> {
final prefs = await SharedPreferences.getInstance();
await prefs.setString(notificationConfigKey, jsonEncode(state.toJson()));
} catch (e) {
print('Error saving notification config: $e');
quantusDebugPrint('Error saving notification config: $e');
}
}

Expand Down
15 changes: 8 additions & 7 deletions mobile-app/lib/providers/notification_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/models/notification_models.dart';
import 'package:resonance_network_wallet/providers/notification_config_provider.dart';
import 'package:resonance_network_wallet/services/local_notifications_service.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';
import 'package:shared_preferences/shared_preferences.dart';

/// Maximum number of notifications to keep (FIFO)
Expand Down Expand Up @@ -64,13 +65,13 @@ class NotificationNotifier extends StateNotifier<List<NotificationData>> {
Future<bool> canShowNotification(NotificationIntent type) async {
// Check app-level master setting
if (!_config.enabled) {
print('Notifications disabled at app level');
quantusDebugPrint('Notifications disabled at app level');
return false;
}

// Check specific notification type setting
if (!_config.isIntentEnabled(type)) {
print('Notification type ${type.name} is disabled');
quantusDebugPrint('Notification type ${type.name} is disabled');
return false;
}

Expand All @@ -80,7 +81,7 @@ class NotificationNotifier extends StateNotifier<List<NotificationData>> {
/// Check if any notifications can be shown (master check)
Future<bool> canShowNotifications() async {
if (!_config.enabled) {
print('Notifications disabled at app level');
quantusDebugPrint('Notifications disabled at app level');
return false;
}

Expand Down Expand Up @@ -132,7 +133,7 @@ class NotificationNotifier extends StateNotifier<List<NotificationData>> {
final scheduledDate = notification.scheduledTime!;
final duration = scheduledDate.difference(DateTime.now());

print('DURATION ${scheduledDate.toString()}');
quantusDebugPrint('DURATION ${scheduledDate.toString()}');

// Schedule timer to show notification at the right time
final timer = Timer(duration, () {
Expand Down Expand Up @@ -162,7 +163,7 @@ class NotificationNotifier extends StateNotifier<List<NotificationData>> {

// Check if this specific notification intent can be shown
if (!await canShowNotification(notification.intent)) {
print('Cannot show ${notification.intent.name} notification: disabled or permission not granted');
quantusDebugPrint('Cannot show ${notification.intent.name} notification: disabled or permission not granted');
return;
}

Expand All @@ -186,15 +187,15 @@ class NotificationNotifier extends StateNotifier<List<NotificationData>> {
Future<void> cancelNotification(String notificationId) async {
final timer = _scheduledTimers.remove(notificationId);
timer?.cancel();
print('Cancelled scheduled notification: $notificationId');
quantusDebugPrint('Cancelled scheduled notification: $notificationId');
}

Future<void> cancelAllNotifications() async {
for (final timer in _scheduledTimers.values) {
timer.cancel();
}
_scheduledTimers.clear();
print('Cancelled all scheduled notifications');
quantusDebugPrint('Cancelled all scheduled notifications');
}

List<String> getScheduledNotificationIds() {
Expand Down
7 changes: 4 additions & 3 deletions mobile-app/lib/providers/pending_cancellations_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';

import 'package:flutter_riverpod/legacy.dart';
import 'package:resonance_network_wallet/models/pending_cancellation.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';
import 'package:shared_preferences/shared_preferences.dart';

final pendingCancellationsProvider = StateNotifierProvider<PendingCancellationsNotifier, Set<String>>((ref) {
Expand Down Expand Up @@ -37,7 +38,7 @@ class PendingCancellationsNotifier extends StateNotifier<Set<String>> {
if (isNotExpired) {
validCancellations.add(cancellation);
} else {
print('Removing expired pending cancellation: ${cancellation.transactionId}');
quantusDebugPrint('Removing expired pending cancellation: ${cancellation.transactionId}');
}
} catch (e) {
throw FormatException('Error parsing pending cancellation: $e');
Expand Down Expand Up @@ -76,7 +77,7 @@ class PendingCancellationsNotifier extends StateNotifier<Set<String>> {
existingCancellations.add(cancellation);
}
} catch (e) {
print('Error parsing existing cancellation: $e');
quantusDebugPrint('Error parsing existing cancellation: $e');
}
}

Expand Down Expand Up @@ -107,7 +108,7 @@ class PendingCancellationsNotifier extends StateNotifier<Set<String>> {
remainingCancellations.add(cancellation);
}
} catch (e) {
print('Error parsing cancellation during removal: $e');
quantusDebugPrint('Error parsing cancellation during removal: $e');
}
}

Expand Down
5 changes: 3 additions & 2 deletions mobile-app/lib/providers/raider_quest_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_riverpod/legacy.dart';
import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/providers/account_providers.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

class RaiderSubmissionsNotifier extends StateNotifier<AsyncValue<RaiderSubmissionsState>> {
final TaskmasterService _taskmasterService = TaskmasterService();
Expand All @@ -22,8 +23,8 @@ class RaiderSubmissionsNotifier extends StateNotifier<AsyncValue<RaiderSubmissio
state = AsyncValue.data(submissions);
}
} catch (e, st) {
print('Error fetching raider submissions: $e');
print('Stack trace: $st');
quantusDebugPrint('Error fetching raider submissions: $e');
quantusDebugPrint('Stack trace: $st');

if (mounted) {
state = AsyncValue.error(e, st);
Expand Down
3 changes: 2 additions & 1 deletion mobile-app/lib/providers/remote_config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/firebase_options.dart';
import 'package:resonance_network_wallet/services/remote_config_service.dart';
import 'package:resonance_network_wallet/services/firebase_messaging_service.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

final remoteConfigServiceProvider = Provider<RemoteConfigService>((ref) {
return RemoteConfigService();
Expand Down Expand Up @@ -39,7 +40,7 @@ class RemoteConfigNotifier extends StateNotifier<RemoteConfigModel> {
state = remote;
}
} catch (e) {
print('Remote config remote refresh failed: $e');
quantusDebugPrint('Remote config remote refresh failed: $e');
} finally {
_isRefreshingRemote = false;
}
Expand Down
3 changes: 2 additions & 1 deletion mobile-app/lib/providers/wallet_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/providers/account_providers.dart';
import 'package:resonance_network_wallet/providers/l10n_provider.dart';
import 'package:resonance_network_wallet/providers/pending_transactions_provider.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

final settingsServiceProvider = Provider<SettingsService>((ref) {
return SettingsService();
Expand Down Expand Up @@ -67,7 +68,7 @@ final isHighSecurityProvider = FutureProvider.family<bool, Account>((ref, accoun

final balanceProviderFamily = FutureProvider.family<BigInt, String>((ref, accountId) async {
final substrateService = ref.watch(substrateServiceProvider);
print('query balance for $accountId');
quantusDebugPrint('query balance for $accountId');
return await substrateService.queryBalance(accountId);
});

Expand Down
9 changes: 5 additions & 4 deletions mobile-app/lib/services/deep_link_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:app_links/app_links.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:resonance_network_wallet/providers/account_associations_providers.dart';
import 'package:resonance_network_wallet/providers/route_intent_providers.dart';
import 'package:resonance_network_wallet/shared/utils/print.dart';

final deepLinkServiceProvider = Provider<DeepLinkService>((ref) {
final service = DeepLinkService(ref);
Expand All @@ -21,14 +22,14 @@ class DeepLinkService {
Future<void> init() async {
// Handle links when the app is already open (warm state)
_linkSubscription = _appLinks.uriLinkStream.listen((uri) {
print('Received link while app is open: $uri');
quantusDebugPrint('Received link while app is open: $uri');
_handleLink(uri);
});

// Handle the link that opened the app (cold state)
final initialUri = await _appLinks.getInitialLink();
if (initialUri != null) {
print('Received initial link: $initialUri');
quantusDebugPrint('Received initial link: $initialUri');
_handleLink(initialUri);
}
}
Expand All @@ -49,7 +50,7 @@ class DeepLinkService {
if (accountId != null && accountId.isNotEmpty) {
_ref.read(sharedAccountIntentProvider.notifier).state = accountId;
} else {
print('Missing or empty account id');
quantusDebugPrint('Missing or empty account id');
}
}

Expand All @@ -58,7 +59,7 @@ class DeepLinkService {
if (payment != null) {
_ref.read(paymentIntentProvider.notifier).state = payment;
} else {
print('Missing payment parameters');
quantusDebugPrint('Missing payment parameters');
}
}

Expand Down
Loading
Loading