Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sunkup
Copy link
Member

@sunkup sunkup commented Nov 11, 2025

For #116 (not closing)

Moves functionality from DAVx5 LocalTaskList and LocalTask to the library so that there's no need to override populate… and build… anymore.

To be combined with bitfireAT/davx5-ose#1811

@sunkup sunkup self-assigned this Nov 11, 2025
@sunkup sunkup force-pushed the dmfstasklist-features branch from b03dbe3 to 04b34c8 Compare November 11, 2025 14:52
@sunkup sunkup changed the title Dmfstasklist features LocalTaskList/LocalTask: provide all fields for DAVx5 Nov 13, 2025
@sunkup sunkup changed the title LocalTaskList/LocalTask: provide all fields for DAVx5 DmfsTaskList/DmfsTask: provide all fields for DAVx5 Nov 13, 2025
@sunkup sunkup marked this pull request as ready for review November 13, 2025 13:53
@sunkup sunkup requested a review from a team as a code owner November 13, 2025 13:53
@rfc2822 rfc2822 requested a review from Copilot November 13, 2025 15:45
Copy link
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 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 DmfsTaskList and DmfsTask from abstract to open classes
  • Added sync-related fields (syncId, eTag, flags, accessLevel) and methods (readSyncState, writeSyncState)
  • Changed populate* and build* 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)
Copy link

Copilot AI Nov 13, 2025

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

Suggested change
flags = values.getAsInteger(COLUMN_FLAGS)
flags = values.getAsInteger(COLUMN_FLAGS) ?: 0

Copilot uses AI. Check for mistakes.
Copy link
Member

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())
Copy link

Copilot AI Nov 13, 2025

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.

Suggested change
val values = contentValuesOf(COLUMN_SYNC_STATE to state.toString())
val values = contentValuesOf(COLUMN_SYNC_STATE to state)

Copilot uses AI. Check for mistakes.
Copy link
Member

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>
Copy link

Copilot AI Nov 13, 2025

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>.

Suggested change
val taskList: DmfsTaskList<DmfsTask>
val taskList: DmfsTaskList<out DmfsTask>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants