feat!: Switched to using Kotlin extensions for EdgeToEdge and pref he… - #281
Conversation
…lpers Legacy Java will call EdgeToEdgeHelperKt and PrefHelperKt respectively. This is a breaking change as it is moved to the context of the primary objects (context, views etc)
There was a problem hiding this comment.
Summary of Changes
Hello @itachi1706, 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 refactors the EdgeToEdgeHelper and PrefHelper classes by converting their static utility methods into Kotlin extension functions. This change aims to provide a more idiomatic and fluent API for Kotlin consumers, allowing functions to be called directly on the Window, View, Context, and AppCompatActivity objects. This is a breaking change as the call signatures for these helper functions have been altered, though legacy Java code can still access them via generated *Kt classes.
Highlights
- Refactored Edge-to-Edge Utilities: The
EdgeToEdgeHelperfunctions for managing system bar insets and setting content views are now Kotlin extension functions onWindow,View, andAppCompatActivity, improving their discoverability and usage within Kotlin code. - Modernized Preference Helpers: The
PrefHelpermethods for accessingSharedPreferencesand checking night mode status have been transformed into extension functions on theContextobject, streamlining preference management and making them more idiomatic. - Breaking API Change: The conversion from static methods to extension functions introduces a breaking change, requiring consumers to update their call sites to use the new extension function syntax (e.g.,
window.disableWindowSystemWindows()instead ofEdgeToEdgeHelper.disableWindowSystemWindows(window)). - Enhanced Kotlin Idiomaticity: The adoption of extension functions aligns the helper library more closely with Kotlin's idiomatic programming patterns, offering a cleaner and more expressive API for developers.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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
-
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. ↩
There was a problem hiding this comment.
Pull Request Overview
This PR refactors helper functions from static object methods to Kotlin extension functions, providing a more idiomatic Kotlin API while maintaining backward compatibility through generated Java interop methods.
- Converts static methods in
PrefHelperandEdgeToEdgeHelperobjects to extension functions on relevant receiver types - Updates documentation to use
@receiverannotations instead of parameter descriptions - Maintains backward compatibility by keeping object declarations and using
@file:Suppress("unused")
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| PrefHelper.kt | Converts preference helper methods to Context extension functions |
| EdgeToEdgeHelper.kt | Converts edge-to-edge layout methods to Window, View, and AppCompatActivity extension functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request refactors EdgeToEdgeHelper and PrefHelper to use Kotlin extension functions, which is a great improvement for code clarity and idiomatic Kotlin usage. The changes in EdgeToEdgeHelper look solid. However, in PrefHelper, the new thread-safe preference getters have a potential issue where the StrictMode policy might not be restored if an exception occurs. I've added comments with suggestions to fix this using try-finally blocks.
Fallback Java to PendingIntentDepKt
|



…lpers
Legacy Java will call EdgeToEdgeHelperKt and PrefHelperKt respectively.
This is a breaking change as it is moved to the context of the primary objects (context, views etc)