Skip to content

Commit

Permalink
[Health] implemented PRs, updated to mavenCentral
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmatteo committed Jul 18, 2023
1 parent 6621e87 commit 502563a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/health/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
ext.kotlin_version = '1.8.0'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand All @@ -17,7 +17,7 @@ buildscript {
rootProject.allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1936,11 +1936,15 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
WORKOUT -> throw IllegalArgumentException("You must use the [writeWorkoutData] API ")
else -> throw IllegalArgumentException("The type $type was not supported by the Health plugin or you must use another API ")
}
Log.i("HealthConnect", "Record: $record")
scope.launch {
try {
healthConnectClient.insertRecords(listOf(record))
Log.i("HealthConnect2", "Record: $record")

result.success(true)
} catch (e: Exception) {
Log.i("HealthConnect2", "Record: $e.message")
result.success(false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
<uses-permission android:name="android.permission.health.WRITE_OXYGEN_SATURATION"/>
<uses-permission android:name="android.permission.health.READ_HYDRATION"/>
<uses-permission android:name="android.permission.health.WRITE_HYDRATION"/>
<uses-permission android:name="android.permission.health.READ_RESTING_HEART_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_RESTING_HEART_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_FLOORS_CLIMBED"/>
<uses-permission android:name="android.permission.health.READ_FLOORS_CLIMBED"/>
<uses-permission android:name="android.permission.health.WRITE_BASAL_METABOLIC_RATE"/>
<uses-permission android:name="android.permission.health.READ_BASAL_METABOLIC_RATE"/>


<application android:label="health_example"
android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity"
Expand Down
6 changes: 3 additions & 3 deletions packages/health/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext.kotlin_version = '1.8.0'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand All @@ -14,7 +14,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down
11 changes: 11 additions & 0 deletions packages/health/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class _HealthAppState extends State<HealthApp> {
// Both Android's Google Fit and iOS' HealthKit have more types that we support in the enum list [HealthDataType]
// Add more - like AUDIOGRAM, HEADACHE_SEVERE etc. to try them.
bool success = true;
/*
success &= await health.writeHealthData(
1.925, HealthDataType.HEIGHT, earlier, now);
success &=
Expand Down Expand Up @@ -168,6 +169,16 @@ class _HealthAppState extends State<HealthApp> {
0.0, HealthDataType.SLEEP_AWAKE, earlier, now);
success &= await health.writeHealthData(
0.0, HealthDataType.SLEEP_DEEP, earlier, now);
*/

success &= await health.writeHealthData(
50.0, HealthDataType.RESTING_HEART_RATE, earlier, now);

success &= await health.writeHealthData(
50, HealthDataType.FLIGHTS_CLIMBED, earlier, now);

success &= await health.writeHealthData(
50, HealthDataType.BASAL_ENERGY_BURNED, earlier, now);

// Store an Audiogram
// Uncomment these on iOS - only available on iOS
Expand Down
3 changes: 3 additions & 0 deletions packages/health/example/lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const List<HealthDataType> dataTypesIOS = [
/// List of data types available on Android
const List<HealthDataType> dataTypesAndroid = [
HealthDataType.ACTIVE_ENERGY_BURNED,
HealthDataType.BASAL_ENERGY_BURNED,
HealthDataType.BLOOD_GLUCOSE,
HealthDataType.BLOOD_OXYGEN,
HealthDataType.BLOOD_PRESSURE_DIASTOLIC,
Expand All @@ -72,4 +73,6 @@ const List<HealthDataType> dataTypesAndroid = [
HealthDataType.SLEEP_SESSION,
HealthDataType.WATER,
HealthDataType.WORKOUT,
HealthDataType.RESTING_HEART_RATE,
HealthDataType.FLIGHTS_CLIMBED,
];

0 comments on commit 502563a

Please sign in to comment.