Skip to content

Commit

Permalink
version 2.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-g committed Jun 4, 2024
1 parent 001f601 commit fe306f9
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 12 deletions.
2 changes: 1 addition & 1 deletion adapty-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
defaultConfig {
minSdk 21
targetSdk 31
buildConfigField 'String', 'VERSION_NAME', "\"2.11.0\""
buildConfigField 'String', 'VERSION_NAME', "\"2.11.1\""
buildConfigField 'String', 'BUILDER_VERSION', "\"3\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
6 changes: 6 additions & 0 deletions adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public class AdaptyPaywallView @JvmOverloads constructor(
internal var observerModeHandler: AdaptyUiObserverModeHandler? = null
get() = if (isAttachedToWindow) field else null

/**
* If you use Adapty in [Observer mode](https://docs.adapty.io/v2.0.0/docs/observer-vs-full-mode),
* use it to handle purchases on your own.
*
* @param[handler] An object that implements the [AdaptyUiObserverModeHandler] interface.
*/
public fun setObserverModeHandler(handler: AdaptyUiObserverModeHandler) {
observerModeHandler = handler
}
Expand Down
22 changes: 12 additions & 10 deletions adapty-ui/src/main/java/com/adapty/ui/AdaptyUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public object AdaptyUI {
*
* @param[tagResolver] If you are going to use custom tags functionality, pass the resolver function here.
*
* @param[observerModeHandler] If you use Adapty in [Observer mode](https://docs.adapty.io/v2.0.0/docs/observer-vs-full-mode),
* pass the [AdaptyUiObserverModeHandler] implementation to handle purchases on your own.
*
* @return An [AdaptyPaywallView] object, representing the requested paywall screen.
*/
@JvmStatic
Expand Down Expand Up @@ -146,7 +149,7 @@ public object AdaptyUI {
public class ViewConfiguration internal constructor(
@get:JvmSynthetic internal val id: String,
@get:JvmSynthetic internal val paywall: AdaptyPaywall,
@get:JvmSynthetic internal val isHard: Boolean,
public val isHard: Boolean,
@get:JvmSynthetic internal val templateId: String?,
@get:JvmSynthetic internal val mainImageRelativeHeight: Float,
private val defaultLocalization: String?,
Expand Down Expand Up @@ -284,13 +287,12 @@ public object AdaptyUI {
LEADING, TRAILING, CENTER, FILL
}

internal sealed class Transition(
val durationMillis: Long,
val startDelayMillis: Long,
val interpolatorName: String,
public sealed class Transition(
internal val durationMillis: Long,
internal val startDelayMillis: Long,
internal val interpolatorName: String,
) {

class Fade(
public class Fade(
durationMillis: Long,
startDelayMillis: Long,
interpolatorName: String,
Expand Down Expand Up @@ -366,9 +368,9 @@ public object AdaptyUI {
internal val source: Source,
): Filling.Local() {

internal sealed class Source {
class File(val file: java.io.File): Source()
class Base64Str(val imageBase64: String?): Source()
public sealed class Source {
public class File(internal val file: java.io.File): Source()
public class Base64Str(internal val imageBase64: String?): Source()
}

internal enum class Dimension { WIDTH, HEIGHT }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,52 @@ import com.adapty.models.AdaptyPaywall
import com.adapty.models.AdaptyPaywallProduct
import com.adapty.ui.AdaptyPaywallView

/**
* If you use Adapty in [Observer mode](https://docs.adapty.io/v2.0.0/docs/observer-vs-full-mode),
* implement this interface to handle purchases on your own.
*/
public fun interface AdaptyUiObserverModeHandler {

/**
* This callback is invoked when the user initiates a purchase.
* You can trigger your custom purchase flow in response to this callback, [read more](https://docs.adapty.io/docs/android-present-paywall-builder-paywalls-in-observer-mode).
*
* @param[product] An [AdaptyPaywallProduct] of the purchase.
*
* @param[paywall] An [AdaptyPaywall] within which the purchase is initiated.
*
* @param[view] An [AdaptyPaywallView] within which the purchase is initiated.
*
* @param[onStartPurchase] A [PurchaseStartCallback] that should be invoked to notify AdaptyUI
* that the purchase is started.
*
* From Kotlin:
*
* ```Kotlin
* onStartPurchase()
* ```
*
* From Java:
*
* ```Java
* onStartPurchase.invoke()
* ```
*
* @param[onFinishPurchase] A [PurchaseFinishCallback] that should be invoked to notify AdaptyUI
* that the purchase is finished successfully or not, or the purchase is canceled.
*
* From Kotlin:
*
* ```Kotlin
* onFinishPurchase()
* ```
*
* From Java:
*
* ```Java
* onFinishPurchase.invoke()
* ```
*/
public fun onPurchaseInitiated(
product: AdaptyPaywallProduct,
paywall: AdaptyPaywall,
Expand All @@ -15,10 +59,17 @@ public fun interface AdaptyUiObserverModeHandler {
)

public fun interface PurchaseStartCallback {
/**
* This method should be called to notify AdaptyUI that the purchase is started.
*/
public operator fun invoke()
}

public fun interface PurchaseFinishCallback {
/**
* This method should be called to notify AdaptyUI that the purchase is finished successfully or not,
* or the purchase is canceled.
*/
public operator fun invoke()
}
}
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':adapty-ui')
implementation 'io.adapty:android-sdk:2.11.0'
implementation 'io.adapty:android-sdk:2.11.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.appcompat:appcompat:1.4.2'
Expand Down

0 comments on commit fe306f9

Please sign in to comment.