From 1412f4241573d3d1bd7fe882644f30b7e8233cc9 Mon Sep 17 00:00:00 2001 From: reasje Date: Fri, 26 Jul 2024 13:13:40 +0330 Subject: [PATCH 1/2] test: Blueberry ring connection --- ...eberry_ring_background_notifications_use_case.dart | 8 ++++---- lib/features/settings/presentation/settings_page.dart | 2 +- .../presentation/settings_page_presenter.dart | 11 +++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart b/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart index 7973340c..a13ad0cf 100644 --- a/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart +++ b/lib/features/common/packages/bluetooth/blueberry_ring/domain/blueberry_ring_background_notifications_use_case.dart @@ -27,7 +27,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { Future checkActivityReminder() async { final data = await _blueberryRingUseCase.readSteps(); - collectLog( + print( 'checkActivityReminder:data ${data.map((e) => e.toJson()).toList()}'); // Get spteps data from cache and compare // If steps is below a certain number then show a @@ -52,7 +52,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { Future checkSleepInsight() async { final data = await _blueberryRingUseCase.readSleep(); - collectLog( + print( 'checkSleepInsight:data ${data.map((e) => e.toJson()).toList()}'); // If sleeps is below standard level // loop throug all and get average @@ -86,7 +86,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { Future checkHeartAlert() async { final data = await _blueberryRingUseCase.readHeartRate(); - collectLog('checkHeartAlert:data ${data.map((e) => e.toJson()).toList()}'); + print('checkHeartAlert:data ${data.map((e) => e.toJson()).toList()}'); // If below standard but between person to person different final latestData = data.first; final lastDate = DateTime.fromMillisecondsSinceEpoch( @@ -108,7 +108,7 @@ class BlueberryRingBackgroundNotificationsUseCase extends ReactiveUseCase { Future checkLowBattery() async { final data = await _blueberryRingUseCase.readLevel(); - collectLog('checkLowBattery:data $data'); + print('checkLowBattery:data $data'); // What si the low battery level // Is 10 OK if (data < 20) { diff --git a/lib/features/settings/presentation/settings_page.dart b/lib/features/settings/presentation/settings_page.dart index 0c72b89f..548c0454 100644 --- a/lib/features/settings/presentation/settings_page.dart +++ b/lib/features/settings/presentation/settings_page.dart @@ -37,7 +37,7 @@ class SettingsPage extends HookConsumerWidget { height: Sizes.space2XLarge, ), GestureDetector( - onTap: AXSFireBase.incrementBuildTap, + onTap: presenter.testOnly, child: Text( '${FlutterI18n.translate(context, 'app_version')}${state.appVersion ?? ''}', style: FontTheme.of(context) diff --git a/lib/features/settings/presentation/settings_page_presenter.dart b/lib/features/settings/presentation/settings_page_presenter.dart index ea9bad61..44d5e35a 100644 --- a/lib/features/settings/presentation/settings_page_presenter.dart +++ b/lib/features/settings/presentation/settings_page_presenter.dart @@ -15,6 +15,10 @@ class SettingsPresenter extends CompletePresenter { late final _webviewUseCase = WebviewUseCase(); late final _authUseCase = ref.read(authUseCaseProvider); late final _accountUserCase = ref.read(accountUseCaseProvider); + late final blueberryRingBackgroundNotificationsUseCase = + ref.read(blueberryRingBackgroundNotificationsUseCaseProvider); + late final contextLessTranslationUseCase = + ref.read(contextLessTranslationUseCaseProvider); @override void initState() { @@ -102,4 +106,11 @@ class SettingsPresenter extends CompletePresenter { void loadCache() { _webviewUseCase.clearCache(); } + + void testOnly() async { + await blueberryRingBackgroundNotificationsUseCase.checkActivityReminder(); + await blueberryRingBackgroundNotificationsUseCase.checkSleepInsight(); + await blueberryRingBackgroundNotificationsUseCase.checkHeartAlert(); + await blueberryRingBackgroundNotificationsUseCase.checkLowBattery(); + } } From 5e66996143c429a248bf92a92dfeea9f0b1287ba Mon Sep 17 00:00:00 2001 From: reasje Date: Fri, 26 Jul 2024 13:42:02 +0330 Subject: [PATCH 2/2] fix: syntax --- .../domain/dapp_hooks_use_case.dart | 4 ++++ .../utils/blueberry_ring_helper.dart | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/features/settings/subfeatures/dapp_hooks/domain/dapp_hooks_use_case.dart b/lib/features/settings/subfeatures/dapp_hooks/domain/dapp_hooks_use_case.dart index 66cdfee2..c28983c2 100644 --- a/lib/features/settings/subfeatures/dapp_hooks/domain/dapp_hooks_use_case.dart +++ b/lib/features/settings/subfeatures/dapp_hooks/domain/dapp_hooks_use_case.dart @@ -374,6 +374,10 @@ class DAppHooksUseCase extends ReactiveUseCase { return false; } } + Future stopBlueberryAutoSyncService({required bool turnOffAll}) async { + return await AXSBackgroundFetch.stopServices( + taskId: blueberryAutoSyncTask, turnOffAll: turnOffAll); + } Future stopMinerAutoClaimService({required bool turnOffAll}) async { return await AXSBackgroundFetch.stopServices( diff --git a/lib/features/settings/subfeatures/dapp_hooks/utils/blueberry_ring_helper.dart b/lib/features/settings/subfeatures/dapp_hooks/utils/blueberry_ring_helper.dart index a21dd8df..d3bab3ab 100644 --- a/lib/features/settings/subfeatures/dapp_hooks/utils/blueberry_ring_helper.dart +++ b/lib/features/settings/subfeatures/dapp_hooks/utils/blueberry_ring_helper.dart @@ -36,7 +36,8 @@ class BlueberryHooksHelper { // After all enabled start service // listen for state and stop If the bluetooth & nearby device is went off // The Service will listen to the ad data and do the things on that - final success = await dAppHooksUseCase.scheduleAutoClaimTransaction(time); + final success = + await dAppHooksUseCase.scheduleBlueberryAutoSyncTransaction(time); if (success) { // Time past, need to run the auto claim @@ -64,21 +65,36 @@ class BlueberryHooksHelper { return true; } - Future changeMinerHooksEnabled( + Future changeBLueberryRingHooksEnabled( bool value, ) { return DAppHooksHelper.shouldUpdateWrapper(() async { late bool update; if (value) { update = await startBlueberryRingHooksService( - time: dAppHooksUseCase.dappHooksData.value.minerHooks.time, + time: dAppHooksUseCase.dappHooksData.value.blueberryRingHooks.time, showBGFetchAlert: true); } else { update = await stopBlueberryRingService(showSnackbar: true); } return update; }, () { - return dAppHooksUseCase.updateMinerHooksEnabled(value); + return dAppHooksUseCase.updateBlueberryRingHooksEnabled(value); + }); + } + + Future changeBlueberryRingHookTiming(TimeOfDay value) async { + return DAppHooksHelper.shouldUpdateWrapper(() async { + late bool update; + final currentDateTime = + dAppHooksUseCase.dappHooksData.value.blueberryRingHooks.time; + final time = currentDateTime.copyWith( + hour: value.hour, minute: value.minute, second: 0); + update = await startBlueberryRingHooksService( + time: time, showBGFetchAlert: false); + return update; + }, () { + return dAppHooksUseCase.updateBlueberryRingHookTiming(value); }); } }