Skip to content

Extract row handler code from AndroidContact.getContact()#426

Merged
rfc2822 merged 15 commits into
mainfrom
androidcontact-extract-mapping
May 22, 2026
Merged

Extract row handler code from AndroidContact.getContact()#426
rfc2822 merged 15 commits into
mainfrom
androidcontact-extract-mapping

Conversation

@rfc2822
Copy link
Copy Markdown
Member

@rfc2822 rfc2822 commented May 22, 2026

Preparation for #391. Related to bitfireAT/davx5-ose#2243.

  • AndroidContact.getContact() now calls RawContactHandler instead of mapping itself
  • AndroidContact/AndroidGroup: rename _contact to cachedContact without changing logic
  • ContactProcessor is split into RawContactHandler and RawContactBuilder (same naming scheme as for events)
  • Move two tests from AndroidContactTest that actually don't test AndroidContact to where they belong

@rfc2822 rfc2822 self-assigned this May 22, 2026
@rfc2822 rfc2822 added the refactoring Quality improvement of existing functions label May 22, 2026
@rfc2822 rfc2822 changed the title Refactor raw contact handling for improved modularity Extract row handler code from AndroidContact.getContact() May 22, 2026
@rfc2822 rfc2822 requested a review from Copilot May 22, 2026 10:57
@rfc2822 rfc2822 marked this pull request as ready for review May 22, 2026 10:57
Copy link
Copy Markdown
Contributor

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 Android contacts raw-contact row processing by extracting read/write responsibilities out of AndroidContact.getContact() into dedicated mapping components, and relocates a couple of vCard-related tests into more appropriate unit-test suites.

Changes:

  • Introduces RawContactHandler (read/mapping) and RawContactBuilder (write/row building) to replace the former combined ContactProcessor.
  • Updates AndroidContact/AndroidGroup to use a renamed contact cache field (cachedContact) and to delegate raw-contact mapping/building to the new classes.
  • Moves vCard-specific tests out of AndroidContactTest into ContactReaderTest/ContactWriterTest, and adds an Android instrumentation test for “contact not found”.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/src/test/kotlin/at/bitfire/synctools/mapping/contacts/ContactWriterTest.kt Adds a unit test for caret encoding behavior in ADR label parameter output.
lib/src/test/kotlin/at/bitfire/synctools/mapping/contacts/ContactReaderTest.kt Adds a unit test for parsing vCard3 BDAY with a timezone offset.
lib/src/main/kotlin/at/bitfire/synctools/storage/contacts/AndroidGroup.kt Renames cached contact field usage and adjusts caching logic/toString output.
lib/src/main/kotlin/at/bitfire/synctools/storage/contacts/AndroidContact.kt Delegates raw-contact row handling/building to new classes and renames cache field.
lib/src/main/kotlin/at/bitfire/synctools/mapping/contacts/RawContactHandler.kt New/updated class to centralize raw-contact and data-row parsing into Contact.
lib/src/main/kotlin/at/bitfire/synctools/mapping/contacts/RawContactBuilder.kt New class to centralize building/inserting data rows for a raw contact.
lib/src/androidTest/kotlin/at/bitfire/synctools/storage/contacts/AndroidContactTest.kt Removes vCard unit tests and adds an instrumentation test for missing contacts.

Comment thread lib/src/main/kotlin/at/bitfire/synctools/storage/contacts/AndroidGroup.kt Outdated
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread lib/src/main/kotlin/at/bitfire/synctools/storage/contacts/AndroidContact.kt Outdated
@rfc2822 rfc2822 requested review from sunkup and removed request for sunkup May 22, 2026 11:33
@rfc2822 rfc2822 marked this pull request as draft May 22, 2026 11:35
@rfc2822 rfc2822 requested a review from sunkup May 22, 2026 11:38
@rfc2822 rfc2822 marked this pull request as ready for review May 22, 2026 11:38
Copy link
Copy Markdown
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

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

Looks good~

@rfc2822 rfc2822 merged commit ea61bf9 into main May 22, 2026
9 checks passed
@rfc2822 rfc2822 deleted the androidcontact-extract-mapping branch May 22, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Quality improvement of existing functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants