Repository navigation
feat(android): use profile weight from Health Connect - #2632
Merged
Merged
Conversation
Adds an opt-in "Use weight from Health Connect" toggle to the Profile card (off by default). While on, every Health Connect import writes the newest Health Connect weight into the profile, the weight stepper is locked, and a caption names the source and the reading's day. Switching it on syncs once immediately from the already-imported rows. The profile sync and the Today Weight tile resolve the reading through one helper (ProfileWeightSync.newest), so with the toggle on they cannot show different weights. Android only: Apple platforms have no Health Connect. The toggle and its sync day stay out of the .noopbak whitelist; the synced weight still round-trips as profile.weightKg.
ProfileWeightSync.kt sits under the governed com/noop/analytics root, so the new file and its newest/captionDate functions entered the parity inventory one-sided. Record all three as platform_specific (Apple platforms have no Health Connect, so there is no Swift counterpart) and refresh the derived twin-map authority. Also document that ProfileWeightSync.newest resolves by day: two readings on the same day are separated only by input order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebase of #2493 by @paradix86 onto current main, so the work can land with CI green. The original description there stays the authoritative account of the feature.
Both commits keep @paradix86 as author. Rebase-merge rather than squash so that stays true.
What the rebase changed
One file conflicted,
Tools/parity_twin_map.json, which is generated. I took main's copy and regenerated it from source withparity_ledger.py --refresh-derivedrather than hand-merging the hunks. The resulting delta is authority counts only: files 507 to 508, functions 4518 to 4520, matchingProfileWeightSync.ktplus itsnewestandcaptionDate. A useful side-confirmation from those counts is that only one file registered rather than two, socom.noop.uisits outside the governed Kotlin roots andHealthConnectWeightSync.ktcorrectly needs no disposition. That regeneration is folded into the existing parity commit, since that commit exists for exactly this metadata.No source file was touched by the rebase. The footprint is identical to #2493: 22 files, +423/-19.
Verification
Android unit tests on the rebased tree with
--no-build-cache --rerun-tasks, andsyncRoomSchemaSnapshotin its own invocation first:ProfileWeightSyncTestHealthConnectWeightSyncTestTodayMetricTilesTestBackupSettingsCodecTestProfileStoreAgeMigrationTest81 tests, no failures and no errors, with the result XML timestamps checked against the wall clock so these are not a stale read. Every compiler warning in the build predates this branch.
Checked statically as well: all four new string keys are present in the default locale and in all eight translations, and no locale carries a key the default lacks, which is the ExtraTranslation class that only release lint catches. Key counts move 2735 to 2739 in the default and gain four in every locale, so no new drift. The
values-deshortfall of one and thevalues-rushortfall of 122 both predate this branch.Separately verified during review: the opt-in genuinely defaults off, the locked stepper blocks taps through
clickable(enabled = ...)rather than only dimming via alpha (a dim-only lock would let a manual edit be silently overwritten on the next sync), the imperial branch locks too, andlatestWeightKgpreserves the previous tie-break so the default-off path is unchanged.Review notes, non-blocking
ProfileWeightSync.newestcarries a doc comment warning that two readings on the same day resolve only by input order. That cannot happen through the real path:HealthConnectImporteralready resolves intra-day by timestamp (if (r.time.epochSecond >= b.weightTs), the same guard itsBodyFatRecordandLeanBodyMassRecordneighbours use), andappleDailyholds one row per(deviceId, day). Sonewestonly ever sees one already-latest reading per day. Worth correcting so nobody later threads timestamps through to fix a problem that is not there.Refs #2493