-
Notifications
You must be signed in to change notification settings - Fork 3
DmfsTaskList/DmfsTask: provide all fields for DAVx5 #138
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
base: main
Are you sure you want to change the base?
Conversation
b03dbe3 to
04b34c8
Compare
There was a problem hiding this 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 moves task synchronization functionality from DAVx5 to the ical4android library by making DmfsTaskList and DmfsTask classes less abstract and providing all necessary fields for DAVx5 integration. The changes eliminate the need for DAVx5 to override populate* and build* methods.
Key changes:
- Changed
DmfsTaskListandDmfsTaskfrom abstract to open classes - Added sync-related fields (
syncId,eTag,flags,accessLevel) and methods (readSyncState,writeSyncState) - Changed
populate*andbuild*methods from protected/open to protected/private to prevent overriding
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
lib/src/main/kotlin/at/bitfire/ical4android/DmfsTaskList.kt |
Added accessLevel field, readSyncState/writeSyncState methods; changed class from abstract to open; made populate method private |
lib/src/main/kotlin/at/bitfire/ical4android/DmfsTask.kt |
Added syncId, eTag, flags fields; updated constructors to accept sync-related parameters; changed class from abstract to open; made internal methods private/protected |
lib/src/androidTest/kotlin/at/bitfire/ical4android/impl/TestTask.kt |
Updated constructor call to pass new required parameters (syncId, eTag, scheduleTag, flags) |
lib/src/androidTest/kotlin/at/bitfire/ical4android/DmfsTaskTest.kt |
Added test case to verify the new ContentValues constructor correctly populates fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| id = values.getAsLong(Tasks._ID) | ||
| syncId = values.getAsString(Tasks._SYNC_ID) | ||
| eTag = values.getAsString(COLUMN_ETAG) | ||
| flags = values.getAsInteger(COLUMN_FLAGS) |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getAsInteger() method can return null when the column value is missing or NULL, but flags is declared as a non-nullable Int with default value 0. This will cause a NullPointerException if COLUMN_FLAGS is not present in the ContentValues. Consider using the elvis operator: flags = values.getAsInteger(COLUMN_FLAGS) ?: 0
| flags = values.getAsInteger(COLUMN_FLAGS) | |
| flags = values.getAsInteger(COLUMN_FLAGS) ?: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, original code also has ?: 0
| } | ||
|
|
||
| fun writeSyncState(state: String?) { | ||
| val values = contentValuesOf(COLUMN_SYNC_STATE to state.toString()) |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting state to String with .toString() is problematic when state is null, as it will store the literal string "null" instead of a SQL NULL value. Consider using state directly: contentValuesOf(COLUMN_SYNC_STATE to state). This will correctly store NULL in the database when state is null.
| val values = contentValuesOf(COLUMN_SYNC_STATE to state.toString()) | |
| val values = contentValuesOf(COLUMN_SYNC_STATE to state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
| */ | ||
| abstract class DmfsTask( | ||
| open class DmfsTask( | ||
| val taskList: DmfsTaskList<DmfsTask> |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a type inconsistency between the primary constructor parameter (taskList: DmfsTaskList<DmfsTask>) and the secondary constructors (taskList: DmfsTaskList<*>). For consistency and to allow subclasses to pass their own task list types, consider changing the primary constructor parameter to val taskList: DmfsTaskList<*> or using a more specific type bound like DmfsTaskList<out DmfsTask>.
| val taskList: DmfsTaskList<DmfsTask> | |
| val taskList: DmfsTaskList<out DmfsTask> |
For #116 (not closing)
Moves functionality from DAVx5
LocalTaskListandLocalTaskto the library so that there's no need to overridepopulate…andbuild…anymore.To be combined with bitfireAT/davx5-ose#1811