Skip to content

Health 13 - Refactored Android Native Implementation #1215

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

Merged
merged 15 commits into from
Jun 12, 2025
Merged

Health 13 - Refactored Android Native Implementation #1215

merged 15 commits into from
Jun 12, 2025

Conversation

iarata
Copy link
Contributor

@iarata iarata commented Jun 12, 2025

The PR for introducing the refactored of Android native implementation. Similarly to the Swift refactor there are now the following files:

HealthPlugin.kt (Main Plugin Class)
├── HealthDataReader.kt (Reading health data)
├── HealthDataWriter.kt (Writing health data)
├── HealthDataOperations.kt (Permissions and utilities)
├── HealthDataConverter.kt (Data conversion)
├── HealthRecordingFilter.kt (Filtering utility)
└── HealthConstants.kt (Constants)

All the files and function are documented as well. Below each files jobs are explained briefly:

  • HealthPlugin.kt (Main Plugin Class)
    • Flutter plugin interface and method channel management
    • Activity lifecycle handling
    • Permission handling
  • HealthDataReader.kt (Reading health data)
    • All data reading operations (getData, getAggregateData, etc.)
    • Handles pagination for large datasets
  • HealthDataWriter.kt (Writing health data)
    • All data writing operations
    • Includes special writing methods for specific data types
  • HealthDataOperations.kt (Permissions and utilities)
    • Permission checking and requesting
    • Data deletion operations
    • Health Connect SDK status, background, and history permissions check
  • HealthDataConverter.kt (Data conversion)
    • Converts Health Connect records to Flutter-compatible maps
  • HealthRecordingFilter.kt (Filtering utility)
    • Filters records by recording methods
  • HealthConstants.kt (Constants)
    • Contains all constants and type mappings
    • Uses Kotlin object for better performance

@iarata iarata requested a review from Copilot June 12, 2025 13:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the Android native implementation into modular classes and adds support for new health data types (SPEED on Android, WALKING_SPEED on iOS) with the corresponding METER_PER_SECOND unit, along with version bumps to 13.1.0.

  • Bumped package versions to 13.1.0 in pubspec, podspec, and CHANGELOG.
  • Introduced WALKING_SPEED (iOS) and SPEED (Android) data types with unit METER_PER_SECOND.
  • Split Android plugin logic into HealthDataOperations, HealthRecordingFilter, HealthDataConverter, and HealthConstants.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/health/pubspec.yaml bumped version to 13.1.0
packages/health/lib/src/heath_data_types.dart added WALKING_SPEED and SPEED types and unit mappings
packages/health/lib/health.g.dart updated serialization maps for new types and units
packages/health/ios/health.podspec bumped iOS podspec version to 13.1.0
packages/health/ios/Classes/SwiftHealthPlugin.swift added WALKING_SPEED type and METER_PER_SECOND unit support
packages/health/ios/Classes/HealthConstants.swift added constants for WALKING_SPEED and METER_PER_SECOND
packages/health/example/lib/util.dart updated example data type lists with new types
packages/health/example/lib/main.dart added example write logic for WALKING_SPEED and SPEED
packages/health/android/src/main/kotlin/cachet/plugins/health/HealthRecordingFilter.kt new record filtering utility
packages/health/android/src/main/kotlin/cachet/plugins/health/HealthDataOperations.kt new class handling permissions and data operations
packages/health/android/src/main/kotlin/cachet/plugins/health/HealthDataConverter.kt new converter from Health Connect records to Flutter maps
packages/health/android/src/main/kotlin/cachet/plugins/health/HealthConstants.kt new Android constants and type mappings
packages/health/README.md updated documentation for WALKING_SPEED
packages/health/CHANGELOG.md added 13.1.0 changelog entries

@iarata iarata merged commit 246b4c7 into master Jun 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant