Skip to content

Refactor to Jetpack Compose, Hilt, and Room#109

Closed
harrydbarnes wants to merge 7 commits intomainfrom
refactor-compose-hilt-room-8391020351450474788
Closed

Refactor to Jetpack Compose, Hilt, and Room#109
harrydbarnes wants to merge 7 commits intomainfrom
refactor-compose-hilt-room-8391020351450474788

Conversation

@harrydbarnes
Copy link
Owner

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Jetpack Compose Migration: The entire user interface has been rewritten from traditional Android Views (XML layouts, RecyclerView adapters) to Jetpack Compose, providing a modern, declarative UI.
  • Hilt Dependency Injection: Hilt has been integrated across the application for robust dependency injection, simplifying object creation and management, and improving testability.
  • Room Persistence Library: Room has been implemented for local data persistence, replacing direct SharedPreferences usage for structured data like weather, news, and calendar events.
  • Architectural Refactoring: The application now follows a modern MVVM-like architecture, utilizing a repository pattern for data abstraction and Kotlin Flow for reactive data streams, enhancing maintainability and scalability.
  • Kotlin Language Migration: All existing Java code, including core activities, adapters, and data models, has been converted to Kotlin, aligning with modern Android development practices.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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!

Comment on lines +17 to +19
) { permissions ->
// Handle permissions granted/denied. ViewModel might reload if needed.
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The news category is hardcoded to "US". The previous version of the app allowed users to select different categories via chips. This appears to be a feature regression. If category selection is planned for a future update, it would be good to add a TODO comment here to track it.

dao.insertEvents(events)
}
} catch (e: Exception) {
e.printStackTrace()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Calling e.printStackTrace() is not ideal for production code. Please use a proper logging framework like Android's Log.e(TAG, message, e) to ensure errors are captured and analyzable. This recommendation applies to the other repositories where this pattern is also used.

@Composable
fun EventItem(event: CalendarEvent) {
Row(Modifier.padding(vertical = 8.dp)) {
val timeFormat = SimpleDateFormat("HH:mm", Locale.getDefault())
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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).

harrydbarnes and others added 6 commits January 20, 2026 23:07
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>
@harrydbarnes harrydbarnes deleted the refactor-compose-hilt-room-8391020351450474788 branch January 20, 2026 23:40
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.

1 participant