feat: [ANDROAPP-7459][4/6] Implement new sync in the app [skip size]#4641
feat: [ANDROAPP-7459][4/6] Implement new sync in the app [skip size]#4641Balcan wants to merge 6 commits intoANDROAPP-7459-3from
Conversation
a22c68a to
598dd8b
Compare
cef2994 to
6e3c7f6
Compare
598dd8b to
858dd0f
Compare
There was a problem hiding this comment.
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.
app/src/main/java/org/dhis2/usescases/settings/domain/LaunchSync.kt
Outdated
Show resolved
Hide resolved
| 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")) { |
There was a problem hiding this comment.
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.
app/src/main/java/org/dhis2/usescases/settings/ui/SettingsScreen.kt
Outdated
Show resolved
Hide resolved
6e3c7f6 to
c82d206
Compare
c6de701 to
85b0968
Compare
2da4a14 to
e1b3909
Compare
85b0968 to
14a4f3a
Compare
Description
Link the JIRA issue.
Please provide a clear definition of the problem and explain your solution.