Skip to content

feat!: Switched to using Kotlin extensions for EdgeToEdge and pref he… - #281

Merged
itachi1706 merged 2 commits into
masterfrom
280-add-support-for-extension-functions-in-kotlin-for-helper-classes
Aug 25, 2025
Merged

itachi1706 merged 2 commits into
masterfrom
280-add-support-for-extension-functions-in-kotlin-for-helper-classes

Conversation

@itachi1706

Copy link
Copy Markdown
Owner

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

…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)
@itachi1706
itachi1706 requested a review from Copilot August 25, 2025 10:35
@itachi1706 itachi1706 self-assigned this Aug 25, 2025
@itachi1706 itachi1706 linked an issue Aug 25, 2025 that may be closed by this pull request

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 EdgeToEdgeHelper functions for managing system bar insets and setting content views are now Kotlin extension functions on Window, View, and AppCompatActivity, improving their discoverability and usage within Kotlin code.
  • Modernized Preference Helpers: The PrefHelper methods for accessing SharedPreferences and checking night mode status have been transformed into extension functions on the Context object, 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 of EdgeToEdgeHelper.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

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 PrefHelper and EdgeToEdgeHelper objects to extension functions on relevant receiver types
  • Updates documentation to use @receiver annotations 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.

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

Copy link
Copy Markdown
Contributor

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 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
@itachi1706
itachi1706 enabled auto-merge August 25, 2025 10:41
@sonarqubecloud

Copy link
Copy Markdown

@itachi1706
itachi1706 merged commit 3aedf87 into master Aug 25, 2025
8 checks passed
@itachi1706
itachi1706 deleted the 280-add-support-for-extension-functions-in-kotlin-for-helper-classes branch August 25, 2025 10:44
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.

Add support for Extension functions in Kotlin for Helper classes

2 participants