-
Notifications
You must be signed in to change notification settings - Fork 126
build: [ANDROAPP-7337] [2/3] Implement usecases for Home screen [skip size] #4465
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: develop
Are you sure you want to change the base?
Conversation
|
andresmr
left a comment
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.
can you fix the lint check
185c8ea to
67435be
Compare
67435be to
a16af7b
Compare
app/src/main/java/org/dhis2/usescases/main/domain/model/DownloadMethod.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/dhis2/usescases/main/domain/ConfigureHomeNavigationBar.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/dhis2/usescases/main/domain/DeleteAccount.kt
Outdated
Show resolved
Hide resolved
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 implements domain-layer use cases for the Home screen as part of a multi-part feature (part 2/3). It introduces a clean architecture pattern with use case classes that handle various home screen operations including user authentication, synchronization, account management, and navigation configuration.
Key changes:
- Added 11 new use case classes for home screen operations (user management, sync, navigation, account operations)
- Created
HomeRepositoryinterface andHomeRepositoryImplwith 15 methods for data operations - Introduced domain models (
LockAction,DownloadMethod) to represent screen actions
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| LockAction.kt | Sealed interface defining PIN creation and session blocking actions |
| DownloadMethod.kt | Sealed interface for app update download methods (URL vs File) |
| UpdateInitialSyncStatus.kt | Use case to mark initial sync as completed |
| ScheduleNewVersionAlert.kt | Use case to schedule periodic app version checks using WorkManager |
| LogOutUser.kt | Use case orchestrating user logout with cleanup operations |
| LaunchInitialSync.kt | Use case determining whether to skip or perform initial sync |
| GetUserName.kt | Use case retrieving formatted user display name |
| GetLockAction.kt | Use case determining PIN creation or session lock action |
| GetHomeFilters.kt | Use case retrieving home screen filter configuration |
| DownloadNewVersion.kt (main) | Use case for downloading app updates via file system |
| DownloadNewVersion.kt (PlayServices) | Flavor-specific variant for downloading via Play Store URL |
| CheckSingleNavigation.kt | Use case checking if single-item direct navigation is possible |
| ConfigureHomeNavigationBar.kt | Use case building navigation bar items based on analytics availability |
| DeleteAccount.kt | Use case orchestrating complete account deletion with cleanup |
| HomeRepository.kt | Repository interface defining data operations for home screen |
| HomeRepositoryImpl.kt | Repository implementation using D2 SDK, Charts, and preferences |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/dhis2PlayServices/java/org/dhis2/usecases/main/domain/DownloadNewVersion.kt
Show resolved
Hide resolved
| } catch (_: DomainError) { | ||
| Result.success(listOf(programItem)) |
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.
Empty catch block silently swallows errors. The catch block on line 41 catches DomainError but then returns success with a default value, silently hiding any actual errors. Consider logging the error or returning a failure result to make debugging easier.
app/src/main/java/org/dhis2/usescases/main/domain/LaunchInitialSync.kt
Outdated
Show resolved
Hide resolved
app/src/dhis2PlayServices/java/org/dhis2/usecases/main/domain/DownloadNewVersion.kt
Show resolved
Hide resolved
| override suspend fun invoke(input: Unit): Result<DownloadMethod> = | ||
| try { | ||
| val url = versionRepository.getUrl() | ||
| url?.toUri()?.let { |
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.
Missing import statement. toUri() extension function is used but the necessary import is missing. Add import androidx.core.net.toUri at the top of the file.
| if (homeItemCount == 1) { | ||
| Result.success(homeRepository.singleHomeItemData()) | ||
| } else { | ||
| Result.failure(Exception("No programs")) |
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.
Inaccurate error message. The error message "No programs" is misleading since this code path is reached when homeItemCount != 1, which includes cases where there are zero items OR more than one item. Consider a more accurate message like "Expected exactly one home item" or "Single navigation not available".
| Result.failure(Exception("No programs")) | |
| Result.failure(Exception("Expected exactly one home item")) |
| if (homeItemCount == 1) { | ||
| Result.success(homeRepository.singleHomeItemData()) | ||
| } else { | ||
| Result.failure(Exception("No programs")) |
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.
Inconsistent error handling. This catch block catches DomainError but line 17 throws a generic Exception. For consistency, either throw a DomainError on line 17 or catch Exception here instead of DomainError.
| Result.failure(Exception("No programs")) | |
| Result.failure(DomainError("No programs")) |
…epositoryImpl Signed-off-by: andresmr <andres@dhis2.org>
a16af7b to
652f690
Compare
cc5d2c6 to
10e49fe
Compare
app/src/dhis2PlayServices/java/org/dhis2/usecases/main/domain/DownloadNewVersion.kt
Show resolved
Hide resolved
652f690 to
0da902e
Compare



Description
Link the JIRA issue.
Please provide a clear definition of the problem and explain your solution.