Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/health/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions packages/health/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1380,6 +1381,19 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
),
)

is SpeedRecord ->
return record.samples.map {
mapOf<String, Any>(
"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<String, Any>(
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/health/example/lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const List<HealthDataType> dataTypesIOS = [
HealthDataType.WEIGHT,
HealthDataType.FLIGHTS_CLIMBED,
HealthDataType.DISTANCE_WALKING_RUNNING,
HealthDataType.WALKING_SPEED,
HealthDataType.MINDFULNESS,
HealthDataType.SLEEP_AWAKE,
HealthDataType.SLEEP_ASLEEP,
Expand Down Expand Up @@ -83,6 +84,7 @@ const List<HealthDataType> dataTypesAndroid = [
HealthDataType.HEART_RATE_VARIABILITY_RMSSD,
HealthDataType.STEPS,
HealthDataType.DISTANCE_DELTA,
HealthDataType.SPEED,
HealthDataType.RESPIRATORY_RATE,
HealthDataType.SLEEP_ASLEEP,
HealthDataType.SLEEP_AWAKE_IN_BED,
Expand Down
2 changes: 2 additions & 0 deletions packages/health/ios/Classes/HealthConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "")

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/health/ios/health.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions packages/health/lib/health.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion packages/health/lib/src/heath_data_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ enum HealthDataType {
DISTANCE_CYCLING,
FLIGHTS_CLIMBED,
DISTANCE_DELTA,
WALKING_SPEED,
SPEED,
MINDFULNESS,
WATER,
SLEEP_ASLEEP,
Expand Down Expand Up @@ -108,7 +110,7 @@ enum HealthDataType {
ELECTROCARDIOGRAM,

// Health Connect
TOTAL_CALORIES_BURNED
TOTAL_CALORIES_BURNED,
}

/// Access types for Health Data.
Expand Down Expand Up @@ -190,6 +192,7 @@ const List<HealthDataType> dataTypeKeysIOS = [
HealthDataType.DISTANCE_WALKING_RUNNING,
HealthDataType.DISTANCE_SWIMMING,
HealthDataType.DISTANCE_CYCLING,
HealthDataType.WALKING_SPEED,
HealthDataType.MINDFULNESS,
HealthDataType.SLEEP_ASLEEP,
HealthDataType.SLEEP_AWAKE,
Expand Down Expand Up @@ -235,6 +238,7 @@ const List<HealthDataType> dataTypeKeysAndroid = [
HealthDataType.STEPS,
HealthDataType.WEIGHT,
HealthDataType.DISTANCE_DELTA,
HealthDataType.SPEED,
HealthDataType.SLEEP_ASLEEP,
HealthDataType.SLEEP_AWAKE_IN_BED,
HealthDataType.SLEEP_AWAKE,
Expand Down Expand Up @@ -326,6 +330,8 @@ const Map<HealthDataType, HealthDataUnit> 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,
Expand Down Expand Up @@ -453,6 +459,7 @@ enum HealthDataUnit {
BEATS_PER_MINUTE,
RESPIRATIONS_PER_MINUTE,
MILLIGRAM_PER_DECILITER,
METER_PER_SECOND,
UNKNOWN_UNIT,
NO_UNIT,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/health/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down