From fe306f94a2b072561f6d4e723d6df657bc3c1712 Mon Sep 17 00:00:00 2001 From: vlad Date: Tue, 4 Jun 2024 14:16:29 +0400 Subject: [PATCH] version 2.11.1 --- adapty-ui/build.gradle | 2 +- .../java/com/adapty/ui/AdaptyPaywallView.kt | 6 +++ .../src/main/java/com/adapty/ui/AdaptyUI.kt | 22 ++++---- .../listeners/AdaptyUiObserverModeHandler.kt | 51 +++++++++++++++++++ app/build.gradle | 2 +- 5 files changed, 71 insertions(+), 12 deletions(-) diff --git a/adapty-ui/build.gradle b/adapty-ui/build.gradle index 737fcad..15714e6 100644 --- a/adapty-ui/build.gradle +++ b/adapty-ui/build.gradle @@ -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" diff --git a/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt b/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt index 3da574b..62d7699 100644 --- a/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt +++ b/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt @@ -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 } diff --git a/adapty-ui/src/main/java/com/adapty/ui/AdaptyUI.kt b/adapty-ui/src/main/java/com/adapty/ui/AdaptyUI.kt index 595494e..8cac067 100644 --- a/adapty-ui/src/main/java/com/adapty/ui/AdaptyUI.kt +++ b/adapty-ui/src/main/java/com/adapty/ui/AdaptyUI.kt @@ -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 @@ -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?, @@ -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, @@ -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 } diff --git a/adapty-ui/src/main/java/com/adapty/ui/listeners/AdaptyUiObserverModeHandler.kt b/adapty-ui/src/main/java/com/adapty/ui/listeners/AdaptyUiObserverModeHandler.kt index f5f168d..96aae86 100644 --- a/adapty-ui/src/main/java/com/adapty/ui/listeners/AdaptyUiObserverModeHandler.kt +++ b/adapty-ui/src/main/java/com/adapty/ui/listeners/AdaptyUiObserverModeHandler.kt @@ -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, @@ -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() } } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index bdef641..6dca08e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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'