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] Add missing Android workout types #836

Merged
merged 3 commits into from
Jan 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,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 @@ -2168,6 +2168,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
Loading