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

WIP: Health connect support #869

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

samtate
Copy link

@samtate samtate commented Nov 9, 2024

Initial development of adding Health Connect Support to the app. Sharing this first stages of development to let maintainers review and make sure they're happy with it so far before I do a lot of work on the feature.

So far I have added the health connect plugin and updated the build environment to the versions required to support Health Connect. I have made a rudimentary settings page where it can be enabled or disabled. I have tested I can send data to Health Connect

Next will be to send your diary data to the API when you enable it, and re-send more when more food is added.

@samtate samtate marked this pull request as draft November 9, 2024 15:14
@davidhealey
Copy link
Owner

updated the build environment to the versions required to support Health Connect

Does this break any of the existing features or deprecate some devices?

@samtate
Copy link
Author

samtate commented Nov 9, 2024

Does this break any of the existing features or deprecate some devices?

I wouldn't have thought it would break existing features and everything still seems to work fine.

I have had to update the minSdkVersion from 21 to 26: I understand this means that Android 5-7 are no longer supported? Android 8+ still consists of 96% of global Android devices and likely a higher percentage of users of this app.

@samtate
Copy link
Author

samtate commented Dec 7, 2024

Hi @davidhealey @EmilJunker I'm keen to continue adding this but I am just wondering the best way to iterate through every food item stored in the database and get the dateTime, calories etc. Obviously everything only needs to be synced on the first enable of Health Connect: subsequent foods can be added to Health Connect when they are added to the diary.

Health Connect returns a unique ID when each food is added which can then be used to delete it later. Should this ID be stored alongside the other data for the food item? Then the delete from diary function can also call the delete from health connect function.

An alternative is for Waistline to periodically delete all waistline health connect nutrition data and re-add from the current all-time diary. Not sure how this impacts performance on-device if it ran e.g. once a day.

@davidhealey
Copy link
Owner

Health Connect returns a unique ID when each food is added which can then be used to delete it later. Should this ID be stored alongside the other data for the food item? Then the delete from diary function can also call the delete from health connect function.

An alternative is for Waistline to periodically delete all waistline health connect nutrition data and re-add from the current all-time diary. Not sure how this impacts performance on-device if it ran e.g. once a day.

What about having a separate table for health connect data that contains both the health connect item id and the food id? It's been ages since I did any work myself on Waistline so I'm a bit out of the loop with the data storage. With SQL it's easy to setup an index with a cascade so that when an item is removed from one table it automatically removes it from the other, I don't know if a similar thing is possible with indexeddb...

@samtate
Copy link
Author

samtate commented Dec 7, 2024

Thanks for the pointers. I will try and look into the best way to do it.

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.

2 participants