Skip to content

Commit

Permalink
Merge pull request #170 from superwall/develop
Browse files Browse the repository at this point in the history
1.2.5
  • Loading branch information
ianrumac authored Sep 23, 2024
2 parents 84e8474 + 2f8e610 commit 3e7266b
Show file tree
Hide file tree
Showing 118 changed files with 4,278 additions and 2,071 deletions.
35 changes: 26 additions & 9 deletions .github/workflows/build+test+deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,20 @@ jobs:
EXISTS=$(git tag -l | grep -Fxq "${{steps.version.outputs.prop}}" && echo 'true' || echo 'false')
echo "::set-output name=tag-exists::$EXISTS"
- name: Configure GPG Key
run: |
export GPG_TTY=$(tty)
echo $GPG_SIGNING_KEY | base64 --decode | gpg --batch --import --passphrase $GPG_SIGNING_KEY_PASSPHRASE
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_KEY_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}

- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
if [ "${{ steps.check-tag.outputs.tag-exists }}" == "false" ]; then
./gradlew publish -Paws_access_key_id=$AWS_ACCESS_KEY_ID -Paws_secret_access_key=$AWS_SECRET_ACCESS_KEY -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD
./gradlew 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=$GPG_SIGNING_KEY -Pgpg_signing_key_passphrase=$GPG_SIGNING_KEY_PASSPHRASE -Pgpg_signing_key_id=$GPG_SIGNING_KEY_ID
fi
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_KEY_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}
GPG_SIGNING_KEY_ID: ${{ secrets.GPG_SIGNING_KEY_ID }}

- name: Determine prerelease status
id: prerelease
Expand Down Expand Up @@ -120,6 +115,28 @@ jobs:
sudo git push -u origin release/${{steps.version.outputs.prop}}
fi
- name: Run Autodowngrade Task
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
if [ "${{ steps.check-tag.outputs.tag-exists }}" == "false" ]; then
./gradlew downgradeAgpTask
fi
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
if [ "${{ steps.check-tag.outputs.tag-exists }}" == "false" ]; then
./gradlew 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=$GPG_SIGNING_KEY -Pgpg_signing_key_passphrase=$GPG_SIGNING_KEY_PASSPHRASE -Pgpg_signing_key_id=$GPG_SIGNING_KEY_ID
fi
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_KEY_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE }}
GPG_SIGNING_KEY_ID: ${{ secrets.GPG_SIGNING_KEY_ID }}

- name: slack-send
# Only notify on a new tag
if: steps.check-tag.outputs.tag-exists == 'false'
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@

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

## 1.2.5

### Enhancements
- Adds a `Modifier` to `PaywallComposable` to allow for more control
- Adds a `PaywallView.setup(...)` method to allow for easy setup when using `PaywallView` directly
- Adds support for `MODAL` presentation style

### Fixes
- Fixes issue with displaying `PaywallComposable`
- Resolves issue where users would get `UninitializedPropertyAccessException` when calling `Superwall.instance`

## 1.2.4

### Enhancements
- For users who are not able to upgrade their AGP or Gradle versions, we have added a new artifact `superwall-android-agp-7` which keeps compatibility.

### Enhancements

- Fixes issue with decoding custom placements from paywalls.
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/superwall/superapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.superwall.sdk.Superwall
import com.superwall.superapp.test.UITestActivity
import java.lang.ref.WeakReference

class MainActivity : AppCompatActivity() {
val events by lazy {
Expand All @@ -15,6 +16,7 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
(application as MainApplication).activity = WeakReference(this)

// Setup deep linking handling
respondToDeepLinks()
Expand Down
29 changes: 29 additions & 0 deletions app/src/main/java/com/superwall/superapp/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.superwall.superapp

import android.app.Activity
import androidx.appcompat.app.AlertDialog
import com.superwall.sdk.Superwall
import com.superwall.sdk.analytics.superwall.SuperwallEventInfo
import com.superwall.sdk.config.options.PaywallOptions
import com.superwall.sdk.config.options.SuperwallOptions
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 kotlinx.coroutines.flow.MutableSharedFlow
import java.lang.ref.WeakReference

class MainApplication :
android.app.Application(),
Expand All @@ -30,6 +35,8 @@ class MainApplication :
*/
}

var activity: WeakReference<Activity>? = null

override fun onCreate() {
super.onCreate()

Expand Down Expand Up @@ -80,6 +87,28 @@ class MainApplication :
Superwall.instance.register(event, params)
}

override fun handleLog(
level: String,
scope: String,
message: String?,
info: Map<String, Any>?,
error: Throwable?,
) {
val ctx = activity?.get() ?: return
if (level == LogLevel.error.toString() &&
scope == LogScope.productsManager.toString()
) {
AlertDialog
.Builder(ctx)
.apply {
setTitle("Error")
setMessage(message)
setPositiveButton("OK") { dialog, _ -> dialog.dismiss() }
}.show()
}
super.handleLog(level, scope, message, info, error)
}

override fun handleSuperwallEvent(withInfo: SuperwallEventInfo) {
println(
"\n!! SuperwallDelegate !! \n" +
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ plugins {
alias(libs.plugins.serialization) apply false
}
true

buildscript {
apply(from = "./scripts/old-agp-auto-downgrade.gradle.kts")
}
50 changes: 47 additions & 3 deletions example/app/src/main/java/com/superwall/exampleapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -44,21 +46,60 @@ import androidx.compose.ui.unit.sp
import androidx.core.view.WindowCompat
import com.superwall.exampleapp.ui.theme.SuperwallExampleAppTheme
import com.superwall.sdk.Superwall
import com.superwall.sdk.delegate.SuperwallDelegate
import com.superwall.sdk.identity.identify
import com.superwall.sdk.identity.setUserAttributes
import com.superwall.sdk.logger.LogLevel
import com.superwall.sdk.logger.LogScope

class MainActivity : ComponentActivity() {
class MainActivity :
ComponentActivity(),
SuperwallDelegate {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Superwall.configure(
applicationContext = this,
applicationContext = application,
apiKey = "pk_3b18882b1683318b710c741f371f40f54e357c6f0baff1f4",
)

WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
SuperwallExampleAppTheme {
var errorMessage =
remember {
mutableStateOf<String?>(null)
}
Superwall.instance.delegate =
object : SuperwallDelegate {
override fun handleLog(
level: String,
scope: String,
message: String?,
info: Map<String, Any>?,
error: Throwable?,
) {
if (level == LogLevel.error.toString() &&
scope == LogScope.productsManager.toString()
) {
errorMessage.value = message
}
super.handleLog(level, scope, message, info, error)
}
}
if (errorMessage.value != null) {
AlertDialog(
onDismissRequest = { errorMessage.value = null },
title = { Text("Error") },
text = { Text(errorMessage.value ?: "") },
confirmButton = {
TextButton(onClick = { errorMessage.value = null }) {
Text("OK")
}
},
)
}

WelcomeScreen()
}
}
Expand All @@ -84,7 +125,10 @@ fun WelcomeScreen() {
.padding(bottom = 20.dp),
contentAlignment = Alignment.Center,
) {
Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(16.dp)) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(16.dp),
) {
Spacer(modifier = Modifier.weight(1f))

Text(
Expand Down
Loading

0 comments on commit 3e7266b

Please sign in to comment.