Skip to content

Commit

Permalink
Merge pull request #836 from rafaellop/patch-1
Browse files Browse the repository at this point in the history
[Health] Add missing Android workout types
  • Loading branch information
hoffmatteo authored Jan 29, 2024
2 parents 2dc2bf9 + c20121b commit d8153ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
// "BIATHLON" to ExerciseSessionRecord.EXERCISE_TYPE_BIATHLON,
"BIKING" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING,
// "BIKING_HAND" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING_HAND,
// "BIKING_MOUNTAIN" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING_MOUNTAIN,
//"BIKING_MOUNTAIN" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING_MOUNTAIN,
// "BIKING_ROAD" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING_ROAD,
// "BIKING_SPINNING" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING_SPINNING,
// "BIKING_STATIONARY" to ExerciseSessionRecord.EXERCISE_TYPE_BIKING_STATIONARY,
Expand Down Expand Up @@ -2246,6 +2246,11 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
val endTime = Instant.ofEpochMilli(call.argument<Long>("endTime")!!)
val totalEnergyBurned = call.argument<Int>("totalEnergyBurned")
val totalDistance = call.argument<Int>("totalDistance")
if(workoutTypeMapHealthConnect.containsKey(type) == false) {
result.success(false)
Log.w("FLUTTER_HEALTH::ERROR", "[Health Connect] Workout type not supported")
return
}
val workoutType = workoutTypeMapHealthConnect[type]!!

scope.launch {
Expand Down
15 changes: 15 additions & 0 deletions packages/health/lib/src/health_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class HealthFactory {
bool _isOnAndroid(HealthWorkoutActivityType type) {
// Returns true if the type is part of the Android set
return {
// Both
HealthWorkoutActivityType.ARCHERY,
HealthWorkoutActivityType.BADMINTON,
HealthWorkoutActivityType.BASEBALL,
Expand Down Expand Up @@ -786,8 +787,17 @@ class HealthFactory {
HealthWorkoutActivityType.WALKING,
HealthWorkoutActivityType.WATER_POLO,
HealthWorkoutActivityType.YOGA,

// Android only
// Once Google Fit is removed, this list needs to be changed
HealthWorkoutActivityType.AEROBICS,
HealthWorkoutActivityType.BIATHLON,
HealthWorkoutActivityType.BIKING_HAND,
HealthWorkoutActivityType.BIKING_MOUNTAIN,
HealthWorkoutActivityType.BIKING_ROAD,
HealthWorkoutActivityType.BIKING_SPINNING,
HealthWorkoutActivityType.BIKING_STATIONARY,
HealthWorkoutActivityType.BIKING_UTILITY,
HealthWorkoutActivityType.CALISTHENICS,
HealthWorkoutActivityType.CIRCUIT_TRAINING,
HealthWorkoutActivityType.CROSS_FIT,
Expand All @@ -803,6 +813,7 @@ class HealthFactory {
HealthWorkoutActivityType.HOUSEWORK,
HealthWorkoutActivityType.INTERVAL_TRAINING,
HealthWorkoutActivityType.IN_VEHICLE,
HealthWorkoutActivityType.ICE_SKATING,
HealthWorkoutActivityType.KAYAKING,
HealthWorkoutActivityType.KETTLEBELL_TRAINING,
HealthWorkoutActivityType.KICK_SCOOTER,
Expand All @@ -813,17 +824,21 @@ class HealthFactory {
HealthWorkoutActivityType.PARAGLIDING,
HealthWorkoutActivityType.POLO,
HealthWorkoutActivityType.ROCK_CLIMBING,
HealthWorkoutActivityType.ROWING_MACHINE,
HealthWorkoutActivityType.RUNNING_JOGGING,
HealthWorkoutActivityType.RUNNING_SAND,
HealthWorkoutActivityType.RUNNING_TREADMILL,
HealthWorkoutActivityType.SCUBA_DIVING,
HealthWorkoutActivityType.SKATING_CROSS,
HealthWorkoutActivityType.SKATING_INDOOR,
HealthWorkoutActivityType.SKATING_INLINE,
HealthWorkoutActivityType.SKIING,
HealthWorkoutActivityType.SKIING_BACK_COUNTRY,
HealthWorkoutActivityType.SKIING_KITE,
HealthWorkoutActivityType.SKIING_ROLLER,
HealthWorkoutActivityType.SLEDDING,
HealthWorkoutActivityType.SNOWMOBILE,
HealthWorkoutActivityType.SNOWSHOEING,
HealthWorkoutActivityType.STAIR_CLIMBING_MACHINE,
HealthWorkoutActivityType.STANDUP_PADDLEBOARDING,
HealthWorkoutActivityType.STILL,
Expand Down

0 comments on commit d8153ac

Please sign in to comment.