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

2.0.0-alpha #220

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3a23f9d
Extract compose, add consumer proguard rules
ianrumac Sep 6, 2024
26a25f1
Add compose to deploy script
ianrumac Sep 16, 2024
d5f5ea3
Downgrade minSDK to version 22
ianrumac Sep 19, 2024
44c05c7
Add purchase and basic restore method
ianrumac Oct 14, 2024
000fd4e
Extract interfaces properly for transaction code, add tests
ianrumac Oct 24, 2024
84d7cfc
Update tests
ianrumac Oct 24, 2024
b76e56a
Wrap purchase methods into Result
ianrumac Oct 24, 2024
32c1fd0
Clear up after rebase, fix transaction tracking and add source to event
ianrumac Nov 11, 2024
6b0dc6b
Downgrade minSDK to version 22
ianrumac Sep 19, 2024
321f21d
Clear up after rebase, fix transaction tracking and add source to event
ianrumac Nov 11, 2024
d6bf054
Add observer mode to the purchases
ianrumac Nov 11, 2024
2464724
Fix base64 handling
ianrumac Nov 16, 2024
38961f5
Update superscript version
ianrumac Dec 12, 2024
c504ef7
Remove deprecated naming and cleanup the code
ianrumac Dec 12, 2024
b260e8a
Minor fixes
ianrumac Dec 13, 2024
11ad604
Fix UI tests and build issues after rebase
ianrumac Dec 13, 2024
d0ad909
Censor error-tracking
ianrumac Dec 13, 2024
94dca95
Downgrade minSDK to version 22
ianrumac Sep 19, 2024
84f98e7
Clear up after rebase, fix transaction tracking and add source to event
ianrumac Nov 11, 2024
b1266c3
Migrate to entitlements from subscriptions
ianrumac Nov 25, 2024
84363d0
Improve tests, fix issues with not observing when PC is not defined
ianrumac Nov 29, 2024
ef27d75
Fix tests for entitlements, fix CEL ignoring evaluation
ianrumac Dec 2, 2024
185d704
Update how billing flow and observations work, minor entitlement refa…
ianrumac Dec 9, 2024
5edcaf0
Fix entitlement bugs, update testing suite, cleanup some code
ianrumac Dec 12, 2024
31268fd
Add sync version of methods, update KDoc and hide internals
ianrumac Sep 30, 2024
c3c05e6
Change active entitlements to list
ianrumac Dec 13, 2024
ec927e7
Fix issues after rebase, update notifications to include subtitle
ianrumac Dec 16, 2024
0d70825
Bump version
ianrumac Dec 16, 2024
0b5015f
Remove JS evaluator
ianrumac Dec 16, 2024
3ccfb2c
Fix issue with RuleEvaluator name change
ianrumac Dec 16, 2024
a1149b8
Move back to release
ianrumac Dec 16, 2024
9817ffd
Add purchase token & fix minor issues with entitlements
ianrumac Dec 18, 2024
eb61672
Add activeProducts to device template
ianrumac Dec 18, 2024
163655b
Minor fixes to observer mode billing listening, adds to DeviceTemplate
ianrumac Dec 18, 2024
38f0c00
Improve documentation on entitlements, purchase and observer
ianrumac Dec 18, 2024
f5f7a20
Add activeEntitlementsObject to device template
ianrumac Dec 18, 2024
b55354e
Merge pull request #219 from superwall/ir/fix/minor-fixes
ianrumac Dec 18, 2024
bb5a9bd
Fix testing utils
ianrumac Dec 18, 2024
707fff0
Merge pull request #167 from superwall/alpha-2.0
ianrumac Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/build+test+deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ jobs:
GPG_SIGNING_KEY_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}
GPG_SIGNING_KEY_ID: ${{ secrets.GPG_SIGNING_KEY_ID }}
run: |
./gradlew publish \
./gradlew :superwall:publish \
-Paws_access_key_id=$AWS_ACCESS_KEY_ID \
-Paws_secret_access_key=$AWS_SECRET_ACCESS_KEY \
-PsonatypeUsername=$SONATYPE_USERNAME \
-PsonatypePassword=$SONATYPE_PASSWORD \
-Pgpg_signing_key_passphrase=$GPG_SIGNING_KEY_PASSPHRASE \
-Pgpg_signing_key_id=$GPG_SIGNING_KEY_ID

./gradlew :superwall-compose:publish \
-Paws_access_key_id=$AWS_ACCESS_KEY_ID \
-Paws_secret_access_key=$AWS_SECRET_ACCESS_KEY \
-PsonatypeUsername=$SONATYPE_USERNAME \
Expand Down Expand Up @@ -143,7 +151,7 @@ jobs:
GPG_SIGNING_KEY_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}
GPG_SIGNING_KEY_ID: ${{ secrets.GPG_SIGNING_KEY_ID }}
run: |
./gradlew publish \
./gradlew :superwall:publish \
-Paws_access_key_id=$AWS_ACCESS_KEY_ID \
-Paws_secret_access_key=$AWS_SECRET_ACCESS_KEY \
-PsonatypeUsername=$SONATYPE_USERNAME \
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub.

## 2.0.0-Alpha

- Removes `PaywallComposable` and Jetpack Compose support from main SDK
- Adds `Superwall-Compose` module for Jetpack Compose support:
- You can find it at `com.superwall.sdk:superwall-compose:2.0.0-alpha`
- Adds consumer proguard rules to enable consumer minification
- Removed methods previously marked as Deprecated

## 1.5.0

### Enhancements
Expand All @@ -14,8 +22,7 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superw

### Fixes

- Fixes concurrency issues with subscriptions triggered in Cordova apps

- Fixes concurrency issues with subscriptions triggered in Cordova apps
## 1.5.0-beta.2

## Enhancements
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The preferred installation method is with [Gradle](https://superwall.com/docs/in

<!-- (2) Add these lines -->
<activity
android:name="com.superwall.sdk.paywall.vc.SuperwallPaywallActivity"
android:name="com.superwall.sdk.paywall.view.SuperwallPaywallActivity"
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {

defaultConfig {
applicationId = "com.superwall.superapp"
minSdk = 26
minSdk = 22
targetSdk = 34
versionCode = 2
versionName = "1.0.0"
Expand Down Expand Up @@ -80,6 +80,7 @@ dependencies {

// Superwall
implementation(project(":superwall"))
implementation(project(":superwall-compose"))

// Test
testImplementation(libs.junit)
Expand Down
21 changes: 0 additions & 21 deletions app/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("ktlint:standard:no-empty-file")

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.FlakyTest
import com.dropbox.dropshots.Dropshots
import com.dropbox.dropshots.ThresholdValidator
import com.example.superapp.utils.CustomComparator
Expand Down Expand Up @@ -32,7 +33,7 @@ class FlowScreenshotTestExecutor {

val mainScope = CoroutineScope(Dispatchers.Main)

/*@Test
@Test
@FlakyTest
fun test_paywall_reappers_with_video() =
with(dropshots) {
Expand All @@ -44,12 +45,13 @@ class FlowScreenshotTestExecutor {
delayFor(500.milliseconds)
}
step("second_paywall") {
it.waitFor { it is SuperwallEvent.PaywallOpen }
awaitUntilWebviewAppears()
delayFor(1.seconds)
}
}
}
*/

@Test
fun test_paywall_presents_regardless_of_subscription() =
with(dropshots) {
Expand All @@ -65,7 +67,7 @@ class FlowScreenshotTestExecutor {
Superwall.instance.paywallView
?.webView
?.scrollBy(0, 300) ?: kotlin.run {
throw IllegalStateException("No viewcontroller found")
throw IllegalStateException("No view found")
}
}.await()
// We delay a bit to ensure the button is visible
Expand All @@ -76,7 +78,7 @@ class FlowScreenshotTestExecutor {
Superwall.instance.paywallView
?.webView
?.scrollTo(0, 0) ?: kotlin.run {
throw IllegalStateException("No viewcontroller found")
throw IllegalStateException("No view found")
}
}.await()
// We delay a bit to ensure scroll has finished
Expand Down Expand Up @@ -123,16 +125,21 @@ class FlowScreenshotTestExecutor {
}
}
}
}

/*

Commented out due to inability to re-record tests until Firebase Android Studio plugin is fixed

@Test
fun test_paywall_presents_then_dismisses_without_reappearing() =
with(dropshots) {
screenshotFlow(UITestHandler.test14Info) {
step {
it.waitFor { it is SuperwallEvent.PaywallWebviewLoadComplete }
it.waitFor { it is SuperwallEvent.ShimmerViewComplete }
awaitUntilShimmerDisappears()
awaitUntilWebviewAppears()
delayFor(100.milliseconds)
delayFor(300.milliseconds)
mainScope
.async {
// We scroll a bit to display the button
Expand All @@ -146,7 +153,7 @@ class FlowScreenshotTestExecutor {
}
}.await()
// We delay a bit to ensure the button is visible
delayFor(100.milliseconds)
delayFor(300.milliseconds)
// We scroll back to the top
mainScope
.async {
Expand All @@ -159,10 +166,7 @@ class FlowScreenshotTestExecutor {
// We delay a bit to ensure scroll has finished
delayFor(500.milliseconds)
}

step {
delayFor(10.seconds)
}
}
}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PresentationRuleTests {
with(dropshots) {
screenshotFlow(UITestHandler.test32Info) {
step("") {
it.waitFor { it is SuperwallEvent.SubscriptionStatusDidChange }
it.waitFor { it is SuperwallEvent.EntitlementStatusDidChange }
delayFor(1.seconds)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.example.superapp.utils.screenshotFlow
import com.example.superapp.utils.waitFor
import com.superwall.sdk.Superwall
import com.superwall.sdk.analytics.superwall.SuperwallEvent
import com.superwall.sdk.delegate.SubscriptionStatus
import com.superwall.superapp.test.UITestHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -144,19 +143,21 @@ class SimpleScreenshotTestExecutor {
it.waitFor { it is SuperwallEvent.PaywallPresentationRequest }
}
}
Superwall.instance.setSubscriptionStatus(SubscriptionStatus.INACTIVE)
}

@Test
fun test_paywall_doesnt_present_without_showing_alert_after_dismiss() =
with(dropshots) {
screenshotFlow(UITestHandler.test26Info) {
step("") {
it.waitFor { it is SuperwallEvent.PaywallPresentationRequest }
awaitUntilDialogAppears()
}
}
}
/*
* Commented out temporarily since Firebase remote lab connection is broken and recording tests is not possible
* @Test
* fun test_paywall_presents_without_showing_alert_after_dismiss() =
* with(dropshots) {
* screenshotFlow(UITestHandler.test26Info) {
* step("") {
* it.waitFor { it is SuperwallEvent.PaywallPresentationRequest }
* awaitUntilDialogAppears()
* }
* }
* }
* */

@Test
fun test_paywall_doesnt_present_calls_feature_block() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import androidx.test.uiautomator.Until
import com.dropbox.dropshots.Dropshots
import com.superwall.sdk.Superwall
import com.superwall.sdk.analytics.superwall.SuperwallEvent
import com.superwall.sdk.paywall.vc.ShimmerView
import com.superwall.sdk.config.models.ConfigurationStatus
import com.superwall.sdk.paywall.view.ShimmerView
import com.superwall.superapp.MainActivity
import com.superwall.superapp.test.UITestInfo
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -112,6 +113,7 @@ fun Dropshots.screenshotFlow(
}

runTest(timeout = 5.minutes) {
Superwall.instance.configurationStateListener.first { it is ConfigurationStatus.Configured }
try {
flow.steps.forEach {
if (!testReady.value) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</intent-filter>
</activity>
<activity
android:name="com.superwall.sdk.paywall.vc.SuperwallPaywallActivity"
android:name="com.superwall.sdk.paywall.view.SuperwallPaywallActivity"
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/superwall/superapp/ComposeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import com.superwall.sdk.composable.PaywallComposable
import com.superwall.sdk.compose.PaywallComposable
import com.superwall.sdk.paywall.presentation.internal.request.PaywallOverrides
import com.superwall.sdk.paywall.presentation.internal.state.PaywallResult
import com.superwall.sdk.paywall.vc.PaywallView
import com.superwall.sdk.paywall.vc.delegate.PaywallViewCallback
import com.superwall.sdk.paywall.view.PaywallView
import com.superwall.sdk.paywall.view.delegate.PaywallViewCallback
import com.superwall.superapp.ui.theme.MyApplicationTheme

class ComposeActivity :
Expand Down
22 changes: 21 additions & 1 deletion app/src/main/java/com/superwall/superapp/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.superwall.sdk.delegate.SuperwallDelegate
import com.superwall.sdk.logger.LogLevel
import com.superwall.sdk.logger.LogScope
import com.superwall.sdk.paywall.presentation.register
import com.superwall.superapp.purchase.RevenueCatPurchaseController
import kotlinx.coroutines.flow.MutableSharedFlow
import java.lang.ref.WeakReference

Expand Down Expand Up @@ -62,7 +63,7 @@ class MainApplication :
.build(),
)

configureWithAutomaticInitialization()
configureWithObserverMode()
// configureWithRevenueCatInitialization()
}

Expand All @@ -86,6 +87,25 @@ class MainApplication :
// Superwall.instance.options.isGameControllerEnabled = true
}

fun configureWithObserverMode() {
Superwall.configure(
this@MainApplication,
CONSTANT_API_KEY,
options =
SuperwallOptions().apply {
shouldObservePurchases = true
paywalls =
PaywallOptions().apply {
shouldPreload = false
}
},
)
Superwall.instance.delegate = this@MainApplication

// Make sure we enable the game controller
// Superwall.instance.options.isGameControllerEnabled = true
}

fun configureWithRevenueCatInitialization() {
val purchaseController = RevenueCatPurchaseController(this)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.superwall.superapp
package com.superwall.superapp.purchase

import android.app.Activity
import android.content.Context
Expand All @@ -24,8 +24,9 @@ import com.revenuecat.purchases.purchaseWith
import com.superwall.sdk.Superwall
import com.superwall.sdk.delegate.PurchaseResult
import com.superwall.sdk.delegate.RestorationResult
import com.superwall.sdk.delegate.SubscriptionStatus
import com.superwall.sdk.delegate.subscription_controller.PurchaseController
import com.superwall.sdk.models.entitlements.Entitlement
import com.superwall.sdk.models.entitlements.EntitlementStatus
import kotlinx.coroutines.CompletableDeferred

// Extension function to convert callback to suspend function
Expand Down Expand Up @@ -126,9 +127,16 @@ class RevenueCatPurchaseController(
// Refetch the customer info on load
Purchases.sharedInstance.getCustomerInfoWith {
if (hasAnyActiveEntitlements(it)) {
setSubscriptionStatus(SubscriptionStatus.ACTIVE)
setEntitlementStatus(
EntitlementStatus.Active(
it.entitlements.active
.map {
Entitlement(it.key, Entitlement.Type.SERVICE_LEVEL)
}.toSet(),
),
)
} else {
setSubscriptionStatus(SubscriptionStatus.INACTIVE)
setEntitlementStatus(EntitlementStatus.Inactive)
}
}
}
Expand All @@ -138,9 +146,16 @@ class RevenueCatPurchaseController(
*/
override fun onReceived(customerInfo: CustomerInfo) {
if (hasAnyActiveEntitlements(customerInfo)) {
setSubscriptionStatus(SubscriptionStatus.ACTIVE)
setEntitlementStatus(
EntitlementStatus.Active(
customerInfo.entitlements.active
.map {
Entitlement(it.key, Entitlement.Type.SERVICE_LEVEL)
}.toSet(),
),
)
} else {
setSubscriptionStatus(SubscriptionStatus.INACTIVE)
setEntitlementStatus(EntitlementStatus.Inactive)
}
}

Expand Down Expand Up @@ -275,9 +290,9 @@ class RevenueCatPurchaseController(
return entitlements.isNotEmpty()
}

private fun setSubscriptionStatus(subscriptionStatus: SubscriptionStatus) {
private fun setEntitlementStatus(entitlementStatus: EntitlementStatus) {
if (Superwall.initialized) {
Superwall.instance.setSubscriptionStatus(subscriptionStatus)
Superwall.instance.setEntitlementStatus(entitlementStatus)
}
}
}
Loading
Loading