File tree Expand file tree Collapse file tree 6 files changed +15
-9
lines changed
main/java/cloud/mindbox/mobile_sdk
test/java/cloud/mindbox/mobile_sdk/inapp/presentation Expand file tree Collapse file tree 6 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -21,4 +21,4 @@ android.enableJetifier=true
2121kotlin.code.style =official
2222
2323# SDK version property
24- SDK_VERSION_NAME =2.9.0-rc
24+ SDK_VERSION_NAME =2.9.0
Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ object Mindbox : MindboxLog {
9595
9696 private val mutex = Mutex ()
9797
98+ private val inAppMutex = Mutex ()
99+
98100 private var firstInitCall: Boolean = true
99101
100102 /* *
@@ -522,7 +524,7 @@ object Mindbox : MindboxLog {
522524 if (activity != null && lifecycleManager.isCurrentActivityResumed) {
523525 inAppMessageManager.registerCurrentActivity(activity)
524526 mindboxScope.launch {
525- mutex .withLock {
527+ inAppMutex .withLock {
526528 firstInitCall = false
527529 inAppMessageManager.listenEventAndInApp()
528530 inAppMessageManager.initLogs()
@@ -576,8 +578,8 @@ object Mindbox : MindboxLog {
576578 )
577579 if (firstInitCall) {
578580 mindboxScope.launch {
579- mutex.withLock {
580- InitializeLock .await( InitializeLock . State . SAVE_MINDBOX_CONFIG )
581+ InitializeLock .await( InitializeLock . State . SAVE_MINDBOX_CONFIG )
582+ inAppMutex.withLock {
581583 if (! firstInitCall) return @launch
582584 firstInitCall = false
583585 inAppMessageManager.listenEventAndInApp()
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ internal class PushPermissionInAppAction(
2727
2828 override fun execute (mindboxView : MindboxView ? ): InAppActionResult {
2929 mindboxLogI(" In-app for push activation was clicked" )
30- mindboxView?.requestPermission()
3130 return InAppActionResult (
3231 redirectUrl = " " ,
3332 payload = payload,
34- shouldDismiss = shouldDismiss()
33+ shouldDismiss = shouldDismiss(),
34+ onCompleted = { mindboxView?.requestPermission() }
3535 )
3636 }
3737
Original file line number Diff line number Diff line change @@ -3,5 +3,6 @@ package cloud.mindbox.mobile_sdk.inapp.presentation.actions
33internal data class InAppActionResult (
44 val redirectUrl : String ,
55 val payload : String ,
6- val shouldDismiss : Boolean
6+ val shouldDismiss : Boolean ,
7+ val onCompleted : (() -> Unit )? = null
78)
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ internal abstract class AbstractInAppViewHolder<T : InAppType> :
6666 var redirectUrl: String
6767 var payload: String
6868 var shouldDismiss: Boolean
69+
6970 currentDialog.setSingleClickListener {
7071
7172 val inAppData = inAppActionHandler.handle(
@@ -85,11 +86,15 @@ internal abstract class AbstractInAppViewHolder<T : InAppType> :
8586 redirectUrl,
8687 payload
8788 )
89+
8890 if (shouldDismiss) {
8991 inAppCallback.onInAppDismissed(wrapper.inAppType.inAppId)
9092 mindboxLogI(" In-app dismissed by click" )
9193 hide()
9294 }
95+
96+ inAppData.onCompleted?.invoke()
97+
9398 InAppMessageViewDisplayerImpl .isActionExecuted = true
9499 }
95100 }
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package cloud.mindbox.mobile_sdk.inapp.presentation
33import cloud.mindbox.mobile_sdk.inapp.presentation.actions.PushPermissionInAppAction
44import cloud.mindbox.mobile_sdk.inapp.presentation.actions.RedirectUrlInAppAction
55import io.mockk.mockk
6- import io.mockk.verify
76import org.junit.Assert
87import org.junit.Before
98import org.junit.Test
@@ -51,7 +50,6 @@ class InAppActionsTest {
5150
5251 val data = action.execute(mindboxView)
5352
54- verify { mindboxView.requestPermission() }
5553 Assert .assertEquals(" " , data.redirectUrl)
5654 Assert .assertEquals(payload, data.payload)
5755 Assert .assertEquals(true , data.shouldDismiss)
You can’t perform that action at this time.
0 commit comments