Refactor to Jetpack Compose, Hilt, and Room#109
Conversation
Summary of ChangesHello @harrydbarnes, 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 introduces a comprehensive architectural overhaul, modernizing the application by migrating to Jetpack Compose for its declarative UI, integrating Hilt for efficient dependency injection, and adopting Room for robust local data storage. This significant refactoring establishes a clear repository pattern and leverages Kotlin Flow for reactive data handling, resulting in a more maintainable, scalable, and contemporary Android codebase. Highlights
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.
Code Review
This is a massive and impressive refactoring to a modern Android tech stack, including Jetpack Compose, Hilt, and Room. The new architecture with repositories, DAOs, and a reactive UI state in the ViewModel is much cleaner and more maintainable. I've pointed out a few areas for improvement, mainly around error handling (logging exceptions instead of swallowing them or using printStackTrace), a couple of regressions from the old UI, and one critical compilation error. Great work on this migration!
| ) { permissions -> | ||
| // Handle permissions granted/denied. ViewModel might reload if needed. | ||
| } |
There was a problem hiding this comment.
The permission result handler is currently empty. If a user denies permissions, features like weather and calendar will fail silently without any feedback. You should handle the permissions map to check which permissions were granted or denied and update the UI accordingly, for example, by showing a rationale or a message guiding the user to settings if a permission is permanently denied.
| private val _userName = MutableStateFlow(prefs.getString(AppConstants.KEY_USER_NAME, "User") ?: "User") | ||
|
|
||
| val weather = weatherRepo.weatherData | ||
| val news = newsRepo.getArticles("US") // Default to US or General |
There was a problem hiding this comment.
| dao.insertEvents(events) | ||
| } | ||
| } catch (e: Exception) { | ||
| e.printStackTrace() |
There was a problem hiding this comment.
| @Composable | ||
| fun EventItem(event: CalendarEvent) { | ||
| Row(Modifier.padding(vertical = 8.dp)) { | ||
| val timeFormat = SimpleDateFormat("HH:mm", Locale.getDefault()) |
There was a problem hiding this comment.
Using a hardcoded SimpleDateFormat pattern like "HH:mm" doesn't respect the user's system preference for 12-hour or 24-hour time format. It's better to use a locale-aware formatter. For example, you could get a formatted time string that respects user settings by using android.text.format.DateUtils.formatDateTime(LocalContext.current, event.startTime, DateUtils.FORMAT_SHOW_TIME).
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
No description provided.