Skip to content

Refactor widget prefs 6177951123037805482#119

Closed
harrydbarnes wants to merge 20 commits intomainfrom
refactor-widget-prefs-6177951123037805482
Closed

Refactor widget prefs 6177951123037805482#119
harrydbarnes wants to merge 20 commits intomainfrom
refactor-widget-prefs-6177951123037805482

Conversation

@harrydbarnes
Copy link
Owner

No description provided.

google-labs-jules bot and others added 20 commits January 20, 2026 07:02
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>
- Implemented permission result handling in MainActivity to refresh data or show feedback.
- Replaced hardcoded SimpleDateFormat with DateUtils in CalendarCard to respect user time format preference.
- Added TODO in MainViewModel regarding hardcoded news category.
- Replaced e.printStackTrace() with Log.e() in repositories for better error tracking.
- Added TAG constants to repositories.
- Implemented permission result handling in MainActivity.
- Replaced hardcoded date format with DateUtils in CalendarCard.
- Re-implemented dynamic news category selection in MainViewModel.
- Added isLoading state to MainViewModel.
- Replaced e.printStackTrace() with Log.e() in repositories.
- Updated repositories to return Boolean success/failure status.
- Implemented transactional replaceAll in ArticleDao/NewsRepository to prevent data loss.
- Implemented retry logic in WidgetUpdateWorker based on refresh success.
- Created missing colors.xml to fix build failure.
- Implemented settings navigation in HomeScreen.
- Implemented permission result handling in MainActivity.
- Replaced hardcoded date format with DateUtils in CalendarCard.
- Re-implemented dynamic news category selection in MainViewModel.
- Added isLoading state to MainViewModel.
- Fixed combine function signature in MainViewModel to handle 8 flows.
- Replaced e.printStackTrace() with Log.e() in repositories.
- Updated repositories to return Boolean success/failure status.
- Implemented transactional replaceAll in ArticleDao/NewsRepository to prevent data loss.
- Implemented retry logic in WidgetUpdateWorker based on refresh success.
- Created missing colors.xml to fix build failure.
- Implemented settings navigation in HomeScreen.
…Repository.kt

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>
- Implemented permission result handling in MainActivity.
- Replaced hardcoded date format with DateUtils in CalendarCard.
- Re-implemented dynamic news category selection in MainViewModel.
- Added isLoading state to MainViewModel.
- Fixed combine function signature in MainViewModel to handle 8 flows.
- Replaced e.printStackTrace() with Log.e() in repositories.
- Updated repositories to return Boolean success/failure status.
- Implemented transactional replaceAll in ArticleDao/NewsRepository to prevent data loss.
- Implemented retry logic in WidgetUpdateWorker based on refresh success.
- Created missing colors.xml to fix build failure.
- Implemented settings navigation in HomeScreen.
- Fixed syntax error in CalendarRepository.
- Implemented permission result handling in MainActivity.
- Replaced hardcoded date format with DateUtils in CalendarCard.
- Re-implemented dynamic news category selection in MainViewModel.
- Added isLoading state to MainViewModel.
- Refactored MainViewModel combine logic to use chained calls for type safety.
- Replaced e.printStackTrace() with Log.e() in repositories and DayAheadWidget.
- Updated repositories to return Boolean success/failure status.
- Implemented transactional replaceAll in ArticleDao/NewsRepository.
- Implemented retry logic in WidgetUpdateWorker.
- Created missing colors.xml to fix build failure.
- Implemented settings navigation in HomeScreen.
- Fixed CalendarRepository syntax error and extracted magic number.
- Added @JvmStatic to AppUtils for Java interop.
- Extracted Hilt versions in build.gradle.
- Added null/blank title filtering in NewsRepository.
- Implemented permission result handling in MainActivity.
- Replaced hardcoded date format with DateUtils in CalendarCard.
- Re-implemented dynamic news category selection in MainViewModel.
- Added isLoading state to MainViewModel.
- Refactored MainViewModel combine logic to use chained calls for type safety.
- Replaced e.printStackTrace() with Log.e() in repositories and DayAheadWidget.
- Updated repositories to return Boolean success/failure status.
- Implemented transactional replaceAll in ArticleDao/NewsRepository.
- Implemented retry logic in WidgetUpdateWorker.
- Created missing colors.xml to fix build failure.
- Implemented settings navigation in HomeScreen.
- Fixed CalendarRepository syntax error and extracted magic number.
- Added @JvmStatic to AppUtils for Java interop.
- Extracted Hilt versions in build.gradle.
- Added null/blank title filtering in NewsRepository.
- Implemented location fetching in MainActivity and updated MainViewModel.
- Updated Geocoder usage for API 33+.
- Updated `fetchLocationName` in `MainViewModel` to use `suspendCancellableCoroutine` for the Tiramisu `Geocoder` API, preventing a race condition where the coroutine scope would close before the callback fired.
- Refactored `DayAheadWidget` to inject `WeatherRepository` instead of `WeatherDao` and `Gson`.
- Simplified `DayAheadWidget.onUpdate` to fetch parsed weather data directly from the repository flow, removing data access and parsing logic from the UI component.
- Created `UserPreferencesRepository` to encapsulate SharedPreferences access and expose flows for user preferences.
- Updated `MainViewModel` to inject `UserPreferencesRepository` instead of direct SharedPreferences usage.
- Fixed race condition in `MainViewModel` Geocoder logic by implementing `GeocodeListener`.
- Updated `HomeScreen` to launch `SettingsActivity` on weather card click.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Refactored DayAheadWidget and WidgetUpdateWorker to use UserPreferencesRepository instead of accessing SharedPreferences directly.
This improves architectural consistency and centralizes data access logic.

Changes:
- Updated UserPreferencesRepository to expose summary flow and hasLocation method.
- Updated DayAheadWidget to inject UserPreferencesRepository and collect summary flow.
- Updated WidgetUpdateWorker to inject UserPreferencesRepository and use it for location check, preference retrieval, and summary saving.
Refactored DayAheadWidget and WidgetUpdateWorker to use UserPreferencesRepository instead of accessing SharedPreferences directly.
This improves architectural consistency and centralizes data access logic.

Changes:
- Updated UserPreferencesRepository to expose summary flow and hasLocation method.
- Updated DayAheadWidget to inject UserPreferencesRepository and collect summary flow.
- Updated WidgetUpdateWorker to inject UserPreferencesRepository and use it for location check, preference retrieval, and summary saving.
- Addressed code review feedback: Added try-catch block in MainViewModel.fetchWeather.
@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 significantly refactors the application to modernize its architecture and UI. It introduces Jetpack Compose for the UI layer, Hilt for dependency injection, and Room for data persistence. The existing Java code is converted to Kotlin, leveraging coroutines and flows for asynchronous operations. The changes aim to improve the app's maintainability, scalability, and performance.

Highlights

  • Dependency Updates: Updates dependencies to newer versions, including ViewModel, LiveData, Compose, Hilt, Room, and Coil.
  • Compose Integration: Integrates Jetpack Compose for UI development, including necessary dependencies and build configurations.
  • Hilt Dependency Injection: Adds Hilt for dependency injection, including dependencies, compiler configuration, and Android application setup.
  • Kotlin Conversion: Converts DayAheadWidget.java and MainActivity.java to Kotlin, leveraging coroutines and flows.
  • Room Persistence: Introduces Room for local data persistence, including entities, DAOs, and database setup.
  • Repository Pattern: Implements a repository pattern for data access, including Weather, News, Calendar, FunFact, and UserPreferences.
  • UI Architecture: Refactors the UI architecture to use Jetpack Compose and StateFlow for managing UI state.
  • Widget Updates: Updates the widget to use Hilt and coroutines for asynchronous data loading.
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

The pull request successfully refactors the application to use Kotlin, Jetpack Compose, Hilt for dependency injection, and Room for local data persistence. This is a significant architectural improvement, enhancing maintainability, testability, and leveraging modern Android development practices. The migration of the UI to Compose and the data layer to a repository pattern with Flow is well-executed. The widget update worker has also been refactored to use the new repository pattern and Hilt, which is a great improvement for background task management.

@harrydbarnes harrydbarnes deleted the refactor-widget-prefs-6177951123037805482 branch January 23, 2026 19:16
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