refactor AndroidEvent; introduce AndroidEvent2 with Entity as data object#40
Merged
refactor AndroidEvent; introduce AndroidEvent2 with Entity as data object#40
AndroidEvent; introduce AndroidEvent2 with Entity as data object#40Conversation
2db182e to
ead97a8
Compare
d26e315 to
40f7df7
Compare
4f2578e to
b58a0f6
Compare
ea3e843 to
524a3f5
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Android calendar integration by introducing a new immutable AndroidEvent2 backed by Entity, deprecating the legacy AndroidEvent, and providing a LegacyAndroidCalendar for backward mapping.
- Introduce
AndroidEvent2and updateAndroidCalendarto useEntityeverywhere - Deprecate and simplify legacy
AndroidEvent, move mapping intoLegacyAndroidCalendar - Update tests and utilities to use the new API
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/main/kotlin/at/bitfire/synctools/test/InitCalendarProviderRule.kt | Replace legacy AndroidEvent.add() calls with addEvent(Entity) |
| lib/src/main/kotlin/at/bitfire/synctools/test/AssertHelpers.kt | Add assertContentValuesEqual helper for comparing ContentValues |
| lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidEvent2.kt | New immutable AndroidEvent2 wrapping an Entity |
| lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendar.kt | Overhaul AndroidCalendar to CRUD Entity and add batch methods |
| lib/src/main/kotlin/at/bitfire/synctools/storage/BatchOperation.kt | Extend batch builder with withValues(ContentValues) |
| lib/src/main/kotlin/at/bitfire/synctools/mapping/calendar/LegacyAndroidEventProcessor.kt | Update processor to use AndroidEvent2 and LegacyAndroidCalendar |
| lib/src/main/kotlin/at/bitfire/synctools/mapping/calendar/LegacyAndroidEventBuilder.kt | Reference AndroidEvent2 constants when building legacy rows |
| lib/src/main/kotlin/at/bitfire/ical4android/LegacyAndroidCalendar.kt | New LegacyAndroidCalendar for mapping between Event and storage |
| lib/src/main/kotlin/at/bitfire/ical4android/Event.kt | Deprecate legacy Event in favor of the standard ical4j model |
| lib/src/main/kotlin/at/bitfire/ical4android/AndroidEvent.kt | Simplify and deprecate legacy AndroidEvent as a ContentValues wrapper |
| lib/src/androidTest/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendarTest.kt | Convert tests to use Entity-based API and new calendar methods |
| lib/src/androidTest/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendarProviderTest.kt | Update provider tests to use LegacyAndroidCalendar.add() |
| lib/src/androidTest/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendarProviderBehaviorTest.kt | Add behavior test for updateEventRow null-status edge case |
| lib/src/androidTest/kotlin/at/bitfire/synctools/mapping/calendar/LegacyAndroidEventProcessorTest.kt | Rename and adapt processor tests to LegacyAndroidEventProcessor |
| lib/src/androidTest/kotlin/at/bitfire/synctools/mapping/calendar/LegacyAndroidEventBuilderTest.kt | Rename builder tests to use LegacyAndroidCalendar |
| lib/src/androidTest/kotlin/at/bitfire/ical4android/AndroidEventTest.kt | Update AndroidEvent tests to use LegacyAndroidCalendar |
| README.md | Document new package layout and deprecation notes |
Comments suppressed due to low confidence (3)
lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendar.kt:75
- [nitpick] Public method
addEventlacks KDoc. Add@param entityand@returncomments to describe that it returns the newly inserted event ID and possible exceptions.
fun addEvent(entity: Entity): Long {
lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendar.kt:1
- The class KDoc lists
@param clientbut the constructor parameter isprovider: AndroidCalendarProvider. Update the@paramtag to match the actual parameter name.
/*
README.md:25
- [nitpick] The markdown sub-list under
at.bitfire.synctoolsis inconsistently indented. Consider using two spaces before each sub-item for proper list nesting.
- `at.bitfire.synctools`: new package where everything shall be refactored into
lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidCalendar.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidEvent2.kt
Outdated
Show resolved
Hide resolved
AndroidEvent: use Entity as data objectAndroidEvent; introduce AndroidEvent2 with Entity as data object
d2dc900 to
ee47481
Compare
ee47481 to
8da9161
Compare
9feaf32 to
3eab4eb
Compare
6e4d2a5 to
5012782
Compare
sunkup
approved these changes
Jul 14, 2025
Member
There was a problem hiding this comment.
I think it should be all good. I mainly looked at the tests to assume the new code will behave correctly.
Maybe @ArnyminerZ can review once as well? Just to make sure :)
lib/src/main/kotlin/at/bitfire/synctools/storage/calendar/AndroidEvent2.kt
Outdated
Show resolved
Hide resolved
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.
To be merged before bitfireAT/davx5-ose#1579, for DAVx⁵ 4.5.3
AndroidEvent2thatEntityas data object,AndroidCalendarthat has CRUD methods forAndroidEvent2.AndroidEvent:add()to the newLegacyAndroidCalendarso thatAndroidEventdoesn't need to support unsaved states withid=null.getEvent()to the newLegacyAndroidCalendar.Eventanymore.Other changes:
AndroidCalendar.Outlook / steps after this PR:
AndroidEvent.eTagetc. immutable.AndroidEvent.update()toLegacyAndroidCalendar, too.AndroidEventlook/behave more and more likeAndroidEvent2so that it can be replaced byAndroidEvent2at some point.