diff --git a/packages/health/CHANGELOG.md b/packages/health/CHANGELOG.md index 39ee691fb..e90b62aaa 100644 --- a/packages/health/CHANGELOG.md +++ b/packages/health/CHANGELOG.md @@ -1,3 +1,9 @@ +## 13.0.2 + +* Android: Add `SPEED` health data type - PR [#1183](https://github.com/cph-cachet/flutter-plugins/pull/1183) +* iOS: Add `WALKING_SPEED` health data type - PR [#1183](https://github.com/cph-cachet/flutter-plugins/pull/1183) +* Add `METER_PER_SECOND` health data unit + ## 13.0.1 * Refactored Swift native implementation - See PR [#1175](https://github.com/cph-cachet/flutter-plugins/pull/1175) and [#1208](https://github.com/cph-cachet/flutter-plugins/pull/1208) for more information: diff --git a/packages/health/README.md b/packages/health/README.md index 65db40ed6..916fdb786 100644 --- a/packages/health/README.md +++ b/packages/health/README.md @@ -385,6 +385,7 @@ The plugin supports the following [`HealthDataType`](https://pub.dev/documentati | UNDERWATER_DEPTH | METER | yes | | Related to/Requires Apple Watch Ultra's Underwater Diving Workout | | UV_INDEX | COUNT | yes | | | | LEAN_BODY_MASS | KILOGRAMS | yes | yes | | +| WALKING_SPEED | METER_PER_SECOND | yes | (yes) | On Android this will be recorded as `SPEED` with similar unit | ## Workout Types diff --git a/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt b/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt index 5fb0a5a79..edb574f36 100644 --- a/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt +++ b/packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt @@ -56,6 +56,7 @@ const val LEAN_BODY_MASS = "LEAN_BODY_MASS" const val BODY_TEMPERATURE = "BODY_TEMPERATURE" const val BODY_WATER_MASS = "BODY_WATER_MASS" const val DISTANCE_DELTA = "DISTANCE_DELTA" +const val SPEED = "SPEED" const val FLIGHTS_CLIMBED = "FLIGHTS_CLIMBED" const val HEART_RATE = "HEART_RATE" const val HEART_RATE_VARIABILITY_RMSSD = "HEART_RATE_VARIABILITY_RMSSD" @@ -1380,6 +1381,19 @@ class HealthPlugin(private var channel: MethodChannel? = null) : ), ) + is SpeedRecord -> + return record.samples.map { + mapOf( + "uuid" to metadata.id, + "value" to it.speed.inMetersPerSecond, + "date_from" to it.time.toEpochMilli(), + "date_to" to it.time.toEpochMilli(), + "source_id" to "", + "source_name" to metadata.dataOrigin.packageName, + "recording_method" to metadata.recordingMethod + ) + } + is HydrationRecord -> return listOf( mapOf( @@ -2535,6 +2549,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) : BLOOD_GLUCOSE to BloodGlucoseRecord::class, HEART_RATE_VARIABILITY_RMSSD to HeartRateVariabilityRmssdRecord::class, DISTANCE_DELTA to DistanceRecord::class, + SPEED to SpeedRecord::class, WATER to HydrationRecord::class, SLEEP_ASLEEP to SleepSessionRecord::class, SLEEP_AWAKE to SleepSessionRecord::class, diff --git a/packages/health/example/lib/util.dart b/packages/health/example/lib/util.dart index 1cdf17de2..8bb37fda8 100644 --- a/packages/health/example/lib/util.dart +++ b/packages/health/example/lib/util.dart @@ -29,6 +29,7 @@ const List dataTypesIOS = [ HealthDataType.WEIGHT, HealthDataType.FLIGHTS_CLIMBED, HealthDataType.DISTANCE_WALKING_RUNNING, + HealthDataType.WALKING_SPEED, HealthDataType.MINDFULNESS, HealthDataType.SLEEP_AWAKE, HealthDataType.SLEEP_ASLEEP, @@ -83,6 +84,7 @@ const List dataTypesAndroid = [ HealthDataType.HEART_RATE_VARIABILITY_RMSSD, HealthDataType.STEPS, HealthDataType.DISTANCE_DELTA, + HealthDataType.SPEED, HealthDataType.RESPIRATORY_RATE, HealthDataType.SLEEP_ASLEEP, HealthDataType.SLEEP_AWAKE_IN_BED, diff --git a/packages/health/ios/Classes/HealthConstants.swift b/packages/health/ios/Classes/HealthConstants.swift index cda0a14b5..49d56788f 100644 --- a/packages/health/ios/Classes/HealthConstants.swift +++ b/packages/health/ios/Classes/HealthConstants.swift @@ -128,6 +128,7 @@ enum HealthConstants { static let DISTANCE_WALKING_RUNNING = "DISTANCE_WALKING_RUNNING" static let DISTANCE_SWIMMING = "DISTANCE_SWIMMING" static let DISTANCE_CYCLING = "DISTANCE_CYCLING" + static let WALKING_SPEED = "WALKING_SPEED" static let FLIGHTS_CLIMBED = "FLIGHTS_CLIMBED" static let MINDFULNESS = "MINDFULNESS" static let SLEEP_ASLEEP = "SLEEP_ASLEEP" @@ -201,6 +202,7 @@ enum HealthConstants { static let BEATS_PER_MINUTE = "BEATS_PER_MINUTE" static let RESPIRATIONS_PER_MINUTE = "RESPIRATIONS_PER_MINUTE" static let MILLIGRAM_PER_DECILITER = "MILLIGRAM_PER_DECILITER" + static let METER_PER_SECOND = "METER_PER_SECOND" static let UNKNOWN_UNIT = "UNKNOWN_UNIT" static let NO_UNIT = "NO_UNIT" } diff --git a/packages/health/ios/Classes/SwiftHealthPlugin.swift b/packages/health/ios/Classes/SwiftHealthPlugin.swift index 881e2b6a7..21cab1556 100644 --- a/packages/health/ios/Classes/SwiftHealthPlugin.swift +++ b/packages/health/ios/Classes/SwiftHealthPlugin.swift @@ -225,6 +225,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { unitDict[HealthConstants.BEATS_PER_MINUTE] = HKUnit.init(from: "count/min") unitDict[HealthConstants.RESPIRATIONS_PER_MINUTE] = HKUnit.init(from: "count/min") unitDict[HealthConstants.MILLIGRAM_PER_DECILITER] = HKUnit.init(from: "mg/dL") + unitDict[HealthConstants.METER_PER_SECOND] = HKUnit.init(from: "m/s") unitDict[HealthConstants.UNKNOWN_UNIT] = HKUnit.init(from: "") unitDict[HealthConstants.NO_UNIT] = HKUnit.init(from: "") @@ -515,6 +516,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin { @available(iOS 14.0, *) private func initializeIOS14Types() { dataTypesDict[HealthConstants.ELECTROCARDIOGRAM] = HKSampleType.electrocardiogramType() + dataTypesDict[HealthConstants.WALKING_SPEED] = HKSampleType.quantityType(forIdentifier: .walkingSpeed) unitDict[HealthConstants.VOLT] = HKUnit.volt() unitDict[HealthConstants.INCHES_OF_MERCURY] = HKUnit.inchesOfMercury() diff --git a/packages/health/ios/health.podspec b/packages/health/ios/health.podspec index 0c7782db1..19a1b64f6 100644 --- a/packages/health/ios/health.podspec +++ b/packages/health/ios/health.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'health' - s.version = '13.0.1' + s.version = '13.0.2' s.summary = 'Wrapper for Apple\'s HealthKit on iOS and Google\'s Health Connect on Android.' s.description = <<-DESC Wrapper for Apple's HealthKit on iOS and Google's Health Connect on Android. diff --git a/packages/health/lib/health.g.dart b/packages/health/lib/health.g.dart index 8da99f284..923df3871 100644 --- a/packages/health/lib/health.g.dart +++ b/packages/health/lib/health.g.dart @@ -140,6 +140,8 @@ const _$HealthDataTypeEnumMap = { HealthDataType.HEADACHE_UNSPECIFIED: 'HEADACHE_UNSPECIFIED', HealthDataType.NUTRITION: 'NUTRITION', HealthDataType.UV_INDEX: 'UV_INDEX', + HealthDataType.WALKING_SPEED: 'WALKING_SPEED', + HealthDataType.SPEED: 'SPEED', HealthDataType.GENDER: 'GENDER', HealthDataType.BIRTH_DATE: 'BIRTH_DATE', HealthDataType.BLOOD_TYPE: 'BLOOD_TYPE', @@ -202,6 +204,7 @@ const _$HealthDataUnitEnumMap = { HealthDataUnit.BEATS_PER_MINUTE: 'BEATS_PER_MINUTE', HealthDataUnit.RESPIRATIONS_PER_MINUTE: 'RESPIRATIONS_PER_MINUTE', HealthDataUnit.MILLIGRAM_PER_DECILITER: 'MILLIGRAM_PER_DECILITER', + HealthDataUnit.METER_PER_SECOND: 'METER_PER_SECOND', HealthDataUnit.UNKNOWN_UNIT: 'UNKNOWN_UNIT', HealthDataUnit.NO_UNIT: 'NO_UNIT', }; diff --git a/packages/health/lib/src/heath_data_types.dart b/packages/health/lib/src/heath_data_types.dart index 7ac85c9e6..cd36c89d7 100644 --- a/packages/health/lib/src/heath_data_types.dart +++ b/packages/health/lib/src/heath_data_types.dart @@ -71,6 +71,8 @@ enum HealthDataType { DISTANCE_CYCLING, FLIGHTS_CLIMBED, DISTANCE_DELTA, + WALKING_SPEED, + SPEED, MINDFULNESS, WATER, SLEEP_ASLEEP, @@ -108,7 +110,7 @@ enum HealthDataType { ELECTROCARDIOGRAM, // Health Connect - TOTAL_CALORIES_BURNED + TOTAL_CALORIES_BURNED, } /// Access types for Health Data. @@ -190,6 +192,7 @@ const List dataTypeKeysIOS = [ HealthDataType.DISTANCE_WALKING_RUNNING, HealthDataType.DISTANCE_SWIMMING, HealthDataType.DISTANCE_CYCLING, + HealthDataType.WALKING_SPEED, HealthDataType.MINDFULNESS, HealthDataType.SLEEP_ASLEEP, HealthDataType.SLEEP_AWAKE, @@ -235,6 +238,7 @@ const List dataTypeKeysAndroid = [ HealthDataType.STEPS, HealthDataType.WEIGHT, HealthDataType.DISTANCE_DELTA, + HealthDataType.SPEED, HealthDataType.SLEEP_ASLEEP, HealthDataType.SLEEP_AWAKE_IN_BED, HealthDataType.SLEEP_AWAKE, @@ -326,6 +330,8 @@ const Map dataTypeToUnit = { HealthDataType.DISTANCE_CYCLING: HealthDataUnit.METER, HealthDataType.FLIGHTS_CLIMBED: HealthDataUnit.COUNT, HealthDataType.DISTANCE_DELTA: HealthDataUnit.METER, + HealthDataType.WALKING_SPEED: HealthDataUnit.METER_PER_SECOND, + HealthDataType.SPEED: HealthDataUnit.METER_PER_SECOND, HealthDataType.WATER: HealthDataUnit.LITER, HealthDataType.SLEEP_ASLEEP: HealthDataUnit.MINUTE, @@ -453,6 +459,7 @@ enum HealthDataUnit { BEATS_PER_MINUTE, RESPIRATIONS_PER_MINUTE, MILLIGRAM_PER_DECILITER, + METER_PER_SECOND, UNKNOWN_UNIT, NO_UNIT, } diff --git a/packages/health/pubspec.yaml b/packages/health/pubspec.yaml index d923a0955..32bbad088 100644 --- a/packages/health/pubspec.yaml +++ b/packages/health/pubspec.yaml @@ -1,6 +1,6 @@ name: health description: Wrapper for Apple's HealthKit on iOS and Google's Health Connect on Android. -version: 13.0.1 +version: 13.0.2 homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/health environment: