-
Notifications
You must be signed in to change notification settings - Fork 139
Migrate SyncStatus to Jetpack Compose #3488
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: master
Are you sure you want to change the base?
Conversation
This PR migrates the Sync Status screen to Jetpack Compose, removing legacy XML layouts.
Summary of ChangesHello @gino-m, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request represents the second phase of migrating the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request successfully migrates SyncStatusFragment to Jetpack Compose by replacing the XML layout with a ComposeView and introducing a new SyncStatusScreen composable. The implementation is clean and follows modern Android practices. However, I've identified a critical issue in gradle.properties where a hardcoded local path has been added, which will break the build for other developers. Additionally, I've provided a few suggestions to improve the new Compose code for better performance, testability, and readability.
gradle.properties
Outdated
| # This option should only be used with decoupled projects. More details, visit | ||
| # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
| # org.gradle.parallel=true | ||
| org.gradle.java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home |
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.
This hardcoded, absolute path for org.gradle.java.home is specific to a single developer's machine and should not be committed to version control. It will cause build failures for other team members on different operating systems or with different Android Studio installation paths. This setting should be configured locally by each developer, for example in the local.properties file (which is typically ignored by Git) or as an environment variable.
| return androidx.compose.ui.platform.ComposeView(requireContext()).apply { | ||
| setViewCompositionStrategy( | ||
| androidx.compose.ui.platform.ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed | ||
| ) | ||
| setContent { | ||
| org.groundplatform.android.ui.theme.AppTheme { | ||
| val list by viewModel.uploadStatus.observeAsState(emptyList()) | ||
| SyncStatusScreen(uploadStatuses = list, onBack = { findNavController().navigateUp() }) | ||
| } | ||
| } | ||
| } |
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.
To improve code readability, it's better to import the classes used here instead of using their fully qualified names. Please add imports for androidx.compose.ui.platform.ComposeView, androidx.compose.ui.platform.ViewCompositionStrategy, and org.groundplatform.android.ui.theme.AppTheme.
| return androidx.compose.ui.platform.ComposeView(requireContext()).apply { | |
| setViewCompositionStrategy( | |
| androidx.compose.ui.platform.ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed | |
| ) | |
| setContent { | |
| org.groundplatform.android.ui.theme.AppTheme { | |
| val list by viewModel.uploadStatus.observeAsState(emptyList()) | |
| SyncStatusScreen(uploadStatuses = list, onBack = { findNavController().navigateUp() }) | |
| } | |
| } | |
| } | |
| return ComposeView(requireContext()).apply { | |
| setViewCompositionStrategy( | |
| ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed | |
| ) | |
| setContent { | |
| AppTheme { | |
| val list by viewModel.uploadStatus.observeAsState(emptyList()) | |
| SyncStatusScreen(uploadStatuses = list, onBack = { findNavController().navigateUp() }) | |
| } | |
| } | |
| } |
| items(uploadStatuses) { | ||
| SyncListItem(modifier = Modifier.semantics { testTag = "item ${it.user}" }, detail = it) | ||
| } |
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.
Here are a couple of suggestions to improve this LazyColumn implementation:
-
Provide a unique key: For better performance and to prevent potential issues with state when the list is modified, it's a best practice to provide a unique
keyfor each item. SinceSyncStatusDetaildoesn't have a unique ID field, you can compose a key from its existing properties. -
Ensure unique
testTag: ThetestTagis generated using only the user's name, which is not guaranteed to be unique if a user has multiple items. This could lead to flaky UI tests. A more robusttestTagcan be created from a combination of fields likelabelandsubtitle.
items(
items = uploadStatuses,
key = { "${it.timestamp.time}-${it.label}-${it.subtitle}" }
) {
SyncListItem(
modifier = Modifier.semantics { testTag = "item ${it.label} ${it.subtitle}" },
detail = it
)
}
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3488 +/- ##
============================================
+ Coverage 69.82% 69.87% +0.05%
+ Complexity 1599 1597 -2
============================================
Files 322 323 +1
Lines 8678 8693 +15
Branches 949 949
============================================
+ Hits 6059 6074 +15
Misses 2049 2049
Partials 570 570
🚀 New features to boost your workflow:
|
Migrates SyncStatusFragment to Compose. Part 2 of 3.
Towards #1795