Skip to content

feat: [ANDROAPP-7459][4/6] Implement new sync in the app [skip size]#4641

Open
Balcan wants to merge 6 commits intoANDROAPP-7459-3from
ANDROAPP-7459-4
Open

feat: [ANDROAPP-7459][4/6] Implement new sync in the app [skip size]#4641
Balcan wants to merge 6 commits intoANDROAPP-7459-3from
ANDROAPP-7459-4

Conversation

@Balcan
Copy link
Collaborator

@Balcan Balcan commented Feb 6, 2026

Description

Link the JIRA issue.

Please provide a clear definition of the problem and explain your solution.

@Balcan Balcan force-pushed the ANDROAPP-7459-3 branch 2 times, most recently from cef2994 to 6e3c7f6 Compare February 13, 2026 11:07
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 pull request implements a new synchronization architecture for the DHIS2 Android app, migrating metadata sync from the legacy WorkManager-based implementation to a new module-based approach using Koin for dependency injection. This is part 4 of a 6-part series (ANDROAPP-7459).

Changes:

  • Migrated metadata synchronization from WorkManager to a new sync module with Koin DI
  • Refactored sync observation from LiveData to Kotlin Flow for better coroutine integration
  • Simplified Matomo analytics API by removing redundant tracker name parameter
  • Removed legacy SyncMetadataWorker and related infrastructure code

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sync/src/androidMain/kotlin/org/dhis2/mobile/sync/di/SyncModule.android.kt Added SyncMetadata use case to Koin module
sync/src/androidMain/kotlin/org/dhis2/mobile/sync/data/AndroidSyncRepository.kt Removed redundant tracker name parameter from Matomo analytics call
commonskmm/src/commonMain/kotlin/org/dhis2/mobile/commons/reporting/AnalyticActions.kt Simplified updateMatomoSecondaryTracker interface by removing trackerName parameter
commonskmm/src/androidMain/kotlin/org/dhis2/mobile/commons/di/CommonsModule.android.kt Added NotificationManager to Koin module for sync notifications
app/src/main/java/org/dhis2/utils/analytics/AnalyticsHelper.kt Updated to use DEFAULT_EXTERNAL_TRACKER_NAME constant instead of parameter
app/src/main/java/org/dhis2/usescases/sync/SyncPresenter.kt Migrated from WorkManager WorkInfo to new SyncJobStatus model with Flow-based observation
app/src/main/java/org/dhis2/usescases/sync/SyncInjector.kt Updated dependency injection to use SyncBackgroundJobAction
app/src/main/java/org/dhis2/usescases/sync/SyncActivity.kt Refactored from LiveData to Flow with coroutine collection in onResume
app/src/main/java/org/dhis2/usescases/settings/ui/SettingsScreen.kt Added SyncBackgroundJobAction injection (currently unused)
app/src/main/java/org/dhis2/usescases/settings/domain/LaunchSync.kt Migrated metadata sync operations to new SyncBackgroundJobAction API
app/src/main/java/org/dhis2/usescases/settings/SyncManagerModule.kt Added SyncBackgroundJobAction dependency to module
app/src/main/java/org/dhis2/usescases/settings/SyncManagerFragment.kt Updated to inject SyncBackgroundJobAction via Koin
app/src/main/java/org/dhis2/di/KoinInitialization.kt Added syncModule to Koin initialization
app/src/main/java/org/dhis2/data/user/UserComponent.java Removed legacy SyncMetadataWorkerComponent and SyncInitWorkerComponent
app/src/main/java/org/dhis2/data/service/workManager/WorkerType.kt Removed METADATA worker type enum value
app/src/main/java/org/dhis2/data/service/workManager/WorkManagerControllerImpl.kt Removed metadata sync worker creation and scheduling logic
app/src/main/java/org/dhis2/data/service/workManager/WorkManagerController.kt Removed syncMetaDataForWorker interface method
app/src/main/java/org/dhis2/data/service/SyncPresenterImpl.kt Removed syncMetadata and startPeriodicMetaWork methods along with SMS setup logic
app/src/main/java/org/dhis2/data/service/SyncPresenter.java Removed syncMetadata and startPeriodicMetaWork interface methods
app/src/main/AndroidManifest.xml Added FOREGROUND_SERVICE permission and simplified SystemForegroundService declaration
app/build.gradle.kts Added dependency on sync module

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

workInfoList.forEach { workInfo ->
if (workInfo.tags.contains(Constants.META_NOW)) {
handleMetaState(workInfo.state, workInfo.outputData.getString(METADATA_MESSAGE))
if (workInfo.tags.contains("METADATA_SYNC_NOW")) {
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Magic string hardcoded. The tag "METADATA_SYNC_NOW" is hardcoded here, but it's defined as a constant METADATA_SYNC_NOW in AndroidSyncBackgroundJobAction.kt (line 18). Consider extracting this to a shared constant to avoid potential inconsistencies if the tag value changes.

Copilot uses AI. Check for mistakes.
@Balcan Balcan changed the title feat: [ANDROAPP-7459][4/6] Implement new sync in the app feat: [ANDROAPP-7459][4/6] Implement new sync in the app [skip size] Feb 18, 2026
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.

4 participants

Comments