Skip to content

Feature/java projects support - #38

Open
ItsBruno wants to merge 3 commits into
mainfrom
feature/java-projects-support
Open

Feature/java projects support#38
ItsBruno wants to merge 3 commits into
mainfrom
feature/java-projects-support

Conversation

@ItsBruno

Copy link
Copy Markdown
Contributor

Summary

This PR adds convenience methods which should make the usage of this library easier in Java projects on the Android and Jvm platforms. It also adjusts requirements not satisfied exception handling in the jvm sample app.

Related issue:

Changes

  • Added extension functions for java convenience usage to the Android and Jvm platform modules
  • Created updater callback interfaces for use in java projects in both platform modules. The interfaces are completely the same and there is code duplication, but this made a bit more sense then adding it only in common main, as iOS has no need for Java support.
  • Created a JavaLoader interface which does not contain suspend functions. It is then internaly wrapped by the kotlin loader which uses suspend functions. This way it can be integrated with the rest of the library logic which uses coroutines.
  • Added java demonstrations to the android and jvm sample apps.

Type

  • Feature: This pull request introduces a new feature.
  • Bug fix: This pull request fixes a bug.
  • Refactor: This pull request refactors existing code.
  • Documentation: This pull request updates documentation.
  • Other: This pull request makes other changes.

Additional information

  • This pull request introduces a breaking change.

Checklist

  • I have performed a self-review of my own code.
  • I have tested my changes, including edge cases.
  • I have added necessary tests for the changes introduced (if applicable).
  • I have updated the documentation to reflect my changes (if applicable).

Additional notes

Note One more point of friction remains for java projects, and that is the storage interface which declares suspend functions. This simply means that java projects will have a bit more of an issue if they decide to implement custom storage solutions. Given that covering this means even more code duplication, and the use case appears to be rare, I decided that we currently don't need to cover this but I'm open to feedback.

Note Due to the fact that Kotlin typealiases don't work in Java (this was an oversight), the base interfaces with generics have to be used. This is a bit less convenient but does not seem like a major issue.

@ItsBruno ItsBruno self-assigned this Jan 14, 2026
@ItsBruno ItsBruno added the enhancement New feature or request label Jan 14, 2026

Copilot AI 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.

Pull request overview

This PR adds Java interoperability support for the Prince of Versions library on Android and JVM platforms. It introduces callback-based APIs and non-suspend interfaces to make the library more accessible to Java developers while maintaining the existing Kotlin-based architecture.

Changes:

  • Added Java-friendly extension functions and callback interfaces for Android and JVM platforms
  • Created JavaLoader interface and UpdaterCallback as alternatives to suspend-based APIs
  • Added Java usage examples to both Android and JVM sample applications

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
princeofversions/src/androidMain/kotlin/com/infinum/princeofversions/java/JavaLoader.kt Defines JavaLoader interface for Android platform
princeofversions/src/androidMain/kotlin/com/infinum/princeofversions/java/PrinceOfVersions.kt Android-specific extension functions for Java interop
princeofversions/src/androidMain/kotlin/com/infinum/princeofversions/java/UpdaterCallback.kt Callback interface for Android platform
princeofversions/src/jvmMain/kotlin/com/infinum/princeofversions/java/JavaLoader.kt Defines JavaLoader interface for JVM platform
princeofversions/src/jvmMain/kotlin/com/infinum/princeofversions/java/PrinceOfVersions.kt JVM-specific extension functions for Java interop
princeofversions/src/jvmMain/kotlin/com/infinum/princeofversions/java/UpdaterCallback.kt Callback interface for JVM platform
princeofversions/src/commonMain/kotlin/com/infinum/princeofversions/BasePrinceOfVersionsCall.kt Removed unused interface
princeofversions/src/commonMain/kotlin/com/infinum/princeofversions/Cancelable.kt Removed unused interface
princeofversions/src/commonMain/kotlin/com/infinum/princeofversions/UpdateCallback.kt Removed unused interface
sampleApp/src/main/java/com/infinum/princeofversions/sample/JavaUsageExample.java Android Java usage example implementation
sampleApp/src/androidMain/kotlin/com/infinum/princeofversions/sample/ComposeJavaBridge.kt Bridge to set up Compose content from Java on Android
sampleApp/src/androidMain/kotlin/com/infinum/princeofversions/sample/MainActivity.kt Added navigation to Java usage example
sampleApp/src/androidMain/AndroidManifest.xml Registered JavaUsageExample activity
sampleApp/src/desktopMain/java/com/infinum/princeofversions/sample/JavaUsageExample.java JVM Java usage example implementation
sampleApp/src/desktopMain/kotlin/com/infinum/princeofversions/sample/ComposeJavaBridge.kt Bridge to set up Compose content from Java on JVM
sampleApp/src/desktopMain/kotlin/com/infinum/princeofversions/sample/main.kt Added navigation and exception handling improvements
sampleApp/src/commonMain/kotlin/com/infinum/princeofversions/sample/App.kt Added Java usage button to main menu
Comments suppressed due to low confidence (2)

princeofversions/src/androidMain/kotlin/com/infinum/princeofversions/java/JavaLoader.kt:1

  • The documentation states 'This class' but JavaLoader is an interface, not a class. Change 'This class' to 'This interface'.
    princeofversions/src/androidMain/kotlin/com/infinum/princeofversions/java/UpdaterCallback.kt:1
  • The documentation comment is misleading. The onSuccess method is called when the update check completes successfully, regardless of whether an update is available. The actual update status is determined by checking result.status. Update the documentation to accurately reflect this behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KCeh KCeh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess solution in this PR is fine.
I don't know how much we really need Java support in Android 🤷

Only note from my side:
Current code organisation is acceptable since Java support is not "heavy"
In case we need to do more for Java support (eg, introduce new dependencies, different APIs), then I think it would be better to extract support to separate module/artefact. But for now it is ok 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants