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]: Remove Google Fit support #1014

Merged
merged 22 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c582918
Remove Google Fit and imports from Android code
SlimShadyIAm Aug 6, 2024
2590ffe
Formatting
SlimShadyIAm Aug 6, 2024
58159bf
Merge branch 'master' into feature/remove-google-fit
SlimShadyIAm Aug 6, 2024
401fa75
Remove Google Fit column from readme
SlimShadyIAm Aug 6, 2024
aa4c763
Remove support for Google Fit types not supported by Health Connect
SlimShadyIAm Aug 6, 2024
2acaaf6
Remove more Google Fit workout types
SlimShadyIAm Aug 6, 2024
58a6ae7
Remove references to Google Fit, remove `useHealthConnectIfAvailable`
SlimShadyIAm Aug 7, 2024
f8bbc42
Remove `disconect` method channel
SlimShadyIAm Aug 7, 2024
99eae33
Remove `flowRate` from `writeBloodOxygen` as it is not supported in H…
SlimShadyIAm Aug 7, 2024
99ae5dd
Remove more unsupported workout types
SlimShadyIAm Aug 7, 2024
d604507
Add missing import
SlimShadyIAm Aug 8, 2024
458d323
Remove Google Fit as dependency
SlimShadyIAm Aug 8, 2024
c732a9e
Add notice in README
SlimShadyIAm Aug 8, 2024
0e248a6
Improve logging for HC permission callback
SlimShadyIAm Aug 8, 2024
0f5fb5a
Update some documentation
SlimShadyIAm Aug 8, 2024
3979573
Android: Fix `requestAuthorization` not returning a result on success
SlimShadyIAm Aug 8, 2024
d663b25
Remove additional workout types that are not supported
SlimShadyIAm Aug 8, 2024
1bb375c
Remove another workout type
SlimShadyIAm Aug 8, 2024
94aceae
Add missing unimplemented method
SlimShadyIAm Aug 8, 2024
bd37cd5
small updates to the README
bardram Aug 21, 2024
8adfd97
Fix an issue in generated file
SlimShadyIAm Aug 22, 2024
dd1f035
When writing data, check if the type is available on the requested pl…
SlimShadyIAm Aug 22, 2024
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
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
Loading