@usercentrics/react-native-sdk 2.2.1 → 2.2.2-RC1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/src/androidTest/java/com/usercentrics/reactnativemodule/RNUsercentricsModuleTest.kt
CHANGED
|
@@ -2,10 +2,7 @@ package com.usercentrics.reactnativemodule
|
|
|
2
2
|
|
|
3
3
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
4
4
|
import androidx.test.platform.app.InstrumentationRegistry
|
|
5
|
-
import com.facebook.react.bridge
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
-
import com.facebook.react.bridge.WritableArray
|
|
8
|
-
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.bridge.*
|
|
9
6
|
import com.facebook.soloader.SoLoader
|
|
10
7
|
import com.usercentrics.reactnativemodule.api.FakeUsercentricsProxy
|
|
11
8
|
import com.usercentrics.reactnativemodule.fake.FakePromise
|
|
@@ -699,31 +696,4 @@ class RNUsercentricsModuleTest {
|
|
|
699
696
|
|
|
700
697
|
assertEquals(1, usercentricsProxy.resetCount)
|
|
701
698
|
}
|
|
702
|
-
|
|
703
|
-
@Test
|
|
704
|
-
fun testShowFirstLayer() {
|
|
705
|
-
val usercentricsProxy = FakeUsercentricsProxy()
|
|
706
|
-
val contextMock = mockk<ReactApplicationContext>(relaxed = true)
|
|
707
|
-
val module = RNUsercentricsModule(contextMock, usercentricsProxy)
|
|
708
|
-
|
|
709
|
-
val promise = FakePromise()
|
|
710
|
-
module.showFirstLayer(ShowFirstLayerMock.arguments, promise)
|
|
711
|
-
|
|
712
|
-
assertEquals(
|
|
713
|
-
FirstLayerStyleSettings(
|
|
714
|
-
title = TitleSettings(alignment = SectionAlignment.END),
|
|
715
|
-
message = MessageSettings(alignment = SectionAlignment.CENTER),
|
|
716
|
-
cornerRadius = 50
|
|
717
|
-
),
|
|
718
|
-
usercentricsProxy.showFirstLayerStyle
|
|
719
|
-
)
|
|
720
|
-
assertEquals(
|
|
721
|
-
BannerSettings(font = null, logo = null),
|
|
722
|
-
usercentricsProxy.showFirstLayerBannerSettings
|
|
723
|
-
)
|
|
724
|
-
assertEquals(
|
|
725
|
-
UsercentricsLayout.Popup(PopupPosition.CENTER),
|
|
726
|
-
usercentricsProxy.showFirstLayerLayout
|
|
727
|
-
)
|
|
728
|
-
}
|
|
729
699
|
}
|
package/android/src/main/java/com/usercentrics/reactnativeusercentrics/RNUsercentricsModule.kt
CHANGED
|
@@ -74,42 +74,50 @@ internal class RNUsercentricsModule(
|
|
|
74
74
|
|
|
75
75
|
@ReactMethod
|
|
76
76
|
fun showFirstLayer(options: ReadableMap, promise: Promise) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
UiThreadUtil.runOnUiThread {
|
|
78
|
+
try {
|
|
79
|
+
val assetManager = currentActivity!!.assets
|
|
80
|
+
|
|
81
|
+
val layout = options.getString("layout")!!.usercentricsLayoutFromEnumString()
|
|
82
|
+
val bannerSettings =
|
|
83
|
+
options.getMap("bannerSettings")?.bannerSettingsFromMap(assetManager)
|
|
84
|
+
val styleSettings =
|
|
85
|
+
options.getMap("styleSettings")?.firstLayerStyleSettingsFromMap(assetManager)
|
|
86
|
+
|
|
87
|
+
usercentricsProxy.showFirstLayer(
|
|
88
|
+
currentActivity!!,
|
|
89
|
+
layout,
|
|
90
|
+
bannerSettings,
|
|
91
|
+
styleSettings,
|
|
92
|
+
promise
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
} catch (e: Exception) {
|
|
96
|
+
promise.reject(e)
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
@ReactMethod
|
|
98
102
|
fun showSecondLayer(options: ReadableMap, promise: Promise) {
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
UiThreadUtil.runOnUiThread {
|
|
104
|
+
try {
|
|
105
|
+
val assetManager = currentActivity!!.assets
|
|
106
|
+
|
|
107
|
+
val bannerSettings =
|
|
108
|
+
options.getMap("bannerSettings")?.bannerSettingsFromMap(assetManager)
|
|
109
|
+
val showCloseButton = options.getBoolean("showCloseButton")
|
|
110
|
+
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
UsercentricsBanner(currentActivity!!, bannerSettings).showSecondLayer(
|
|
113
|
+
showCloseButton
|
|
114
|
+
) {
|
|
115
|
+
promise.resolve(it?.toWritableMap())
|
|
116
|
+
}
|
|
105
117
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
) {
|
|
109
|
-
promise.resolve(it?.toWritableMap())
|
|
118
|
+
} catch (e: Exception) {
|
|
119
|
+
promise.reject(e)
|
|
110
120
|
}
|
|
111
|
-
} catch (e: Exception) {
|
|
112
|
-
promise.reject(e)
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
|