Skip to content

Commit

Permalink
Merge branch 'master' into feature/remove-v1-android-embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimShadyIAm committed Aug 29, 2024
2 parents 7fe84f7 + 4b19432 commit 3fb532c
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 200 deletions.
258 changes: 127 additions & 131 deletions packages/health/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.health.connect.client.records.MealType.MEAL_TYPE_DINNER
import androidx.health.connect.client.records.MealType.MEAL_TYPE_LUNCH
import androidx.health.connect.client.records.MealType.MEAL_TYPE_SNACK
import androidx.health.connect.client.records.MealType.MEAL_TYPE_UNKNOWN
import androidx.health.connect.client.records.metadata.Metadata
import androidx.health.connect.client.request.AggregateGroupByDurationRequest
import androidx.health.connect.client.request.AggregateRequest
import androidx.health.connect.client.request.ReadRecordsRequest
Expand Down Expand Up @@ -720,6 +721,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
healthConnectData.add(
// mapOf(
mapOf<String, Any?>(
"uuid" to record.metadata.id,
"workoutActivityType" to
(workoutTypeMap
.filterValues {
Expand Down Expand Up @@ -792,8 +794,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
convertRecordStage(
recStage,
dataType,
rec.metadata.dataOrigin
.packageName
rec.metadata
)
)
}
Expand Down Expand Up @@ -824,10 +825,13 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
private fun convertRecordStage(
stage: SleepSessionRecord.Stage,
dataType: String,
sourceName: String
metadata: Metadata
): List<Map<String, Any>> {
var sourceName = metadata.dataOrigin
.packageName
return listOf(
mapOf<String, Any>(
"uuid" to metadata.id,
"stage" to stage.stage,
"value" to
ChronoUnit.MINUTES.between(
Expand Down Expand Up @@ -923,6 +927,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is WeightRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.weight
.inKilograms,
Expand All @@ -942,6 +948,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is HeightRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.height
.inMeters,
Expand All @@ -961,6 +969,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is BodyFatRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.percentage
.value,
Expand All @@ -980,6 +990,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is StepsRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to record.count,
"date_from" to
record.startTime
Expand All @@ -997,6 +1009,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is ActiveCaloriesBurnedRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.energy
.inKilocalories,
Expand All @@ -1016,6 +1030,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is HeartRateRecord ->
return record.samples.map {
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to it.beatsPerMinute,
"date_from" to
it.time.toEpochMilli(),
Expand All @@ -1030,6 +1046,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is HeartRateVariabilityRmssdRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.heartRateVariabilityMillis,
"date_from" to
Expand All @@ -1048,6 +1066,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is BodyTemperatureRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.temperature
.inCelsius,
Expand All @@ -1067,6 +1087,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is BodyWaterMassRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.mass
.inKilograms,
Expand All @@ -1086,6 +1108,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is BloodPressureRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
if (dataType ==
BLOOD_PRESSURE_DIASTOLIC
Expand All @@ -1111,6 +1135,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is OxygenSaturationRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.percentage
.value,
Expand All @@ -1130,6 +1156,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is BloodGlucoseRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.level
.inMilligramsPerDeciliter,
Expand All @@ -1149,6 +1177,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is DistanceRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.distance
.inMeters,
Expand All @@ -1168,6 +1198,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is HydrationRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.volume
.inLiters,
Expand All @@ -1187,6 +1219,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is TotalCaloriesBurnedRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.energy
.inKilocalories,
Expand All @@ -1206,6 +1240,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is BasalMetabolicRateRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.basalMetabolicRate
.inKilocaloriesPerDay,
Expand All @@ -1225,6 +1261,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is SleepSessionRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"date_from" to
record.startTime
.toEpochMilli(),
Expand All @@ -1247,6 +1285,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is RestingHeartRateRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to
record.beatsPerMinute,
"date_from" to
Expand All @@ -1265,6 +1305,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is FloorsClimbedRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to record.floors,
"date_from" to
record.startTime
Expand All @@ -1282,6 +1324,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is RespiratoryRateRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to
metadata.id,
"value" to record.rate,
"date_from" to
record.time
Expand All @@ -1299,6 +1343,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is NutritionRecord ->
return listOf(
mapOf<String, Any?>(
"uuid" to metadata.id,
"calories" to record.energy?.inKilocalories,
"protein" to record.protein?.inGrams,
"carbs" to record.totalCarbohydrate?.inGrams,
Expand Down Expand Up @@ -1362,6 +1407,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
is MenstruationFlowRecord ->
return listOf(
mapOf<String, Any>(
"uuid" to metadata.id,
"value" to record.flow,
"date_from" to record.time.toEpochMilli(),
"date_to" to record.time.toEpochMilli(),
Expand Down Expand Up @@ -2180,10 +2226,13 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
"CALISTHENICS" to
ExerciseSessionRecord
.EXERCISE_TYPE_CALISTHENICS,
"CARDIO_DANCE" to
ExerciseSessionRecord
.EXERCISE_TYPE_DANCING,
"CRICKET" to ExerciseSessionRecord.EXERCISE_TYPE_CRICKET,
// "CROSS_COUNTRY_SKIING" to ExerciseSessionRecord.EXERCISE_TYPE_SKIING_CROSS_COUNTRY,
"CROSS_COUNTRY_SKIING" to ExerciseSessionRecord.EXERCISE_TYPE_SKIING,
"DANCING" to ExerciseSessionRecord.EXERCISE_TYPE_DANCING,
// "DOWNHILL_SKIING" to ExerciseSessionRecord.EXERCISE_TYPE_SKIING_DOWNHILL,
"DOWNHILL_SKIING" to ExerciseSessionRecord.EXERCISE_TYPE_SKIING,
"ELLIPTICAL" to
ExerciseSessionRecord
.EXERCISE_TYPE_ELLIPTICAL,
Expand Down Expand Up @@ -2242,6 +2291,9 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
ExerciseSessionRecord
.EXERCISE_TYPE_SNOWSHOEING,
// "SOCCER" to ExerciseSessionRecord.EXERCISE_TYPE_FOOTBALL_SOCCER,
"SOCIAL_DANCE" to
ExerciseSessionRecord
.EXERCISE_TYPE_DANCING,
"SOFTBALL" to ExerciseSessionRecord.EXERCISE_TYPE_SOFTBALL,
"SQUASH" to ExerciseSessionRecord.EXERCISE_TYPE_SQUASH,
"STAIR_CLIMBING_MACHINE" to
Expand Down Expand Up @@ -2277,6 +2329,12 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
"WHEELCHAIR" to
ExerciseSessionRecord
.EXERCISE_TYPE_WHEELCHAIR,
"WHEELCHAIR_RUN_PACE" to
ExerciseSessionRecord
.EXERCISE_TYPE_WHEELCHAIR,
"WHEELCHAIR_WALK_PACE" to
ExerciseSessionRecord
.EXERCISE_TYPE_WHEELCHAIR,
"YOGA" to ExerciseSessionRecord.EXERCISE_TYPE_YOGA,
"OTHER" to ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT,
)
Expand Down
5 changes: 0 additions & 5 deletions packages/health/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ class _HealthAppState extends State<HealthApp> {
type: HealthDataType.HEART_RATE,
startTime: earlier,
endTime: now);
success &= await Health().writeHealthData(
value: 30,
type: HealthDataType.HEART_RATE_VARIABILITY_RMSSD,
startTime: earlier,
endTime: now);
success &= await Health().writeHealthData(
value: 37,
type: HealthDataType.BODY_TEMPERATURE,
Expand Down
4 changes: 3 additions & 1 deletion packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,10 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
workoutActivityTypeMap["PADDLE_SPORTS"] = .paddleSports
workoutActivityTypeMap["ROWING"] = .rowing
workoutActivityTypeMap["SAILING"] = .sailing
workoutActivityTypeMap["SURFING_SPORTS"] = .surfingSports
workoutActivityTypeMap["SURFING"] = .surfingSports
workoutActivityTypeMap["SWIMMING"] = .swimming
workoutActivityTypeMap["SWIMMING_OPEN_WATER"] = .swimming
workoutActivityTypeMap["SWIMMING_POOL"] = .swimming
workoutActivityTypeMap["WATER_FITNESS"] = .waterFitness
workoutActivityTypeMap["WATER_POLO"] = .waterPolo
workoutActivityTypeMap["WATER_SPORTS"] = .waterSports
Expand Down
Loading

0 comments on commit 3fb532c

Please sign in to comment.