Skip to content

Commit

Permalink
[Health]: Remove Google Fit support (cph-cachet#1014)
Browse files Browse the repository at this point in the history
* Remove Google Fit and imports from Android code

* Formatting

* Remove Google Fit column from readme

* Remove support for Google Fit types not supported by Health Connect

* Remove more Google Fit workout types

* Remove references to Google Fit, remove `useHealthConnectIfAvailable`

* Remove `disconect` method channel

* Remove `flowRate` from `writeBloodOxygen` as it is not supported in Health Connect

* Remove more unsupported workout types

* Add missing import

* Remove Google Fit as dependency

* Add notice in README

* Improve logging for HC permission callback

* Update some documentation

* Android: Fix `requestAuthorization` not returning a result on success

* Remove additional workout types that are not supported

* Remove another workout type

* Add missing unimplemented method

* small updates to the README

* Fix an issue in generated file

* When writing data, check if the type is available on the requested platform

---------

Co-authored-by: bardram <[email protected]>
  • Loading branch information
SlimShadyIAm and bardram authored Aug 22, 2024
1 parent 310d13d commit e076c8e
Show file tree
Hide file tree
Showing 15 changed files with 2,495 additions and 4,770 deletions.
446 changes: 181 additions & 265 deletions packages/health/README.md

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions packages/health/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ dependencies {
def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
implementation(composeBom)
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation("com.google.android.gms:play-services-fitness:21.1.0")
implementation("com.google.android.gms:play-services-auth:20.2.0")

// The new health connect api
implementation("androidx.health.connect:connect-client:1.1.0-alpha07")
def fragment_version = "1.6.2"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
Expand Down
6,338 changes: 2,187 additions & 4,151 deletions packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions packages/health/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ dependencies {
implementation(composeBom)
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
implementation("com.google.android.gms:play-services-fitness:21.1.0")
implementation("com.google.android.gms:play-services-auth:20.2.0")
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// The new health connect api
// implementation("androidx.health.connect:connect-client:1.0.0-alpha11")
}
12 changes: 2 additions & 10 deletions packages/health/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _HealthAppState extends State<HealthApp> {

void initState() {
// configure the health plugin before use.
Health().configure(useHealthConnectIfAvailable: true);
Health().configure();

super.initState();
}
Expand Down Expand Up @@ -185,7 +185,7 @@ class _HealthAppState extends State<HealthApp> {

// Add data for supported types
// NOTE: These are only the ones supported on Androids new API Health Connect.
// Both Android's Google Fit and iOS' HealthKit have more types that we support in the enum list [HealthDataType]
// Both Android's Health Connect 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;

Expand Down 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 Expand Up @@ -265,7 +260,6 @@ class _HealthAppState extends State<HealthApp> {
saturation: 98,
startTime: earlier,
endTime: now,
flowRate: 1.0,
);
success &= await Health().writeWorkoutData(
activityType: HealthWorkoutActivityType.AMERICAN_FOOTBALL,
Expand Down Expand Up @@ -591,8 +585,6 @@ class _HealthAppState extends State<HealthApp> {
Widget _authorizationNotGranted = const Column(
children: [
const Text('Authorization not given.'),
const Text(
'For Google Fit please check your OAUTH2 client ID is correct in Google Developer Console.'),
const Text(
'For Google Health Connect please check if you have added the right permissions and services to the manifest file.'),
const Text('For Apple Health check your permissions in Apple Health.'),
Expand Down
3 changes: 1 addition & 2 deletions packages/health/example/lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const List<HealthDataType> dataTypesIOS = [
/// List of data types available on Android.
///
/// Note that these are only the ones supported on Android's Health Connect API.
/// Android's Google Fit have more types that we support in the [HealthDataType]
/// Android's Health Connect has more types that we support in the [HealthDataType]
/// enumeration.
const List<HealthDataType> dataTypesAndroid = [
HealthDataType.ACTIVE_ENERGY_BURNED,
Expand All @@ -79,7 +79,6 @@ const List<HealthDataType> dataTypesAndroid = [
HealthDataType.HEART_RATE,
HealthDataType.HEART_RATE_VARIABILITY_RMSSD,
HealthDataType.STEPS,
// HealthDataType.MOVE_MINUTES, // TODO: Find alternative for Health Connect
HealthDataType.DISTANCE_DELTA,
HealthDataType.RESPIRATORY_RATE,
HealthDataType.SLEEP_AWAKE,
Expand Down
12 changes: 0 additions & 12 deletions packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,6 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
else if call.method.elementsEqual("delete") {
try! delete(call: call, result: result)
}

/// Disconnect
else if (call.method.elementsEqual("disconnect")){
// Do nothing.
result(true)
}

}

func checkIfHealthDataAvailable(call: FlutterMethodCall, result: @escaping FlutterResult) {
Expand Down Expand Up @@ -1303,8 +1296,6 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
workoutActivityTypeMap["FLEXIBILITY"] = .flexibility
workoutActivityTypeMap["WALKING"] = .walking
workoutActivityTypeMap["RUNNING"] = .running
workoutActivityTypeMap["RUNNING_JOGGING"] = .running // Supported due to combining with Android naming
workoutActivityTypeMap["RUNNING_SAND"] = .running // Supported due to combining with Android naming
workoutActivityTypeMap["RUNNING_TREADMILL"] = .running // Supported due to combining with Android naming
workoutActivityTypeMap["WHEELCHAIR_WALK_PACE"] = .wheelchairWalkPace
workoutActivityTypeMap["WHEELCHAIR_RUN_PACE"] = .wheelchairRunPace
Expand Down Expand Up @@ -1345,9 +1336,6 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
workoutActivityTypeMap["SNOW_SPORTS"] = .snowSports
workoutActivityTypeMap["SNOWBOARDING"] = .snowboarding
workoutActivityTypeMap["SKATING"] = .skatingSports
workoutActivityTypeMap["SKATING_CROSS,"] = .skatingSports // Supported due to combining with Android naming
workoutActivityTypeMap["SKATING_INDOOR,"] = .skatingSports // Supported due to combining with Android naming
workoutActivityTypeMap["SKATING_INLINE,"] = .skatingSports // Supported due to combining with Android naming
workoutActivityTypeMap["PADDLE_SPORTS"] = .paddleSports
workoutActivityTypeMap["ROWING"] = .rowing
workoutActivityTypeMap["SAILING"] = .sailing
Expand Down
4 changes: 2 additions & 2 deletions packages/health/ios/health.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Pod::Spec.new do |s|
s.name = 'health'
s.version = '1.0.4'
s.summary = 'Wrapper for the iOS HealthKit and Android GoogleFit services.'
s.summary = 'Wrapper for Apple\'s HealthKit on iOS and Google\'s Health Connect on Android.'
s.description = <<-DESC
Wrapper for the iOS HealthKit and Android GoogleFit services.
Wrapper for Apple's HealthKit on iOS and Google's Health Connect on Android.
DESC
s.homepage = 'https://pub.dev/packages/health'
s.license = { :file => '../LICENSE' }
Expand Down
110 changes: 30 additions & 80 deletions packages/health/lib/health.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/health/lib/health.json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void _registerFromJsonFunctions() {
leftEarSensitivities: [],
rightEarSensitivities: [],
),
WorkoutHealthValue(workoutActivityType: HealthWorkoutActivityType.AEROBICS),
ElectrocardiogramHealthValue(voltageValues: []),
ElectrocardiogramVoltageValue(voltage: 12, timeSinceSampleStart: 0),
NutritionHealthValue(),
Expand Down
4 changes: 2 additions & 2 deletions packages/health/lib/src/health_data_point.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of '../health.dart';

/// Types of health platforms.
enum HealthPlatformType { appleHealth, googleFit, googleHealthConnect }
enum HealthPlatformType { appleHealth, googleHealthConnect }

/// A [HealthDataPoint] object corresponds to a data point capture from
/// Apple HealthKit or Google Fit or Google Health Connect with a [HealthValue]
/// Apple HealthKit or Google Health Connect with a [HealthValue]
/// as value.
@JsonSerializable(fieldRename: FieldRename.snake, includeIfNull: false)
class HealthDataPoint {
Expand Down
Loading

0 comments on commit e076c8e

Please sign in to comment.