Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health 10.2.0 #944

Merged
merged 21 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dd6a32a
feat: add `STAND_TIME` data type
bruce3x Dec 26, 2023
b6978ab
feat: get data only from watch
bruce3x Jan 8, 2024
2306345
Add support for saving blood pressure as a correlation(ios)
ikoamu Feb 24, 2024
42f7eef
add body water mass to health connect
tm-hirai Mar 14, 2024
ee72db8
Merge pull request #920 from NickBalnaves/master
bardram Mar 25, 2024
d6d4b26
Merge pull request #917 from tm-hirai/health/add-body-water-mass-to-h…
bardram Mar 25, 2024
c043d52
Merge branch 'master' into feature/add-stand-time
bardram Mar 25, 2024
01a702d
Merge pull request #866 from bruce3x/feature/add-stand-time
bardram Mar 25, 2024
7a0d332
Merge branch 'master' of https://github.com/cph-cachet/flutter-plugin…
ikoamu Mar 26, 2024
532cf5d
writeWorkoutData: Add title
ciriousjoker Mar 30, 2024
73be5d1
Merge remote-tracking branch 'upstream/master' into fix/write-blood-p…
ikoamu Mar 31, 2024
5342c0d
resolve conflict
ikoamu Mar 31, 2024
f40f30a
Add missing newline at end of file
ikoamu Mar 31, 2024
6fcf0bd
Add installHealthConnect
ciriousjoker Apr 2, 2024
ddbb06d
Add getHealthConnectSdkStatus
ciriousjoker Apr 2, 2024
34f41d9
Merge pull request #941 from dieringe/health_getHealthConnectStatus
bardram Apr 3, 2024
d83f080
Merge pull request #943 from dieringe/health_installHealthConnect
bardram Apr 3, 2024
19b2892
Merge pull request #938 from dieringe/health_writeWorkoutData_title
bardram Apr 3, 2024
d96cf6a
PR #941 #943 #938 merged
bardram Apr 3, 2024
f6326cb
Merge pull request #919 from ikoamu/fix/write-blood-pressure
bardram Apr 3, 2024
122b3ae
PR #919 & support for HealthPlatformType
bardram Apr 3, 2024
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
16 changes: 13 additions & 3 deletions packages/health/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
## 10.2.0

* Using named parameters in most methods for consistency.
* Added a `HealthPlatformType` to save which health platform the data originates from (Apple Health, Google Fit, or Google Health Connect).
* Android: Improved support for Google Health Connect
* getHealthConnectSdkStatus, PR [#941](https://github.com/cph-cachet/flutter-plugins/pull/941)
* installHealthConnect, PR [#943](https://github.com/cph-cachet/flutter-plugins/pull/943)
* workout title, PR [#938](https://github.com/cph-cachet/flutter-plugins/pull/938)
* iOS: Add support for saving blood pressure as a correlation, PR [#919](https://github.com/cph-cachet/flutter-plugins/pull/919)

## 10.1.1

* fix of error in `WorkoutSummary` JSON serialization.
* fix of [#934](https://github.com/cph-cachet/flutter-plugins/issues/934)
* empty value check for calories nutrition, PR [#926](https://github.com/cph-cachet/flutter-plugins/pull/926)
* Fix of error in `WorkoutSummary` JSON serialization.
* Fix of [#934](https://github.com/cph-cachet/flutter-plugins/issues/934)
* Empty value check for calories nutrition, PR [#926](https://github.com/cph-cachet/flutter-plugins/pull/926)

## 10.0.0

Expand Down
28 changes: 23 additions & 5 deletions packages/health/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,35 @@ HealthDataType type;
HealthDataUnit unit;
DateTime dateFrom;
DateTime dateTo;
PlatformType platform;
String uuid, deviceId;
HealthPlatformType sourcePlatform;
String sourceDeviceId;
String sourceId;
String sourceName;
bool isManualEntry;
WorkoutSummary? workoutSummary;
```

where a [HealthValue](https://pub.dev/documentation/health/latest/health/HealthValue-class.html) can be any type of `AudiogramHealthValue`, `ElectrocardiogramHealthValue`, `ElectrocardiogramVoltageValue`, `NumericHealthValue`, `NutritionHealthValue`, or `WorkoutHealthValue`.

A `HealthDataPoint` object can be serialized to and from JSON using the `toJson()` and `fromJson()` methods. JSON serialization is using camel_case notation.
where a [`HealthValue`](https://pub.dev/documentation/health/latest/health/HealthValue-class.html) can be any type of `AudiogramHealthValue`, `ElectrocardiogramHealthValue`, `ElectrocardiogramVoltageValue`, `NumericHealthValue`, `NutritionHealthValue`, or `WorkoutHealthValue`.

A `HealthDataPoint` object can be serialized to and from JSON using the `toJson()` and `fromJson()` methods. JSON serialization is using camel_case notation. Null values are not serialized. For example;

```json
{
"value": {
"__type": "NumericHealthValue",
"numeric_value": 141.0
},
"type": "STEPS",
"unit": "COUNT",
"date_from": "2024-04-03T10:06:57.736",
"date_to": "2024-04-03T10:12:51.724",
"source_platform": "appleHealth",
"source_device_id": "F74938B9-C011-4DE4-AA5E-CF41B60B96E7",
"source_id": "com.apple.health.81AE7156-EC05-47E3-AC93-2D6F65C717DF",
"source_name": "iPhone12.bardram.net",
"is_manual_entry": false
}
```

### Fetch health data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Handler
import android.util.Log
Expand Down Expand Up @@ -2382,7 +2383,9 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
/** Handle calls from the MethodChannel */
override fun onMethodCall(call: MethodCall, result: Result) {
when (call.method) {
"installHealthConnect" -> installHealthConnect(call, result)
"useHealthConnectIfAvailable" -> useHealthConnectIfAvailable(call, result)
"getHealthConnectSdkStatus" -> getHealthConnectSdkStatus(call, result)
"hasPermissions" -> hasPermissions(call, result)
"requestAuthorization" -> requestAuthorization(call, result)
"revokePermissions" -> revokePermissions(call, result)
Expand All @@ -2408,15 +2411,13 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
binding.addActivityResultListener(this)
activity = binding.activity

if (healthConnectAvailable) {
val requestPermissionActivityContract =
PermissionController.createRequestPermissionResultContract()
val requestPermissionActivityContract =
PermissionController.createRequestPermissionResultContract()

healthConnectRequestPermissionsLauncher =
(activity as ComponentActivity).registerForActivityResult(
requestPermissionActivityContract
) { granted -> onHealthConnectPermissionCallback(granted) }
}
healthConnectRequestPermissionsLauncher =
(activity as ComponentActivity).registerForActivityResult(
requestPermissionActivityContract
) { granted -> onHealthConnectPermissionCallback(granted) }
}

override fun onDetachedFromActivityForConfigChanges() {
Expand Down Expand Up @@ -2444,11 +2445,37 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
healthConnectAvailable = healthConnectStatus == HealthConnectClient.SDK_AVAILABLE
}

private fun installHealthConnect(call: MethodCall, result: Result) {
val uriString =
"market://details?id=com.google.android.apps.healthdata&url=healthconnect%3A%2F%2Fonboarding"
context!!.startActivity(
Intent(Intent.ACTION_VIEW).apply {
setPackage("com.android.vending")
data = Uri.parse(uriString)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra("overlay", true)
putExtra("callerId", context!!.packageName)
}
)
result.success(null)
}

fun useHealthConnectIfAvailable(call: MethodCall, result: Result) {
useHealthConnectIfAvailable = true
result.success(null)
}

private fun getHealthConnectSdkStatus(call: MethodCall, result: Result) {
checkAvailability()
if (healthConnectAvailable) {
healthConnectClient =
HealthConnectClient.getOrCreate(
context!!
)
}
result.success(healthConnectStatus)
}

private fun hasPermissionsHC(call: MethodCall, result: Result) {
val args = call.arguments as HashMap<*, *>
val types = (args["types"] as? ArrayList<*>)?.filterIsInstance<String>()!!
Expand Down Expand Up @@ -3765,6 +3792,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
return
}
val workoutType = workoutTypeMapHealthConnect[type]!!
val title = call.argument<String>("title") ?: type

scope.launch {
try {
Expand All @@ -3776,7 +3804,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
endTime = endTime,
endZoneOffset = null,
exerciseType = workoutType,
title = type,
title = title,
),
)
if (totalDistance != null) {
Expand Down
Loading
Loading