Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Paywalls V2] Makes TextComponent public #1939

Merged
merged 105 commits into from
Nov 26, 2024
Merged

Conversation

JayShortway
Copy link
Member

Public

This makes the TextComponent type, and all types it references, public. This allows us to use these types from revenuecatui. Note that they are still marked as @InternalRevenueCatAPI, so using them requires explicit opt-in. I still kept constructors internal for now. Will open things up more as we need it.

Data classes

We decided a while back that we don't want to use data classes in our public API, because they increase the API surface substantially (with copy() and componentN() functions), and are hard to evolve in a binary-compatible way.

However, having property-based equals() and hashCode() (and toString()) functions is still highly desirable. While these can be generated in Android Studio (CMD + N), the extra boilerplate adds substantial cognitive load when reading.

For this reason, this PR adds a compiler plugin called Poko, which generates these functions for us. It seems to be well maintained. This gives us the benefits of these functions, without the drawbacks of boilerplate. Let me know what you think.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 81.89%. Comparing base (a5375dc) to head (1f697fd).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...chases/paywalls/components/properties/ColorInfo.kt 16.66% 0 Missing and 5 partials ⚠️
...t/purchases/paywalls/components/properties/Size.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1939   +/-   ##
=======================================
  Coverage   81.89%   81.89%           
=======================================
  Files         260      260           
  Lines        8449     8449           
  Branches     1226     1226           
=======================================
  Hits         6919     6919           
  Misses       1032     1032           
  Partials      498      498           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

val default = Padding(10.0, 10.0, 20.0, 20.0)
internal companion object {
internal val zero = Padding(0.0, 0.0, 0.0, 0.0)
internal val default = Padding(10.0, 10.0, 20.0, 20.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

do these need the internal as well? I think it will be implicit

Copy link
Member Author

Choose a reason for hiding this comment

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

You used to be able to still call members of a non-public companion object from Java, but I think that had to do with private companion objects and not internal ones.

However, marking the fields as internal is not sufficient either to hide it from Java completely, as internal things become public, albeit with mangled names. (This became getDefault$purchases_defaultsRelease().)

I experimented some more and went with your earlier suggestion of using @JvmSynthetic (94003a4). This achieves the goal of hiding these fields from Java completely. Thanks for making me double check this!

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

This looks good to me 🤷‍♂️

Base automatically changed from pw2-internal-api to main November 26, 2024 10:41
# Conflicts:
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/PartialComponent.kt
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/TextComponent.kt
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/common/ComponentOverrides.kt
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/common/Localization.kt
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/properties/ColorInfo.kt
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/properties/Padding.kt
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/properties/Size.kt
@JayShortway JayShortway enabled auto-merge (squash) November 26, 2024 10:51
@JayShortway JayShortway merged commit ba75c52 into main Nov 26, 2024
10 checks passed
@JayShortway JayShortway deleted the pw2-public-textcomponent branch November 26, 2024 11:15
This was referenced Nov 28, 2024
JayShortway pushed a commit that referenced this pull request Dec 2, 2024
**This is an automatic release.**

## RevenueCat SDK
### 🐞 Bugfixes
* Uses `Sequence` instead of `Stream` to avoid errors due to unavailable
Java 8 APIs (#1943) via JayShortway (@JayShortway)

### 🔄 Other Changes
* Increase integration test timeout (#1946) via Toni Rico (@tonidero)
* Removes `@RequiresApi(N)` from `FileHelper` and related classes
(#1944) via JayShortway (@JayShortway)
* [Paywalls V2] Minimizes Java API (#1942) via JayShortway
(@JayShortway)
* [Paywalls V2] Makes `TextComponent` public (#1939) via JayShortway
(@JayShortway)
* Introduces an `@InternalRevenueCatAPI` annotation (#1938) via
JayShortway (@JayShortway)
* [Paywalls V2] Moves any non-component file to a new `common` package.
(#1937) via JayShortway (@JayShortway)
* [Paywalls V2] `LocalizationKey` is an inline value class now. (#1936)
via JayShortway (@JayShortway)
* [Paywalls V2] Adds `PaywallComponentsData` (#1935) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `StickyFooterComponent` (#1934) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `PurchaseButtonComponent` (#1933) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `PackageComponent` (#1932) via JayShortway
(@JayShortway)
* Ensure the correct error message is shown when failing to open a Uri
in paywalls (#1922) via JayShortway (@JayShortway)
* [Paywalls V2] Adds `ButtonComponent` (#1931) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `StackComponent` (#1930) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `ComponentOverrides` (#1929) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `ImageComponent` (#1928) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `TextComponent` (#1927) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds all enum properties (#1926) via JayShortway
(@JayShortway)
* [Paywalls V2] Adds `SizeConstraints`, `Size`, `Padding` and `Shadow`
properties (#1925) via JayShortway (@JayShortway)
* [Paywalls V2] Adds `CornerRadiuses`, `Shape` and `MaskShape`
properties (#1924) via JayShortway (@JayShortway)
* [Paywalls V2] Adds `ImageUrls` and `ColorInfo` properties (#1923) via
JayShortway (@JayShortway)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants