diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index a33e55541..d4a4722cc 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -91,7 +91,7 @@
Workout photos
NSHealthShareUsageDescription
wger reads your Apple Health data to import measurements and activity such as weight, body fat, blood pressure, heart rate, blood oxygen, sleep, steps, distance, and active energy into your wger account
-
NSHealthUpdateUsageDescription
diff --git a/lib/features/health/models/health_metric.dart b/lib/features/health/models/health_metric.dart
index 802e95eb0..bab7c7d52 100644
--- a/lib/features/health/models/health_metric.dart
+++ b/lib/features/health/models/health_metric.dart
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:wger/features/measurements/models/measurement_category.dart';
/// Timeline a single platform query covers unless the metric says otherwise,
diff --git a/lib/features/health/models/health_reading.dart b/lib/features/health/models/health_reading.dart
index 51491e0df..a370f51f8 100644
--- a/lib/features/health/models/health_reading.dart
+++ b/lib/features/health/models/health_reading.dart
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
/// A single reading pulled from a health platform, reduced to the fields the
/// importer needs. Keeps the `health` package's [HealthDataPoint] out of the
diff --git a/lib/features/health/providers/health_entry_writer.dart b/lib/features/health/providers/health_entry_writer.dart
index bac7f6d65..ed24ac443 100644
--- a/lib/features/health/providers/health_entry_writer.dart
+++ b/lib/features/health/providers/health_entry_writer.dart
@@ -17,7 +17,7 @@
*/
import 'package:collection/collection.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:logging/logging.dart';
import 'package:powersync/powersync.dart' as ps;
import 'package:wger/features/health/models/daily_windows.dart';
diff --git a/lib/features/health/providers/health_importer.dart b/lib/features/health/providers/health_importer.dart
index e852076e2..4c96624ab 100644
--- a/lib/features/health/providers/health_importer.dart
+++ b/lib/features/health/providers/health_importer.dart
@@ -17,7 +17,7 @@
*/
import 'package:collection/collection.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:logging/logging.dart';
import 'package:powersync/powersync.dart' as ps;
import 'package:wger/core/network/auth_credentials_storage.dart';
diff --git a/lib/features/health/providers/health_repository.dart b/lib/features/health/providers/health_repository.dart
index ac583f498..d9af82882 100644
--- a/lib/features/health/providers/health_repository.dart
+++ b/lib/features/health/providers/health_repository.dart
@@ -21,7 +21,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/services.dart' show PlatformException;
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:logging/logging.dart';
import 'package:wger/features/health/models/health_metric.dart';
import 'package:wger/features/health/models/health_reading.dart';
@@ -101,15 +101,15 @@ class HealthRepository {
/// The subset of [types] the platform lets us read, without ever showing a
/// permission dialog.
///
- /// Asked per type on purpose. Both platforms hand out access per data type,
- /// and Health Connect's dialog invites the user to untick individual ones,
- /// so a single declined type must cost only its own metric its import.
- /// (`hasPermissions` answers for the whole list at once, which turned one
- /// declined type into a full stop.)
+ /// Asked one type per call on purpose. Both platforms hand out access per
+ /// data type, and Health Connect's dialog invites the user to untick
+ /// individual ones, so a single declined type must cost only its own metric
+ /// its import. (`hasPermissions` with the whole list is only true when every
+ /// type is granted, which turned one declined type into a full stop.)
///
/// Only Android answers exactly. HealthKit does not disclose read access, so
- /// the types it maps come back as `requestedOrUnknown` and count as
- /// readable; a denial there only shows up when the read fails, see
+ /// `hasPermissions` returns null there and the type counts as readable; a
+ /// denial there only shows up when the read fails, see
/// [isAuthorizationMissing].
Future> readableTypes(List types) async {
if (types.isEmpty) {
@@ -117,30 +117,23 @@ class HealthRepository {
}
await _health.configure();
- try {
- final snapshot = await _health.getAuthorizationSnapshot(types.toSet().toList());
- if (!snapshot.available) {
- return {};
+ final readable = {};
+ for (final type in types.toSet()) {
+ try {
+ if (await _health.hasPermissions([type]) != false) {
+ readable.add(type);
+ }
+ } catch (e) {
+ // The check only refines what we try: without it the type is read and
+ // fails on its own if the platform refuses it, which is the behaviour
+ // this method improves on, not one it depends on
+ _logger.warning('Could not check the permission for ${type.name}, trying it anyway: $e');
+ readable.add(type);
}
- return {
- for (final entry in snapshot.types)
- if (_isReadable(entry.read)) entry.type,
- };
- } catch (e) {
- // The snapshot only refines what we try: without it every type is read
- // and the ones the platform refuses fail individually, which is the
- // behaviour this method improves on, not one it depends on
- _logger.warning('Could not read the authorization snapshot, trying every type: $e');
- return types.toSet();
}
+ return readable;
}
- static bool _isReadable(HealthAuthorizationState state) => switch (state) {
- // iOS never reports more than "was requested at some point"
- HealthAuthorizationState.authorized || HealthAuthorizationState.requestedOrUnknown => true,
- _ => false,
- };
-
/// Whether [error] is the platform refusing a read for lack of permissions.
///
/// HealthKit throws this when authorization for a type was never requested
@@ -201,9 +194,9 @@ class HealthRepository {
/// record). Adding up the raw records instead counts those twice. The value
/// is in the platform's raw unit (count, meters, kcal), like a raw read.
///
- /// Null on iOS, on failure, or when the platform returned nothing, so the
- /// caller can fall back to the raw sum. A range without data from the
- /// user's priority list comes back as 0, not null.
+ /// Null on iOS, on failure, or when the platform returned nothing (it omits
+ /// a range without data from the user's priority list), so the caller can
+ /// fall back to the raw sum.
Future platformTotal(HealthDataType type, DateTime start, DateTime end) async {
if (!hasPlatformTotals || !end.isAfter(start)) {
return null;
diff --git a/pubspec.lock b/pubspec.lock
index fc5a197a3..30ac8fd97 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -193,6 +193,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.1.2"
+ carp_serializable:
+ dependency: transitive
+ description:
+ name: carp_serializable
+ sha256: efeac6afbc85c3763fac382647cec6395368cf4c3ecfea4d2d10f95d99c03705
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.2"
change:
dependency: transitive
description:
@@ -759,15 +767,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.2"
- health_bridge:
+ health:
dependency: "direct main"
description:
- path: "."
- ref: "v2.1.0"
- resolved-ref: "05515122beb1ac6e93a3b558b5468af16c3e5aaf"
- url: "https://github.com/ytsni/health_bridge.git"
- source: git
- version: "2.1.0"
+ name: health
+ sha256: "683d15fdde49a942bacce871faf3090bda3c1f5dad995725337aeb1dfd348e6d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "14.0.0"
hooks:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 354175af8..9ebab6962 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -54,13 +54,7 @@ dependencies:
flutter_zxing: ^3.1.1
font_awesome_flutter: ^11.0.0
freezed_annotation: ^3.1.0
- # A maintained fork of `health` 13.3.1. We need its per-type authorization
- # snapshot (see HealthRepository.readableTypes) plus its Health Connect and
- # iOS crash fixes, none of which upstream has picked up.
- health_bridge:
- git:
- url: https://github.com/ytsni/health_bridge.git
- ref: v2.1.0
+ health: ^14.0.0
http: ^1.6.0
image_picker: ^1.2.3
intl: ^0.20.2
diff --git a/test/features/health/health_manifest_test.dart b/test/features/health/health_manifest_test.dart
index 062cd54f9..2652cdadb 100644
--- a/test/features/health/health_manifest_test.dart
+++ b/test/features/health/health_manifest_test.dart
@@ -19,7 +19,7 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:wger/database/powersync/powersync.dart';
import 'package:wger/features/health/models/health_metric.dart';
diff --git a/test/features/health/models/daily_windows_test.dart b/test/features/health/models/daily_windows_test.dart
index 758a4d78d..a9379f706 100644
--- a/test/features/health/models/daily_windows_test.dart
+++ b/test/features/health/models/daily_windows_test.dart
@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:wger/features/health/models/daily_windows.dart';
import 'package:wger/features/health/models/health_metric.dart';
import 'package:wger/features/health/models/health_reading.dart';
diff --git a/test/features/health/models/health_metric_test.dart b/test/features/health/models/health_metric_test.dart
index d4f6ecbb8..7550a7fb0 100644
--- a/test/features/health/models/health_metric_test.dart
+++ b/test/features/health/models/health_metric_test.dart
@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:wger/features/health/models/health_metric.dart';
import 'package:wger/features/measurements/models/measurement_category.dart';
diff --git a/test/features/health/models/health_reading_test.dart b/test/features/health/models/health_reading_test.dart
index b80fec904..387e8b723 100644
--- a/test/features/health/models/health_reading_test.dart
+++ b/test/features/health/models/health_reading_test.dart
@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:wger/features/health/models/health_reading.dart';
HealthDataPoint dataPoint({String uuid = 'abc-123', HealthValue? value}) {
diff --git a/test/features/health/providers/health_importer_test.dart b/test/features/health/providers/health_importer_test.dart
index 5e5cbffa2..3f1ffaf4b 100644
--- a/test/features/health/providers/health_importer_test.dart
+++ b/test/features/health/providers/health_importer_test.dart
@@ -19,7 +19,7 @@
import 'package:collection/collection.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:powersync/powersync.dart' as ps;
diff --git a/test/features/health/providers/health_importer_test.mocks.dart b/test/features/health/providers/health_importer_test.mocks.dart
index 587fc2fba..3a28c5a66 100644
--- a/test/features/health/providers/health_importer_test.mocks.dart
+++ b/test/features/health/providers/health_importer_test.mocks.dart
@@ -6,7 +6,7 @@
import 'dart:async' as _i4;
-import 'package:health_bridge/health.dart' as _i5;
+import 'package:health/health.dart' as _i5;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i3;
import 'package:wger/core/network/auth_credentials_storage.dart' as _i11;
diff --git a/test/features/health/providers/health_repository_test.dart b/test/features/health/providers/health_repository_test.dart
index 184d3899a..d2ba5bc5b 100644
--- a/test/features/health/providers/health_repository_test.dart
+++ b/test/features/health/providers/health_repository_test.dart
@@ -17,7 +17,7 @@
*/
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:wger/features/health/models/health_metric.dart';
@@ -363,4 +363,39 @@ void main() {
);
});
});
+
+ group('readableTypes', () {
+ test('a declined type costs only itself', () async {
+ // Asked for both at once, the platform says false as soon as one is
+ // missing, which would drop the granted type too
+ when(health.hasPermissions(any)).thenAnswer((invocation) async {
+ final types = invocation.positionalArguments.first as List;
+ return !types.contains(HealthDataType.HEART_RATE);
+ });
+
+ final readable = await repository.readableTypes([
+ HealthDataType.WEIGHT,
+ HealthDataType.HEART_RATE,
+ ]);
+
+ expect(readable, {HealthDataType.WEIGHT});
+ });
+
+ test('an undisclosed read access counts as readable', () async {
+ // HealthKit never tells whether reading was granted
+ when(health.hasPermissions(any)).thenAnswer((_) async => null);
+
+ final readable = await repository.readableTypes([HealthDataType.WEIGHT]);
+
+ expect(readable, {HealthDataType.WEIGHT});
+ });
+
+ test('a failing check still tries the type', () async {
+ when(health.hasPermissions(any)).thenThrow(Exception('boom'));
+
+ final readable = await repository.readableTypes([HealthDataType.WEIGHT]);
+
+ expect(readable, {HealthDataType.WEIGHT});
+ });
+ });
}
diff --git a/test/features/health/providers/health_repository_test.mocks.dart b/test/features/health/providers/health_repository_test.mocks.dart
index 74afde0eb..df0811a3d 100644
--- a/test/features/health/providers/health_repository_test.mocks.dart
+++ b/test/features/health/providers/health_repository_test.mocks.dart
@@ -6,7 +6,7 @@
import 'dart:async' as _i4;
-import 'package:health_bridge/health.dart' as _i2;
+import 'package:health/health.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i3;
@@ -34,6 +34,17 @@ class MockHealth extends _i1.Mock implements _i2.Health {
_i1.throwOnMissingStub(this);
}
+ @override
+ _i2.HealthIsolateMode get isolateMode =>
+ (super.noSuchMethod(
+ Invocation.getter(#isolateMode),
+ returnValue: _i2.HealthIsolateMode.auto,
+ )
+ as _i2.HealthIsolateMode);
+
+ @override
+ int get pageSize => (super.noSuchMethod(Invocation.getter(#pageSize), returnValue: 0) as int);
+
@override
_i2.HealthConnectSdkStatus get healthConnectSdkStatus =>
(super.noSuchMethod(
@@ -61,6 +72,18 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as String);
+ @override
+ set isolateMode(_i2.HealthIsolateMode? value) => super.noSuchMethod(
+ Invocation.setter(#isolateMode, value),
+ returnValueForMissingStub: null,
+ );
+
+ @override
+ set pageSize(int? value) => super.noSuchMethod(
+ Invocation.setter(#pageSize, value),
+ returnValueForMissingStub: null,
+ );
+
@override
_i4.Future configure() =>
(super.noSuchMethod(
@@ -78,45 +101,6 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as bool);
- @override
- _i4.Future hasPermissions(
- List<_i2.HealthDataType>? types, {
- List<_i2.HealthDataAccess>? permissions,
- }) =>
- (super.noSuchMethod(
- Invocation.method(
- #hasPermissions,
- [types],
- {#permissions: permissions},
- ),
- returnValue: _i4.Future.value(),
- )
- as _i4.Future);
-
- @override
- _i4.Future<_i2.HealthAuthorizationSnapshot> getAuthorizationSnapshot(
- List<_i2.HealthDataType>? types,
- ) =>
- (super.noSuchMethod(
- Invocation.method(#getAuthorizationSnapshot, [types]),
- returnValue: _i4.Future<_i2.HealthAuthorizationSnapshot>.value(
- _i3.dummyValue<_i2.HealthAuthorizationSnapshot>(
- this,
- Invocation.method(#getAuthorizationSnapshot, [types]),
- ),
- ),
- )
- as _i4.Future<_i2.HealthAuthorizationSnapshot>);
-
- @override
- _i4.Future revokePermissions() =>
- (super.noSuchMethod(
- Invocation.method(#revokePermissions, []),
- returnValue: _i4.Future.value(),
- returnValueForMissingStub: _i4.Future.value(),
- )
- as _i4.Future);
-
@override
_i4.Future<_i2.HealthConnectSdkStatus?> getHealthConnectSdkStatus() =>
(super.noSuchMethod(
@@ -125,6 +109,186 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future<_i2.HealthConnectSdkStatus?>);
+ @override
+ _i4.Future writeHealthData({
+ required double? value,
+ _i2.HealthDataUnit? unit,
+ required _i2.HealthDataType? type,
+ required DateTime? startTime,
+ String? clientRecordId,
+ double? clientRecordVersion,
+ DateTime? endTime,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#writeHealthData, [], {
+ #value: value,
+ #unit: unit,
+ #type: type,
+ #startTime: startTime,
+ #clientRecordId: clientRecordId,
+ #clientRecordVersion: clientRecordVersion,
+ #endTime: endTime,
+ #recordingMethod: recordingMethod,
+ }),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future<_i2.HealthDataPoint?> getHealthDataByUUID({
+ required String? uuid,
+ required _i2.HealthDataType? type,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getHealthDataByUUID, [], {
+ #uuid: uuid,
+ #type: type,
+ }),
+ returnValue: _i4.Future<_i2.HealthDataPoint?>.value(),
+ )
+ as _i4.Future<_i2.HealthDataPoint?>);
+
+ @override
+ _i4.Future> getHealthDataFromTypes({
+ required List<_i2.HealthDataType>? types,
+ Map<_i2.HealthDataType, _i2.HealthDataUnit>? preferredUnits,
+ required DateTime? startTime,
+ required DateTime? endTime,
+ List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
+ int? limit,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getHealthDataFromTypes, [], {
+ #types: types,
+ #preferredUnits: preferredUnits,
+ #startTime: startTime,
+ #endTime: endTime,
+ #recordingMethodsToFilter: recordingMethodsToFilter,
+ #limit: limit,
+ }),
+ returnValue: _i4.Future>.value(
+ <_i2.HealthDataPoint>[],
+ ),
+ )
+ as _i4.Future>);
+
+ @override
+ _i4.Stream<_i2.HealthDataPage> getHealthDataPages({
+ required List<_i2.HealthDataType>? types,
+ required DateTime? startTime,
+ required DateTime? endTime,
+ Map<_i2.HealthDataType, _i2.HealthDataUnit>? preferredUnits,
+ List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
+ int? pageSize,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getHealthDataPages, [], {
+ #types: types,
+ #startTime: startTime,
+ #endTime: endTime,
+ #preferredUnits: preferredUnits,
+ #recordingMethodsToFilter: recordingMethodsToFilter,
+ #pageSize: pageSize,
+ }),
+ returnValue: _i4.Stream<_i2.HealthDataPage>.empty(),
+ )
+ as _i4.Stream<_i2.HealthDataPage>);
+
+ @override
+ List<_i2.HealthDataPoint> removeDuplicates(
+ List<_i2.HealthDataPoint>? points,
+ ) =>
+ (super.noSuchMethod(
+ Invocation.method(#removeDuplicates, [points]),
+ returnValue: <_i2.HealthDataPoint>[],
+ )
+ as List<_i2.HealthDataPoint>);
+
+ @override
+ _i4.Future> getHealthIntervalDataFromTypes({
+ required DateTime? startDate,
+ required DateTime? endDate,
+ required List<_i2.HealthDataType>? types,
+ required int? interval,
+ List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getHealthIntervalDataFromTypes, [], {
+ #startDate: startDate,
+ #endDate: endDate,
+ #types: types,
+ #interval: interval,
+ #recordingMethodsToFilter: recordingMethodsToFilter,
+ }),
+ returnValue: _i4.Future>.value(
+ <_i2.HealthDataPoint>[],
+ ),
+ )
+ as _i4.Future>);
+
+ @override
+ _i4.Future> getHealthAggregateDataFromTypes({
+ required List<_i2.HealthDataType>? types,
+ required DateTime? startDate,
+ required DateTime? endDate,
+ int? activitySegmentDuration = 1,
+ bool? includeManualEntry = true,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getHealthAggregateDataFromTypes, [], {
+ #types: types,
+ #startDate: startDate,
+ #endDate: endDate,
+ #activitySegmentDuration: activitySegmentDuration,
+ #includeManualEntry: includeManualEntry,
+ }),
+ returnValue: _i4.Future>.value(
+ <_i2.HealthDataPoint>[],
+ ),
+ )
+ as _i4.Future>);
+
+ @override
+ _i4.Future getTotalStepsInInterval(
+ DateTime? startTime,
+ DateTime? endTime, {
+ bool? includeManualEntry = true,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #getTotalStepsInInterval,
+ [startTime, endTime],
+ {#includeManualEntry: includeManualEntry},
+ ),
+ returnValue: _i4.Future.value(0),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future getChangesToken({
+ required List<_i2.HealthDataType>? types,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getChangesToken, [], {#types: types}),
+ returnValue: _i4.Future.value(),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future<_i2.HealthChangesResponse?> getChanges({
+ required String? changesToken,
+ bool? includeSelf = false,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#getChanges, [], {
+ #changesToken: changesToken,
+ #includeSelf: includeSelf,
+ }),
+ returnValue: _i4.Future<_i2.HealthChangesResponse?>.value(),
+ )
+ as _i4.Future<_i2.HealthChangesResponse?>);
+
@override
_i4.Future isHealthConnectAvailable() =>
(super.noSuchMethod(
@@ -198,6 +362,37 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future);
+ @override
+ _i4.Future isMindfulnessSessionAvailable() =>
+ (super.noSuchMethod(
+ Invocation.method(#isMindfulnessSessionAvailable, []),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future isActivityIntensityAvailable() =>
+ (super.noSuchMethod(
+ Invocation.method(#isActivityIntensityAvailable, []),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future hasPermissions(
+ List<_i2.HealthDataType>? types, {
+ List<_i2.HealthDataAccess>? permissions,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #hasPermissions,
+ [types],
+ {#permissions: permissions},
+ ),
+ returnValue: _i4.Future.value(),
+ )
+ as _i4.Future);
+
@override
_i4.Future requestAuthorization(
List<_i2.HealthDataType>? types, {
@@ -214,7 +409,31 @@ class MockHealth extends _i1.Mock implements _i2.Health {
as _i4.Future);
@override
- _i4.Future writeHealthData({
+ _i4.Future<_i2.HealthAuthorizationRequestStatus?> getRequestStatusForAuthorization(
+ List<_i2.HealthDataType>? types, {
+ List<_i2.HealthDataAccess>? permissions,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #getRequestStatusForAuthorization,
+ [types],
+ {#permissions: permissions},
+ ),
+ returnValue: _i4.Future<_i2.HealthAuthorizationRequestStatus?>.value(),
+ )
+ as _i4.Future<_i2.HealthAuthorizationRequestStatus?>);
+
+ @override
+ _i4.Future revokePermissions() =>
+ (super.noSuchMethod(
+ Invocation.method(#revokePermissions, []),
+ returnValue: _i4.Future.value(),
+ returnValueForMissingStub: _i4.Future.value(),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future writeHealthDataUUID({
required double? value,
_i2.HealthDataUnit? unit,
required _i2.HealthDataType? type,
@@ -225,7 +444,7 @@ class MockHealth extends _i1.Mock implements _i2.Health {
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
- Invocation.method(#writeHealthData, [], {
+ Invocation.method(#writeHealthDataUUID, [], {
#value: value,
#unit: unit,
#type: type,
@@ -239,71 +458,6 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future);
- @override
- _i4.Future writeActivityIntensity({
- required _i2.ActivityIntensityLevel? intensityLevel,
- required DateTime? startTime,
- DateTime? endTime,
- _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
- String? clientRecordId,
- double? clientRecordVersion,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#writeActivityIntensity, [], {
- #intensityLevel: intensityLevel,
- #startTime: startTime,
- #endTime: endTime,
- #recordingMethod: recordingMethod,
- #clientRecordId: clientRecordId,
- #clientRecordVersion: clientRecordVersion,
- }),
- returnValue: _i4.Future.value(false),
- )
- as _i4.Future);
-
- @override
- _i4.Future delete({
- required _i2.HealthDataType? type,
- required DateTime? startTime,
- DateTime? endTime,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#delete, [], {
- #type: type,
- #startTime: startTime,
- #endTime: endTime,
- }),
- returnValue: _i4.Future.value(false),
- )
- as _i4.Future);
-
- @override
- _i4.Future deleteByUUID({
- required String? uuid,
- _i2.HealthDataType? type,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#deleteByUUID, [], {#uuid: uuid, #type: type}),
- returnValue: _i4.Future.value(false),
- )
- as _i4.Future);
-
- @override
- _i4.Future deleteByClientRecordId({
- required _i2.HealthDataType? dataTypeKey,
- required String? clientRecordId,
- String? recordId,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#deleteByClientRecordId, [], {
- #dataTypeKey: dataTypeKey,
- #clientRecordId: clientRecordId,
- #recordId: recordId,
- }),
- returnValue: _i4.Future.value(false),
- )
- as _i4.Future);
-
@override
_i4.Future writeBloodPressure({
required int? systolic,
@@ -346,6 +500,110 @@ class MockHealth extends _i1.Mock implements _i2.Health {
)
as _i4.Future);
+ @override
+ _i4.Future writeMenstruationFlow({
+ required _i2.MenstrualFlow? flow,
+ required DateTime? startTime,
+ required DateTime? endTime,
+ required bool? isStartOfCycle,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#writeMenstruationFlow, [], {
+ #flow: flow,
+ #startTime: startTime,
+ #endTime: endTime,
+ #isStartOfCycle: isStartOfCycle,
+ #recordingMethod: recordingMethod,
+ }),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future writeSexualActivity({
+ _i2.SexualActivityProtection? protectionUsed = _i2.SexualActivityProtection.unknown,
+ required DateTime? startTime,
+ DateTime? endTime,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
+ String? clientRecordId,
+ double? clientRecordVersion,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#writeSexualActivity, [], {
+ #protectionUsed: protectionUsed,
+ #startTime: startTime,
+ #endTime: endTime,
+ #recordingMethod: recordingMethod,
+ #clientRecordId: clientRecordId,
+ #clientRecordVersion: clientRecordVersion,
+ }),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future writeAudiogram({
+ required List? frequencies,
+ required List? leftEarSensitivities,
+ required List? rightEarSensitivities,
+ required DateTime? startTime,
+ DateTime? endTime,
+ Map? metadata,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#writeAudiogram, [], {
+ #frequencies: frequencies,
+ #leftEarSensitivities: leftEarSensitivities,
+ #rightEarSensitivities: rightEarSensitivities,
+ #startTime: startTime,
+ #endTime: endTime,
+ #metadata: metadata,
+ }),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future writeInsulinDelivery(
+ double? units,
+ _i2.InsulinDeliveryReason? reason,
+ DateTime? startTime,
+ DateTime? endTime,
+ ) =>
+ (super.noSuchMethod(
+ Invocation.method(#writeInsulinDelivery, [
+ units,
+ reason,
+ startTime,
+ endTime,
+ ]),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future writeActivityIntensity({
+ required _i2.ActivityIntensityLevel? intensityLevel,
+ required DateTime? startTime,
+ DateTime? endTime,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
+ String? clientRecordId,
+ double? clientRecordVersion,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#writeActivityIntensity, [], {
+ #intensityLevel: intensityLevel,
+ #startTime: startTime,
+ #endTime: endTime,
+ #recordingMethod: recordingMethod,
+ #clientRecordId: clientRecordId,
+ #clientRecordVersion: clientRecordVersion,
+ }),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
@override
_i4.Future writeMeal({
required _i2.MealType? mealType,
@@ -453,19 +711,21 @@ class MockHealth extends _i1.Mock implements _i2.Health {
as _i4.Future);
@override
- _i4.Future writeMenstruationFlow({
- required _i2.MenstrualFlow? flow,
+ _i4.Future writeSleepSession({
required DateTime? startTime,
required DateTime? endTime,
- required bool? isStartOfCycle,
+ List<_i2.SleepSessionStage>? stages = const [],
+ String? title,
+ String? notes,
_i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
- Invocation.method(#writeMenstruationFlow, [], {
- #flow: flow,
+ Invocation.method(#writeSleepSession, [], {
#startTime: startTime,
#endTime: endTime,
- #isStartOfCycle: isStartOfCycle,
+ #stages: stages,
+ #title: title,
+ #notes: notes,
#recordingMethod: recordingMethod,
}),
returnValue: _i4.Future.value(false),
@@ -473,254 +733,153 @@ class MockHealth extends _i1.Mock implements _i2.Health {
as _i4.Future);
@override
- _i4.Future writeAudiogram({
- required List? frequencies,
- required List? leftEarSensitivities,
- required List? rightEarSensitivities,
- required DateTime? startTime,
- DateTime? endTime,
- Map? metadata,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#writeAudiogram, [], {
- #frequencies: frequencies,
- #leftEarSensitivities: leftEarSensitivities,
- #rightEarSensitivities: rightEarSensitivities,
- #startTime: startTime,
- #endTime: endTime,
- #metadata: metadata,
- }),
- returnValue: _i4.Future.value(false),
- )
- as _i4.Future);
-
- @override
- _i4.Future writeInsulinDelivery(
- double? units,
- _i2.InsulinDeliveryReason? reason,
- DateTime? startTime,
- DateTime? endTime,
- ) =>
- (super.noSuchMethod(
- Invocation.method(#writeInsulinDelivery, [
- units,
- reason,
- startTime,
- endTime,
- ]),
- returnValue: _i4.Future.value(false),
- )
- as _i4.Future);
-
- @override
- _i4.Future<_i2.HealthDataPoint?> getHealthDataByUUID({
- required String? uuid,
- required _i2.HealthDataType? type,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#getHealthDataByUUID, [], {
- #uuid: uuid,
- #type: type,
- }),
- returnValue: _i4.Future<_i2.HealthDataPoint?>.value(),
- )
- as _i4.Future<_i2.HealthDataPoint?>);
-
- @override
- _i4.Future> getHealthDataFromTypes({
- required List<_i2.HealthDataType>? types,
- Map<_i2.HealthDataType, _i2.HealthDataUnit>? preferredUnits,
+ _i4.Future writeMindfulnessSession({
required DateTime? startTime,
required DateTime? endTime,
- List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
+ _i2.MindfulnessSessionType? sessionType = _i2.MindfulnessSessionType.UNKNOWN,
+ String? title,
+ String? notes,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
}) =>
(super.noSuchMethod(
- Invocation.method(#getHealthDataFromTypes, [], {
- #types: types,
- #preferredUnits: preferredUnits,
+ Invocation.method(#writeMindfulnessSession, [], {
#startTime: startTime,
#endTime: endTime,
- #recordingMethodsToFilter: recordingMethodsToFilter,
+ #sessionType: sessionType,
+ #title: title,
+ #notes: notes,
+ #recordingMethod: recordingMethod,
}),
- returnValue: _i4.Future>.value(
- <_i2.HealthDataPoint>[],
- ),
+ returnValue: _i4.Future.value(false),
)
- as _i4.Future>);
+ as _i4.Future);
@override
- _i4.Future> getHealthIntervalDataFromTypes({
- required DateTime? startDate,
- required DateTime? endDate,
- required List<_i2.HealthDataType>? types,
- required int? interval,
- List<_i2.RecordingMethod>? recordingMethodsToFilter = const [],
+ _i4.Future delete({
+ required _i2.HealthDataType? type,
+ required DateTime? startTime,
+ DateTime? endTime,
}) =>
(super.noSuchMethod(
- Invocation.method(#getHealthIntervalDataFromTypes, [], {
- #startDate: startDate,
- #endDate: endDate,
- #types: types,
- #interval: interval,
- #recordingMethodsToFilter: recordingMethodsToFilter,
+ Invocation.method(#delete, [], {
+ #type: type,
+ #startTime: startTime,
+ #endTime: endTime,
}),
- returnValue: _i4.Future>.value(
- <_i2.HealthDataPoint>[],
- ),
+ returnValue: _i4.Future.value(false),
)
- as _i4.Future>);
+ as _i4.Future);
@override
- _i4.Future> getHealthAggregateDataFromTypes({
- required List<_i2.HealthDataType>? types,
- required DateTime? startDate,
- required DateTime? endDate,
- int? activitySegmentDuration = 1,
- bool? includeManualEntry = true,
+ _i4.Future deleteByUUID({
+ required String? uuid,
+ _i2.HealthDataType? type,
}) =>
(super.noSuchMethod(
- Invocation.method(#getHealthAggregateDataFromTypes, [], {
- #types: types,
- #startDate: startDate,
- #endDate: endDate,
- #activitySegmentDuration: activitySegmentDuration,
- #includeManualEntry: includeManualEntry,
+ Invocation.method(#deleteByUUID, [], {#uuid: uuid, #type: type}),
+ returnValue: _i4.Future.value(false),
+ )
+ as _i4.Future);
+
+ @override
+ _i4.Future deleteByClientRecordId({
+ required _i2.HealthDataType? dataTypeKey,
+ required String? clientRecordId,
+ String? recordId,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(#deleteByClientRecordId, [], {
+ #dataTypeKey: dataTypeKey,
+ #clientRecordId: clientRecordId,
+ #recordId: recordId,
}),
- returnValue: _i4.Future>.value(
- <_i2.HealthDataPoint>[],
- ),
+ returnValue: _i4.Future.value(false),
)
- as _i4.Future>);
+ as _i4.Future);
@override
- _i4.Future getChangesToken({
- required List<_i2.HealthDataType>? types,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#getChangesToken, [], {#types: types}),
- returnValue: _i4.Future.value(),
- )
- as _i4.Future);
-
- @override
- _i4.Future<_i2.HealthChangesResponse?> getChanges({
- required String? changesToken,
- bool? includeSelf = false,
- }) =>
- (super.noSuchMethod(
- Invocation.method(#getChanges, [], {
- #changesToken: changesToken,
- #includeSelf: includeSelf,
- }),
- returnValue: _i4.Future<_i2.HealthChangesResponse?>.value(),
- )
- as _i4.Future<_i2.HealthChangesResponse?>);
-
- @override
- List<_i2.HealthDataPoint> removeDuplicates(
- List<_i2.HealthDataPoint>? points,
- ) =>
- (super.noSuchMethod(
- Invocation.method(#removeDuplicates, [points]),
- returnValue: <_i2.HealthDataPoint>[],
- )
- as List<_i2.HealthDataPoint>);
-
- @override
- _i4.Future getTotalStepsInInterval(
- DateTime? startTime,
- DateTime? endTime, {
- bool? includeManualEntry = true,
- }) =>
- (super.noSuchMethod(
- Invocation.method(
- #getTotalStepsInInterval,
- [startTime, endTime],
- {#includeManualEntry: includeManualEntry},
- ),
- returnValue: _i4.Future.value(),
- )
- as _i4.Future);
-
- @override
- _i4.Future<_i2.HealthWorkoutWriteResult> writeWorkoutData({
- required String? workoutClientRecordId,
- String? energyClientRecordId,
- required int? clientRecordVersion,
+ _i4.Future writeWorkoutData({
required _i2.HealthWorkoutActivityType? activityType,
required DateTime? start,
required DateTime? end,
- required int? startZoneOffsetSeconds,
- required int? endZoneOffsetSeconds,
- double? activeEnergyKcal,
- required String? title,
- required _i2.HealthRecordingProvenance? recordingProvenance,
- required _i2.HealthRecordingDevice? recordingDevice,
+ int? totalEnergyBurned,
+ _i2.HealthDataUnit? totalEnergyBurnedUnit = _i2.HealthDataUnit.KILOCALORIE,
+ int? totalDistance,
+ _i2.HealthDataUnit? totalDistanceUnit = _i2.HealthDataUnit.METER,
+ String? title,
+ _i2.WorkoutMetadata? metadata,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
+ String? clientRecordId,
+ double? clientRecordVersion,
+ Duration? startZoneOffset,
+ Duration? endZoneOffset,
+ _i2.SwimmingDetails? swimming,
+ int? totalSwimmingStrokeCount,
}) =>
(super.noSuchMethod(
Invocation.method(#writeWorkoutData, [], {
- #workoutClientRecordId: workoutClientRecordId,
- #energyClientRecordId: energyClientRecordId,
- #clientRecordVersion: clientRecordVersion,
#activityType: activityType,
#start: start,
#end: end,
- #startZoneOffsetSeconds: startZoneOffsetSeconds,
- #endZoneOffsetSeconds: endZoneOffsetSeconds,
- #activeEnergyKcal: activeEnergyKcal,
+ #totalEnergyBurned: totalEnergyBurned,
+ #totalEnergyBurnedUnit: totalEnergyBurnedUnit,
+ #totalDistance: totalDistance,
+ #totalDistanceUnit: totalDistanceUnit,
#title: title,
- #recordingProvenance: recordingProvenance,
- #recordingDevice: recordingDevice,
+ #metadata: metadata,
+ #recordingMethod: recordingMethod,
+ #clientRecordId: clientRecordId,
+ #clientRecordVersion: clientRecordVersion,
+ #startZoneOffset: startZoneOffset,
+ #endZoneOffset: endZoneOffset,
+ #swimming: swimming,
+ #totalSwimmingStrokeCount: totalSwimmingStrokeCount,
}),
- returnValue: _i4.Future<_i2.HealthWorkoutWriteResult>.value(
- _i3.dummyValue<_i2.HealthWorkoutWriteResult>(
- this,
- Invocation.method(#writeWorkoutData, [], {
- #workoutClientRecordId: workoutClientRecordId,
- #energyClientRecordId: energyClientRecordId,
- #clientRecordVersion: clientRecordVersion,
- #activityType: activityType,
- #start: start,
- #end: end,
- #startZoneOffsetSeconds: startZoneOffsetSeconds,
- #endZoneOffsetSeconds: endZoneOffsetSeconds,
- #activeEnergyKcal: activeEnergyKcal,
- #title: title,
- #recordingProvenance: recordingProvenance,
- #recordingDevice: recordingDevice,
- }),
- ),
- ),
+ returnValue: _i4.Future.value(false),
)
- as _i4.Future<_i2.HealthWorkoutWriteResult>);
+ as _i4.Future);
@override
- _i4.Future<_i2.HealthWorkoutLookupResult> lookupWorkoutData({
- required String? workoutClientRecordId,
- String? energyClientRecordId,
+ _i4.Future writeWorkoutDataUUID({
+ required _i2.HealthWorkoutActivityType? activityType,
required DateTime? start,
required DateTime? end,
+ int? totalEnergyBurned,
+ _i2.HealthDataUnit? totalEnergyBurnedUnit = _i2.HealthDataUnit.KILOCALORIE,
+ int? totalDistance,
+ _i2.HealthDataUnit? totalDistanceUnit = _i2.HealthDataUnit.METER,
+ String? title,
+ _i2.WorkoutMetadata? metadata,
+ _i2.RecordingMethod? recordingMethod = _i2.RecordingMethod.automatic,
+ String? clientRecordId,
+ double? clientRecordVersion,
+ Duration? startZoneOffset,
+ Duration? endZoneOffset,
+ _i2.SwimmingDetails? swimming,
+ int? totalSwimmingStrokeCount,
}) =>
(super.noSuchMethod(
- Invocation.method(#lookupWorkoutData, [], {
- #workoutClientRecordId: workoutClientRecordId,
- #energyClientRecordId: energyClientRecordId,
+ Invocation.method(#writeWorkoutDataUUID, [], {
+ #activityType: activityType,
#start: start,
#end: end,
+ #totalEnergyBurned: totalEnergyBurned,
+ #totalEnergyBurnedUnit: totalEnergyBurnedUnit,
+ #totalDistance: totalDistance,
+ #totalDistanceUnit: totalDistanceUnit,
+ #title: title,
+ #metadata: metadata,
+ #recordingMethod: recordingMethod,
+ #clientRecordId: clientRecordId,
+ #clientRecordVersion: clientRecordVersion,
+ #startZoneOffset: startZoneOffset,
+ #endZoneOffset: endZoneOffset,
+ #swimming: swimming,
+ #totalSwimmingStrokeCount: totalSwimmingStrokeCount,
}),
- returnValue: _i4.Future<_i2.HealthWorkoutLookupResult>.value(
- _i3.dummyValue<_i2.HealthWorkoutLookupResult>(
- this,
- Invocation.method(#lookupWorkoutData, [], {
- #workoutClientRecordId: workoutClientRecordId,
- #energyClientRecordId: energyClientRecordId,
- #start: start,
- #end: end,
- }),
- ),
- ),
+ returnValue: _i4.Future.value(),
)
- as _i4.Future<_i2.HealthWorkoutLookupResult>);
+ as _i4.Future);
@override
_i4.Future startWorkoutRoute() =>
diff --git a/test/features/health/providers/health_sync_test.dart b/test/features/health/providers/health_sync_test.dart
index cfe3f7cd3..860f0d7ac 100644
--- a/test/features/health/providers/health_sync_test.dart
+++ b/test/features/health/providers/health_sync_test.dart
@@ -20,7 +20,7 @@ import 'dart:async';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:health_bridge/health.dart';
+import 'package:health/health.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
diff --git a/test/features/health/providers/health_sync_test.mocks.dart b/test/features/health/providers/health_sync_test.mocks.dart
index 05b4def27..07290ca1a 100644
--- a/test/features/health/providers/health_sync_test.mocks.dart
+++ b/test/features/health/providers/health_sync_test.mocks.dart
@@ -6,7 +6,7 @@
import 'dart:async' as _i4;
-import 'package:health_bridge/health.dart' as _i5;
+import 'package:health/health.dart' as _i5;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i3;
import 'package:wger/core/network/auth_credentials_storage.dart' as _i11;
diff --git a/test/screenshots/screenshots_01_dashboard.mocks.dart b/test/screenshots/screenshots_01_dashboard.mocks.dart
index 54b5672fb..189d983ae 100644
--- a/test/screenshots/screenshots_01_dashboard.mocks.dart
+++ b/test/screenshots/screenshots_01_dashboard.mocks.dart
@@ -6,7 +6,7 @@
import 'dart:async' as _i11;
-import 'package:health_bridge/health.dart' as _i44;
+import 'package:health/health.dart' as _i44;
import 'package:image_picker/image_picker.dart' as _i12;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i32;