-
Notifications
You must be signed in to change notification settings - Fork 4
Extract row handler code from AndroidContact.getContact()
#426
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d3594b0
Add `RawContactHandler` for centralized raw contact fetching
rfc2822 c363f8a
Move data row handling from `ContactProcessor` to `RawContactHandler`
rfc2822 b1c0786
Move provider access back to AndroidContact
rfc2822 cc39736
Make `RawContactHandler` provider parameter non-nullable
rfc2822 c7a6d7e
Rename `ContactProcessor` to `RawContactBuilder`
rfc2822 b65388b
Rename `_contact` to `cachedContact` for clarity
rfc2822 ee3c648
Minor changes
rfc2822 2072a7d
Move `testAddressCaretEncoding` to `ContactWriterTest` and `testBirth…
rfc2822 ab25075
Remove `RawContactHandlerTest`
rfc2822 1350f02
Fix typo
rfc2822 0c23048
Allow `AndroidContact subclasses/users to specify their `RawContactBu…
rfc2822 06a4375
Make `setContact` parameter nullable
rfc2822 1a88385
Revert mistaken copyright notice change
rfc2822 fd324d8
Use correct rawContactBuilder in insertDataRows
rfc2822 95021ba
Merge branch 'main' into androidcontact-extract-mapping
rfc2822 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
lib/src/main/kotlin/at/bitfire/synctools/mapping/contacts/RawContactBuilder.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * This file is part of bitfireAT/synctools which is released under GPLv3. | ||
| * Copyright © All Contributors. See the LICENSE and AUTHOR files in the root directory for details. | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| */ | ||
|
|
||
| package at.bitfire.synctools.mapping.contacts | ||
|
|
||
| import android.net.Uri | ||
| import at.bitfire.synctools.mapping.contacts.builder.DataRowBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.EmailBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.EventBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.ImBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.NicknameBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.NoteBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.OrganizationBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.PhoneBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.PhotoBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.RelationBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.SipAddressBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.StructuredNameBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.StructuredPostalBuilder | ||
| import at.bitfire.synctools.mapping.contacts.builder.WebsiteBuilder | ||
| import at.bitfire.synctools.storage.contacts.ContactsBatchOperation | ||
|
|
||
| class RawContactBuilder { | ||
|
|
||
| private val dataRowBuilderFactories = mutableListOf<DataRowBuilder.Factory<*>>( | ||
| EmailBuilder.Factory, | ||
| EventBuilder.Factory, | ||
| ImBuilder.Factory, | ||
| NicknameBuilder.Factory, | ||
| NoteBuilder.Factory, | ||
| OrganizationBuilder.Factory, | ||
| PhoneBuilder.Factory, | ||
| PhotoBuilder.Factory, | ||
| RelationBuilder.Factory, | ||
| SipAddressBuilder.Factory, | ||
| StructuredNameBuilder.Factory, | ||
| StructuredPostalBuilder.Factory, | ||
| WebsiteBuilder.Factory | ||
| ) | ||
|
|
||
| fun registerBuilderFactory(factory: DataRowBuilder.Factory<*>) { | ||
| dataRowBuilderFactories += factory | ||
| } | ||
|
|
||
| fun insertDataRows(dataRowUri: Uri, rawContactId: Long?, contact: Contact, batch: ContactsBatchOperation, readOnly: Boolean) { | ||
| for (factory in dataRowBuilderFactories) { | ||
| val builder = factory.newInstance(dataRowUri, rawContactId, contact, readOnly) | ||
| batch += builder.build() | ||
| } | ||
| } | ||
|
|
||
| fun builderMimeTypes(): Set<String> { | ||
| val mimeTypes = mutableSetOf<String>() | ||
| for (factory in dataRowBuilderFactories) | ||
| mimeTypes += factory.mimeType() | ||
| return mimeTypes | ||
| } | ||
|
|
||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.