Skip to content

Commit

Permalink
Merge pull request #118 from superwall/develop
Browse files Browse the repository at this point in the history
1.1.7
  • Loading branch information
ianrumac authored Jun 6, 2024
2 parents fef994b + 2582de8 commit 0324ca5
Show file tree
Hide file tree
Showing 308 changed files with 8,768 additions and 8,446 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*.{kt,kts}]
ktlint_code_style = ktlint_official
ij_kotlin_packages_to_use_import_on_demand = disabled
ktlint_standard_enum-entry-name-case = disabled
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_package-name = disabled
ktlint_standard_filename = disabled
ktlint_function_naming_ignore_when_annotated_with=Composable
ktlint_standard_class-naming = disable
ktlint_standard_backing-property-naming = disabled
ktlint_standard_property-naming = disabled
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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

## 1.1.7

### Enhancements

- SW-2805: Exposes a `presentation` property on the `PaywallInfo` object. This contains information about the presentation of the paywall.
- SW-2855: Adds `restore_start`, `restore_complete`, and `restore_fail` events.

### Fixes

- SW-2854: Fixed issue where abandoning the transaction by pressing back would prevent the user from restarting the transaction.


## 1.1.6

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.superwall.superapp

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand All @@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.superwall.superapp", appContext.packageName)
}
}
}
97 changes: 54 additions & 43 deletions app/src/main/java/com/superwall/superapp/ComposeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,19 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.superwall.superapp.ui.theme.MyApplicationTheme
import android.view.View
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.LaunchedEffect
import com.superwall.sdk.paywall.presentation.internal.request.PaywallOverrides
import com.superwall.sdk.paywall.vc.delegate.PaywallViewControllerDelegate
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import com.superwall.sdk.Superwall
import androidx.compose.ui.unit.dp
import com.superwall.sdk.composable.PaywallComposable
import com.superwall.sdk.paywall.presentation.get_paywall.getPaywall
import com.superwall.sdk.paywall.presentation.internal.request.PaywallOverrides
import com.superwall.sdk.paywall.presentation.internal.state.PaywallResult
import com.superwall.sdk.paywall.vc.PaywallViewController
import com.superwall.sdk.paywall.vc.delegate.PaywallViewControllerDelegate
import com.superwall.superapp.ui.theme.MyApplicationTheme

class ComposeActivity : ComponentActivity(), PaywallViewControllerDelegate {
class ComposeActivity :
ComponentActivity(),
PaywallViewControllerDelegate {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Expand All @@ -49,40 +45,42 @@ class ComposeActivity : ComponentActivity(), PaywallViewControllerDelegate {
override fun didFinish(
paywall: PaywallViewController,
result: PaywallResult,
shouldDismiss: Boolean
shouldDismiss: Boolean,
) {
// In the context of a tab bar, there won't be a dismissal.
}
}

@Preview(showBackground = true)
@Composable
fun ComposeActivityContent(@PreviewParameter(PreviewPaywallDelegateProvider::class) delegate: PaywallViewControllerDelegate) {
fun ComposeActivityContent(
@PreviewParameter(PreviewPaywallDelegateProvider::class) delegate: PaywallViewControllerDelegate,
) {
val selectedTabIndex = remember { mutableStateOf(0) }
val examplePaywallOverrides = PaywallOverrides()

MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
color = MaterialTheme.colorScheme.background,
) {
Column {
TabRow(selectedTabIndex = selectedTabIndex.value) {
Tab(
selected = selectedTabIndex.value == 0,
onClick = { selectedTabIndex.value = 0 }
onClick = { selectedTabIndex.value = 0 },
) {
Text(text = "Tab 0", modifier = Modifier.padding(16.dp))
}
Tab(
selected = selectedTabIndex.value == 1,
onClick = { selectedTabIndex.value = 1 }
onClick = { selectedTabIndex.value = 1 },
) {
Text(text = "Tab 1", modifier = Modifier.padding(16.dp))
}
Tab(
selected = selectedTabIndex.value == 2,
onClick = { selectedTabIndex.value = 2 }
onClick = { selectedTabIndex.value = 2 },
) {
Text(text = "Tab 2", modifier = Modifier.padding(16.dp))
}
Expand All @@ -101,22 +99,28 @@ fun ComposeActivityContent(@PreviewParameter(PreviewPaywallDelegateProvider::cla
}

@Composable
fun TabContent0(paywallOverrides: PaywallOverrides?, delegate: PaywallViewControllerDelegate) {
fun TabContent0(
paywallOverrides: PaywallOverrides?,
delegate: PaywallViewControllerDelegate,
) {
PaywallComposable(
event = "no_products",
params = mapOf("key" to "value"),
paywallOverrides = paywallOverrides,
delegate = delegate
delegate = delegate,
)
}

@Composable
fun TabContent1(paywallOverrides: PaywallOverrides?, delegate: PaywallViewControllerDelegate) {
fun TabContent1(
paywallOverrides: PaywallOverrides?,
delegate: PaywallViewControllerDelegate,
) {
PaywallComposable(
event = "no-existing-event",
params = mapOf("key" to "value"),
paywallOverrides = paywallOverrides,
delegate = delegate
delegate = delegate,
)
}

Expand All @@ -126,7 +130,7 @@ fun TabContent2() {
Column(
modifier = Modifier.align(Alignment.Center),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
horizontalAlignment = Alignment.CenterHorizontally,
) {
Greeting("Jetpack Compose")
EventButton()
Expand All @@ -135,39 +139,46 @@ fun TabContent2() {
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
fun Greeting(
name: String,
modifier: Modifier = Modifier,
) {
Text(
text = "Hello $name!",
modifier = modifier
modifier = modifier,
)
}

@Composable
fun EventButton() {
val context = LocalContext.current

Button(onClick = {
val app = context.applicationContext as? MainApplication
app?.invokeRegister("another_paywall")
}, modifier = Modifier
.width(250.dp)
){
Button(
onClick = {
val app = context.applicationContext as? MainApplication
app?.invokeRegister("another_paywall")
},
modifier =
Modifier
.width(250.dp),
) {
Text("Another Paywall")
}
}

// Mock Provider for Preview
class PreviewPaywallDelegateProvider : PreviewParameterProvider<PaywallViewControllerDelegate> {
override val values: Sequence<PaywallViewControllerDelegate> = sequenceOf(
object : PaywallViewControllerDelegate {
// Mock implementation of PaywallViewControllerDelegate
override fun didFinish(
paywall: PaywallViewController,
result: PaywallResult,
shouldDismiss: Boolean
) {
// No implementation required
}
}
)
}
override val values: Sequence<PaywallViewControllerDelegate> =
sequenceOf(
object : PaywallViewControllerDelegate {
// Mock implementation of PaywallViewControllerDelegate
override fun didFinish(
paywall: PaywallViewController,
result: PaywallResult,
shouldDismiss: Boolean,
) {
// No implementation required
}
},
)
}
8 changes: 4 additions & 4 deletions app/src/main/java/com/superwall/superapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.superwall.superapp

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.superwall.sdk.Superwall
import com.superwall.superapp.test.UITestActivity

Expand Down Expand Up @@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity() {
val intent = Intent(this, UITestActivity::class.java)
startActivity(intent)
}

val devicePropertiesTestButton: Button = findViewById(R.id.devicePropertiesTest)
devicePropertiesTestButton.setOnClickListener {
val app = application as? MainApplication
Expand Down Expand Up @@ -112,7 +112,7 @@ class MainActivity : AppCompatActivity() {
Superwall.instance.dispatchMotionEvent(event)
return true
}
*/
*/

//region Deep Links

Expand All @@ -123,4 +123,4 @@ class MainActivity : AppCompatActivity() {
}

//endregion
}
}
15 changes: 9 additions & 6 deletions app/src/main/java/com/superwall/superapp/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import com.superwall.sdk.analytics.superwall.SuperwallEventInfo
import com.superwall.sdk.delegate.SuperwallDelegate
import com.superwall.sdk.paywall.presentation.register

class MainApplication : android.app.Application(), SuperwallDelegate {
class MainApplication :
android.app.Application(),
SuperwallDelegate {
companion object {
const val CONSTANT_API_KEY = "pk_0ff90006c5c2078e1ce832bd2343ba2f806ca510a0a1696a"

Expand Down Expand Up @@ -35,7 +37,7 @@ class MainApplication : android.app.Application(), SuperwallDelegate {
fun configureWithAutomaticInitialization() {
Superwall.configure(
this,
CONSTANT_API_KEY
CONSTANT_API_KEY,
)
Superwall.instance.delegate = this

Expand All @@ -49,7 +51,7 @@ class MainApplication : android.app.Application(), SuperwallDelegate {
Superwall.configure(
this,
CONSTANT_API_KEY,
purchaseController
purchaseController,
)
Superwall.instance.delegate = this

Expand All @@ -61,15 +63,16 @@ class MainApplication : android.app.Application(), SuperwallDelegate {

fun invokeRegister(
event: String = "campaign_trigger",
params: Map<String, Any>? = null
params: Map<String, Any>? = null,
) {
Superwall.instance.register(event, params)
}

override fun handleSuperwallEvent(withInfo: SuperwallEventInfo) {
println("\n!! SuperwallDelegate !! \n" +
println(
"\n!! SuperwallDelegate !! \n" +
"\tEvent name:" + withInfo.event.rawName + "" +
",\n\tParams:" + withInfo.params + "\n"
",\n\tParams:" + withInfo.params + "\n",
)
}
}
Loading

0 comments on commit 0324ca5

Please sign in to comment.