react-native-firework-sdk 1.2.0-beta.8 → 1.2.1
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/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +0 -8
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +2 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt +3 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt +2 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +23 -21
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +4 -19
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +28 -9
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt +22 -10
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWDataUtils.kt +119 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +38 -3
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWBundleUtils.kt +86 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +12 -3
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +1 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +35 -4
- package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +2 -1
- package/ios/Modules/Shopping/CartViewController.swift +6 -1
- package/ios/Modules/Shopping/ShoppingModule.m +1 -2
- package/ios/Modules/Shopping/ShoppingModule.swift +10 -12
- package/lib/commonjs/FWNavigator.js +10 -1
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +4 -4
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +3 -16
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +3 -1
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js +0 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/NewNativeContainerProps.js +2 -0
- package/lib/commonjs/models/NewNativeContainerProps.js.map +1 -0
- package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FWNavigator.js +10 -1
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +4 -4
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +3 -16
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/VideoFeed.js +3 -1
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/NewNativeContainerProps.js +2 -0
- package/lib/module/models/NewNativeContainerProps.js.map +1 -0
- package/lib/module/modules/FWNavigatorModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +6 -1
- package/lib/typescript/VideoShopping.d.ts +2 -9
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/models/NewNativeContainerProps.d.ts +6 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +4 -0
- package/lib/typescript/modules/FWNavigatorModule.d.ts +1 -0
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -2
- package/package.json +1 -1
- package/src/FWNavigator.tsx +9 -1
- package/src/FireworkSDK.ts +4 -4
- package/src/VideoShopping.ts +5 -17
- package/src/components/VideoFeed.tsx +2 -0
- package/src/index.tsx +2 -5
- package/src/models/NewNativeContainerProps.ts +4 -0
- package/src/models/VideoFeedConfiguration.ts +4 -0
- package/src/modules/FWNavigatorModule.ts +1 -0
- package/src/modules/ShoppingModule.ts +5 -2
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWCustomCTALinkContentContainerActivity.kt +0 -55
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWVideoShoppingCartActivity.kt +0 -43
- package/lib/commonjs/components/CartContainer.js +0 -35
- package/lib/commonjs/components/CartContainer.js.map +0 -1
- package/lib/module/components/CartContainer.js +0 -18
- package/lib/module/components/CartContainer.js.map +0 -1
- package/lib/typescript/components/CartContainer.d.ts +0 -3
- package/src/components/CartContainer.tsx +0 -20
package/android/build.gradle
CHANGED
|
@@ -168,7 +168,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
168
168
|
dependencies {
|
|
169
169
|
|
|
170
170
|
// optional 1: firework sdk release verison
|
|
171
|
-
def firework_sdk_version = 'v5.12.
|
|
171
|
+
def firework_sdk_version = 'v5.12.2'
|
|
172
172
|
implementation "com.github.loopsocial:firework_sdk:$firework_sdk_version"
|
|
173
173
|
|
|
174
174
|
// optional 2: firework sdk local version,
|
|
@@ -7,18 +7,10 @@
|
|
|
7
7
|
<activity
|
|
8
8
|
android:name="com.loopnow.fireworklibrary.PlaybackActivity"
|
|
9
9
|
/>
|
|
10
|
-
<activity
|
|
11
|
-
android:name="com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity"
|
|
12
|
-
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
13
|
-
/>
|
|
14
10
|
<activity
|
|
15
11
|
android:name="com.fireworksdk.bridge.reactnative.pages.FWContainerActivity"
|
|
16
12
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
17
13
|
/>
|
|
18
|
-
<activity
|
|
19
|
-
android:name="com.fireworksdk.bridge.reactnative.pages.FWCustomCTALinkContentContainerActivity"
|
|
20
|
-
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
21
|
-
/>
|
|
22
14
|
<provider
|
|
23
15
|
android:authorities="com.fireworksdk.bridge.reactnative"
|
|
24
16
|
android:name=".reactnative.FWInitializationProvider"
|
|
@@ -155,7 +155,7 @@ class FWVideoFeed(
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// set Feed Configuration
|
|
158
|
-
FWVideoPlayerUtils.setVideoFeedConfig(videoFeedView, videoFeedConfiguration)
|
|
158
|
+
FWVideoPlayerUtils.setVideoFeedConfig(context, videoFeedView, videoFeedConfiguration)
|
|
159
159
|
// set Player Configuration
|
|
160
160
|
FWVideoPlayerUtils.setVideoPlayerConfig(videoPlayerConfiguration)
|
|
161
161
|
}
|
|
@@ -188,7 +188,7 @@ class FWVideoFeed(
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
// set Feed Configuration
|
|
191
|
-
FWVideoPlayerUtils.setPlaylistGroupFeedConfig(playlistGroupFeedView, videoFeedConfiguration)
|
|
191
|
+
FWVideoPlayerUtils.setPlaylistGroupFeedConfig(context, playlistGroupFeedView, videoFeedConfiguration)
|
|
192
192
|
// set Player Configuration
|
|
193
193
|
FWVideoPlayerUtils.setVideoPlayerConfig(videoPlayerConfiguration)
|
|
194
194
|
}
|
|
@@ -10,7 +10,8 @@ data class FWVideoFeedConfigModel(
|
|
|
10
10
|
var title: FWTitleModel? = null,
|
|
11
11
|
var titlePosition: String? = null,
|
|
12
12
|
var playIcon: FWPlayIconModel? = null,
|
|
13
|
-
var showAdBadge: Boolean? = null
|
|
13
|
+
var showAdBadge: Boolean? = null,
|
|
14
|
+
var customLayoutName: String? = null
|
|
14
15
|
) : Parcelable {
|
|
15
16
|
|
|
16
17
|
@Parcelize
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
package com.fireworksdk.bridge.reactnative.models
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
5
|
|
|
5
6
|
interface FWNavigatorInterface {
|
|
6
7
|
|
|
7
|
-
fun pushNativeContainer(
|
|
8
|
+
fun pushNativeContainer(props: ReadableMap?, promise: Promise)
|
|
8
9
|
fun popNativeContainer(promise: Promise)
|
|
10
|
+
fun canPopNativeContainer(promise: Promise)
|
|
9
11
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.fireworksdk.bridge.reactnative.models
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
3
4
|
import com.facebook.react.bridge.ReadableArray
|
|
4
5
|
import com.facebook.react.bridge.ReadableMap
|
|
5
6
|
|
|
@@ -9,8 +10,7 @@ interface FWVideoShoppingInterface {
|
|
|
9
10
|
fun updateVideoProducts(productArray: ReadableArray?, videoId: String?)
|
|
10
11
|
fun updateProductViewConfig(config: ReadableMap?, callbackId: Int?)
|
|
11
12
|
fun updateAddToCartStatus(res: String?, tip: String?, callbackId: Int?)
|
|
12
|
-
fun jumpToCartPage(callbackId: Int?)
|
|
13
|
-
fun exitCartPage()
|
|
13
|
+
fun jumpToCartPage(callbackId: Int?, props: ReadableMap?)
|
|
14
14
|
fun setCartIconVisible(visible: Boolean?)
|
|
15
15
|
fun setCartItemCount(count: Int?)
|
|
16
16
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt
CHANGED
|
@@ -10,6 +10,7 @@ interface FireworkSDKInterface {
|
|
|
10
10
|
fun setShareBaseURL(url: String?, promise: Promise)
|
|
11
11
|
fun setAdBadgeConfiguration(config: ReadableMap?, promise: Promise)
|
|
12
12
|
fun setCustomCTAClickEnabled(value: Boolean?)
|
|
13
|
-
fun
|
|
13
|
+
fun setCustomCTALinkContentPageRouteName(name: String?, promise: Promise)
|
|
14
|
+
fun setAppComponentName(name: String?, promise: Promise)
|
|
14
15
|
fun setVideoPlaybackEventEnabled(value: Boolean?)
|
|
15
16
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
package com.fireworksdk.bridge.reactnative.module
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
3
4
|
import com.facebook.react.bridge.*
|
|
4
5
|
import com.fireworksdk.bridge.reactnative.FWInitializationProvider
|
|
5
6
|
import com.fireworksdk.bridge.reactnative.models.FWNavigatorInterface
|
|
6
|
-
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
7
7
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
8
|
-
import com.fireworksdk.bridge.utils.FWDateUtils
|
|
9
8
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
10
|
-
import java.util.*
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
class FWNavigatorModule(
|
|
@@ -15,42 +13,39 @@ class FWNavigatorModule(
|
|
|
15
13
|
) : ReactContextBaseJavaModule(reactContext), FWNavigatorInterface {
|
|
16
14
|
|
|
17
15
|
@ReactMethod
|
|
18
|
-
override fun pushNativeContainer(
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
override fun pushNativeContainer(props: ReadableMap?, promise: Promise) {
|
|
17
|
+
FWEventUtils.pushNativeContainer(reactApplicationContext, props, promise)
|
|
18
|
+
}
|
|
21
19
|
|
|
20
|
+
@ReactMethod
|
|
21
|
+
override fun popNativeContainer(promise: Promise) {
|
|
22
|
+
FWLogUtils.d { "FWNavigatorModule popNativeContainer" }
|
|
23
|
+
|
|
24
|
+
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
22
25
|
if (activity == null) {
|
|
23
26
|
promise.resolve(false)
|
|
24
27
|
return
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
if (isTaskRoot(activity)) {
|
|
31
|
+
promise.resolve(false)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
28
34
|
|
|
29
35
|
UiThreadUtil.runOnUiThread {
|
|
30
|
-
|
|
31
|
-
FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] Before Starting container activity ${FWDateUtils.getDateString(Date())}")
|
|
32
|
-
|
|
33
|
-
activity.startActivity(FWContainerActivity.createIntent(activity, callbackId))
|
|
34
|
-
|
|
35
|
-
FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] After Starting container activity ${FWDateUtils.getDateString(Date())}")
|
|
36
|
+
activity.finish()
|
|
36
37
|
}
|
|
37
38
|
promise.resolve(true)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
@ReactMethod
|
|
41
|
-
override fun
|
|
42
|
-
FWLogUtils.d { "FWNavigatorModule popNativeContainer" }
|
|
43
|
-
|
|
42
|
+
override fun canPopNativeContainer(promise: Promise) {
|
|
44
43
|
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
45
44
|
if (activity == null) {
|
|
46
45
|
promise.resolve(false)
|
|
47
46
|
return
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
UiThreadUtil.runOnUiThread {
|
|
51
|
-
activity.finish()
|
|
52
|
-
}
|
|
53
|
-
promise.resolve(true)
|
|
48
|
+
promise.resolve(!isTaskRoot(activity))
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
@ReactMethod
|
|
@@ -67,6 +62,13 @@ class FWNavigatorModule(
|
|
|
67
62
|
promise.resolve(Arguments.createMap())
|
|
68
63
|
}
|
|
69
64
|
|
|
65
|
+
private fun isTaskRoot(activity: Activity):Boolean {
|
|
66
|
+
if (activity.isTaskRoot) {
|
|
67
|
+
return true
|
|
68
|
+
}
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
|
|
70
72
|
override fun getName(): String {
|
|
71
73
|
return "FWNavigatorModule"
|
|
72
74
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt
CHANGED
|
@@ -3,17 +3,16 @@ package com.fireworksdk.bridge.reactnative.module
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import com.facebook.react.bridge.*
|
|
5
5
|
import com.fasterxml.jackson.core.type.TypeReference
|
|
6
|
-
import com.fireworksdk.bridge.reactnative.FWInitializationProvider
|
|
7
6
|
import com.loopnow.fireworklibrary.baya.Baya
|
|
8
7
|
import com.loopnow.fireworklibrary.baya.UpdateCartStatus
|
|
9
8
|
import com.fireworksdk.bridge.reactnative.models.FWVideoShoppingInterface
|
|
10
9
|
import com.fireworksdk.bridge.models.FWVideoShoppingProduct
|
|
11
|
-
import com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity
|
|
12
10
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
13
11
|
import com.fireworksdk.bridge.utils.FWJsonUtils
|
|
14
12
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
15
13
|
import com.loopnow.fireworklibrary.data.Product
|
|
16
14
|
import com.loopnow.fireworklibrary.utils.Util
|
|
15
|
+
import kotlin.collections.HashMap
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class FWVideoShoppingModule(
|
|
@@ -112,26 +111,12 @@ class FWVideoShoppingModule(
|
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
@ReactMethod
|
|
115
|
-
override fun jumpToCartPage(callbackId: Int?) {
|
|
116
|
-
FWLogUtils.d { "FWVideoShoppingModule jumpToCartPage: $callbackId" }
|
|
114
|
+
override fun jumpToCartPage(callbackId: Int?, props: ReadableMap?) {
|
|
115
|
+
FWLogUtils.d { "FWVideoShoppingModule jumpToCartPage: $callbackId props: $props" }
|
|
117
116
|
if (callbackId == null || cartClickHandler?.first != callbackId) {
|
|
118
117
|
return
|
|
119
118
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
UiThreadUtil.runOnUiThread {
|
|
123
|
-
activity.startActivity(FWVideoShoppingCartActivity.createIntent(activity))
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@ReactMethod
|
|
128
|
-
override fun exitCartPage() {
|
|
129
|
-
|
|
130
|
-
val activity = FWInitializationProvider.INSTANCE.resumedActivity ?: return
|
|
131
|
-
|
|
132
|
-
UiThreadUtil.runOnUiThread {
|
|
133
|
-
activity.finish()
|
|
134
|
-
}
|
|
119
|
+
FWEventUtils.pushNativeContainer(reactApplicationContext, props, null)
|
|
135
120
|
}
|
|
136
121
|
|
|
137
122
|
@ReactMethod
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt
CHANGED
|
@@ -13,7 +13,7 @@ import com.facebook.react.bridge.ReactMethod
|
|
|
13
13
|
import com.fireworksdk.bridge.models.FWAdBadgeConfigModel
|
|
14
14
|
import com.fireworksdk.bridge.reactnative.FWInitializationProvider
|
|
15
15
|
import com.fireworksdk.bridge.reactnative.models.FireworkSDKInterface
|
|
16
|
-
import com.fireworksdk.bridge.reactnative.pages.
|
|
16
|
+
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
17
17
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
18
18
|
import com.loopnow.fireworklibrary.*
|
|
19
19
|
import java.util.*
|
|
@@ -104,11 +104,6 @@ class FireworkSDKModule(
|
|
|
104
104
|
FWVideoPlayerUtils.customCTAClickEnabled = value?:false
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
@ReactMethod
|
|
108
|
-
override fun setCustomCTALinkContentRenderEnabled(value: Boolean?) {
|
|
109
|
-
FWVideoPlayerUtils.customCTALinkContentRenderEnabled = value?:false
|
|
110
|
-
}
|
|
111
|
-
|
|
112
107
|
@ReactMethod
|
|
113
108
|
override fun setVideoPlaybackEventEnabled(value: Boolean?) {
|
|
114
109
|
FWVideoPlayerUtils.videoPlaybackEventEnabled = value?:false
|
|
@@ -180,12 +175,19 @@ class FireworkSDKModule(
|
|
|
180
175
|
|
|
181
176
|
FWEventUtils.sendCustomCTAClickEvent(reactApplicationContext, actionUrl)
|
|
182
177
|
|
|
183
|
-
if (
|
|
178
|
+
if (!appComponentName.isNullOrBlank() && !customCTALinkContentPageRouteName.isNullOrBlank()) {
|
|
184
179
|
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
185
|
-
|
|
180
|
+
|
|
181
|
+
activity?.startActivity(FWContainerActivity.createIntent(activity, appComponentName,
|
|
182
|
+
hashMapOf(
|
|
183
|
+
"initialRouteName" to customCTALinkContentPageRouteName,
|
|
184
|
+
"initialParams" to hashMapOf("url" to actionUrl)
|
|
185
|
+
)
|
|
186
|
+
))
|
|
187
|
+
return true
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
return FWVideoPlayerUtils.customCTAClickEnabled
|
|
190
|
+
return FWVideoPlayerUtils.customCTAClickEnabled
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
}
|
|
@@ -243,6 +245,18 @@ class FireworkSDKModule(
|
|
|
243
245
|
})
|
|
244
246
|
}
|
|
245
247
|
|
|
248
|
+
@ReactMethod
|
|
249
|
+
override fun setCustomCTALinkContentPageRouteName(name: String?, promise: Promise) {
|
|
250
|
+
customCTALinkContentPageRouteName = name
|
|
251
|
+
promise.resolve(Arguments.createMap())
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@ReactMethod
|
|
255
|
+
override fun setAppComponentName(name: String?, promise: Promise) {
|
|
256
|
+
appComponentName = name
|
|
257
|
+
promise.resolve(Arguments.createMap())
|
|
258
|
+
}
|
|
259
|
+
|
|
246
260
|
@ReactMethod
|
|
247
261
|
fun addListener(eventName: String?, promise: Promise) {
|
|
248
262
|
// Set up any upstream listeners or background tasks as necessary
|
|
@@ -261,4 +275,9 @@ class FireworkSDKModule(
|
|
|
261
275
|
return "FireworkSDK"
|
|
262
276
|
}
|
|
263
277
|
|
|
278
|
+
companion object {
|
|
279
|
+
var appComponentName: String? = null
|
|
280
|
+
var customCTALinkContentPageRouteName: String? = null
|
|
281
|
+
}
|
|
282
|
+
|
|
264
283
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt
CHANGED
|
@@ -8,6 +8,8 @@ import androidx.fragment.app.Fragment
|
|
|
8
8
|
import com.facebook.react.ReactFragment
|
|
9
9
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
|
|
10
10
|
import com.fireworksdk.bridge.R
|
|
11
|
+
import com.fireworksdk.bridge.utils.FWBundleUtils
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
|
|
13
15
|
|
|
@@ -15,11 +17,12 @@ class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
|
|
|
15
17
|
super.onCreate(savedInstanceState)
|
|
16
18
|
setContentView(R.layout.fw_bridge_fragment_container)
|
|
17
19
|
|
|
18
|
-
val
|
|
20
|
+
val componentName = intent.getStringExtra(KEY_COMPONENT_NAME)
|
|
21
|
+
val params = intent.getSerializableExtra(KEY_PARAMS) as HashMap<String, Any?>?
|
|
19
22
|
|
|
20
23
|
val reactNativeFragment: Fragment = ReactFragment.Builder()
|
|
21
|
-
.setComponentName(
|
|
22
|
-
.setLaunchOptions(
|
|
24
|
+
.setComponentName(componentName)
|
|
25
|
+
.setLaunchOptions(FWBundleUtils.mapToBundle(params))
|
|
23
26
|
.build()
|
|
24
27
|
|
|
25
28
|
supportFragmentManager
|
|
@@ -28,20 +31,29 @@ class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
|
|
|
28
31
|
.commit()
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
// https://github.com/facebook/react-native/issues/16026
|
|
35
|
+
private fun getLaunchOptions(params: HashMap<String, Any?>?) = Bundle().apply {
|
|
36
|
+
if (params != null) {
|
|
37
|
+
putBundle(KEY_PARAMS, FWBundleUtils.mapToBundle(params))
|
|
38
|
+
|
|
39
|
+
// val jsonString = FWJsonUtils.toJson(params)
|
|
40
|
+
// if (!jsonString.isNullOrBlank()) {
|
|
41
|
+
// val jsonObject = JSONObject(jsonString)
|
|
42
|
+
// val writableMap = FWDataUtils.convertJsonObjectToWritableMap(jsonObject)
|
|
43
|
+
// putSerializable(KEY_PARAMS, params)
|
|
44
|
+
// }
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
companion object {
|
|
38
49
|
|
|
39
|
-
private const val
|
|
40
|
-
private const val
|
|
50
|
+
private const val KEY_PARAMS = "params"
|
|
51
|
+
private const val KEY_COMPONENT_NAME = "componentName"
|
|
41
52
|
|
|
42
|
-
fun createIntent(activity: Activity,
|
|
53
|
+
fun createIntent(activity: Activity, componentName: String?, params: HashMap<String, Any?>?): Intent {
|
|
43
54
|
val intent = Intent(activity, FWContainerActivity::class.java)
|
|
44
|
-
intent.putExtra(
|
|
55
|
+
intent.putExtra(KEY_COMPONENT_NAME, componentName)
|
|
56
|
+
intent.putExtra(KEY_PARAMS, params)
|
|
45
57
|
intent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
|
|
46
58
|
activity.overridePendingTransition(0, 0)
|
|
47
59
|
return intent
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.reactnative.utils
|
|
2
|
+
import com.facebook.react.bridge.*
|
|
3
|
+
import org.json.JSONArray
|
|
4
|
+
import org.json.JSONException
|
|
5
|
+
import org.json.JSONObject
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
object FWDataUtils {
|
|
9
|
+
|
|
10
|
+
@Throws(JSONException::class)
|
|
11
|
+
fun convertJsonObjectToWritableMap(jsonObject: JSONObject?): WritableMap? {
|
|
12
|
+
if (jsonObject == null) {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
val map: WritableMap = WritableNativeMap()
|
|
16
|
+
val iterator = jsonObject.keys()
|
|
17
|
+
while (iterator.hasNext()) {
|
|
18
|
+
val key = iterator.next()
|
|
19
|
+
when (val value = jsonObject[key]) {
|
|
20
|
+
is JSONObject -> {
|
|
21
|
+
map.putMap(key, convertJsonObjectToWritableMap(value))
|
|
22
|
+
}
|
|
23
|
+
is JSONArray -> {
|
|
24
|
+
map.putArray(key, convertJsonObjectToWritableArray(value))
|
|
25
|
+
}
|
|
26
|
+
is Boolean -> {
|
|
27
|
+
map.putBoolean(key, value)
|
|
28
|
+
}
|
|
29
|
+
is Int -> {
|
|
30
|
+
map.putInt(key, value)
|
|
31
|
+
}
|
|
32
|
+
is Double -> {
|
|
33
|
+
map.putDouble(key, value)
|
|
34
|
+
}
|
|
35
|
+
is String -> {
|
|
36
|
+
map.putString(key, value)
|
|
37
|
+
}
|
|
38
|
+
else -> {
|
|
39
|
+
map.putString(key, value.toString())
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return map
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Throws(JSONException::class)
|
|
47
|
+
fun convertJsonObjectToWritableArray(jsonArray: JSONArray?): WritableArray? {
|
|
48
|
+
if (jsonArray == null) {
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
val array: WritableArray = WritableNativeArray()
|
|
52
|
+
for (i in 0 until jsonArray.length()) {
|
|
53
|
+
when (val value = jsonArray[i]) {
|
|
54
|
+
is JSONObject -> {
|
|
55
|
+
array.pushMap(convertJsonObjectToWritableMap(value))
|
|
56
|
+
}
|
|
57
|
+
is JSONArray -> {
|
|
58
|
+
array.pushArray(convertJsonObjectToWritableArray(value))
|
|
59
|
+
}
|
|
60
|
+
is Boolean -> {
|
|
61
|
+
array.pushBoolean(value)
|
|
62
|
+
}
|
|
63
|
+
is Int -> {
|
|
64
|
+
array.pushInt(value)
|
|
65
|
+
}
|
|
66
|
+
is Double -> {
|
|
67
|
+
array.pushDouble(value)
|
|
68
|
+
}
|
|
69
|
+
is String -> {
|
|
70
|
+
array.pushString(value)
|
|
71
|
+
}
|
|
72
|
+
else -> {
|
|
73
|
+
array.pushString(value.toString())
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return array
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Throws(JSONException::class)
|
|
81
|
+
fun convertReadableMapToJsonObject(readableMap: ReadableMap?): JSONObject? {
|
|
82
|
+
if (readableMap == null) {
|
|
83
|
+
return null
|
|
84
|
+
}
|
|
85
|
+
val `object` = JSONObject()
|
|
86
|
+
val iterator = readableMap.keySetIterator()
|
|
87
|
+
while (iterator.hasNextKey()) {
|
|
88
|
+
val key = iterator.nextKey()
|
|
89
|
+
when (readableMap.getType(key)) {
|
|
90
|
+
ReadableType.Null -> `object`.put(key, JSONObject.NULL)
|
|
91
|
+
ReadableType.Boolean -> `object`.put(key, readableMap.getBoolean(key))
|
|
92
|
+
ReadableType.Number -> `object`.put(key, readableMap.getDouble(key))
|
|
93
|
+
ReadableType.String -> `object`.put(key, readableMap.getString(key))
|
|
94
|
+
ReadableType.Map -> `object`.put(key, convertReadableMapToJsonObject(readableMap.getMap(key)))
|
|
95
|
+
ReadableType.Array -> `object`.put(key, convertReadableArrayToJsonObject(readableMap.getArray(key)))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return `object`
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Throws(JSONException::class)
|
|
102
|
+
fun convertReadableArrayToJsonObject(readableArray: ReadableArray?): JSONArray? {
|
|
103
|
+
if (readableArray == null) {
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
val array = JSONArray()
|
|
107
|
+
for (i in 0 until readableArray.size()) {
|
|
108
|
+
when (readableArray.getType(i)) {
|
|
109
|
+
ReadableType.Null -> {}
|
|
110
|
+
ReadableType.Boolean -> array.put(readableArray.getBoolean(i))
|
|
111
|
+
ReadableType.Number -> array.put(readableArray.getDouble(i))
|
|
112
|
+
ReadableType.String -> array.put(readableArray.getString(i))
|
|
113
|
+
ReadableType.Map -> array.put(convertReadableMapToJsonObject(readableArray.getMap(i)))
|
|
114
|
+
ReadableType.Array -> array.put(convertReadableArrayToJsonObject(readableArray.getArray(i)))
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return array
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
package com.fireworksdk.bridge.reactnative.utils
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
|
-
import com.facebook.react.bridge
|
|
5
|
-
import com.facebook.react.bridge.ReactContext
|
|
6
|
-
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
import com.facebook.react.bridge.*
|
|
7
5
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
6
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
9
7
|
import com.fireworksdk.bridge.models.*
|
|
8
|
+
import com.fireworksdk.bridge.reactnative.FWInitializationProvider
|
|
9
|
+
import com.fireworksdk.bridge.reactnative.module.FireworkSDKModule
|
|
10
|
+
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
11
|
+
import com.fireworksdk.bridge.utils.FWDateUtils
|
|
10
12
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
11
13
|
import com.loopnow.fireworklibrary.data.Product
|
|
14
|
+
import java.util.*
|
|
12
15
|
|
|
13
16
|
object FWEventUtils {
|
|
14
17
|
|
|
18
|
+
fun pushNativeContainer(reactContext: ReactContext, props: ReadableMap?, promise: Promise?) {
|
|
19
|
+
FWLogUtils.d { "FWNavigatorModule pushNativeContainer: $props" }
|
|
20
|
+
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
21
|
+
|
|
22
|
+
if (activity == null) {
|
|
23
|
+
promise?.resolve(false)
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
sendLogMessageEvent(reactContext, "[Android] Enter pushNativeContainer ${
|
|
28
|
+
FWDateUtils.getDateString(
|
|
29
|
+
Date()
|
|
30
|
+
)}")
|
|
31
|
+
|
|
32
|
+
UiThreadUtil.runOnUiThread {
|
|
33
|
+
|
|
34
|
+
sendLogMessageEvent(reactContext, "[Android] Before Starting container activity ${
|
|
35
|
+
FWDateUtils.getDateString(
|
|
36
|
+
Date()
|
|
37
|
+
)}")
|
|
38
|
+
|
|
39
|
+
activity.startActivity(FWContainerActivity.createIntent(activity, FireworkSDKModule.appComponentName, props?.toHashMap()))
|
|
40
|
+
|
|
41
|
+
sendLogMessageEvent(reactContext, "[Android] After Starting container activity ${
|
|
42
|
+
FWDateUtils.getDateString(
|
|
43
|
+
Date()
|
|
44
|
+
)}")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
promise?.resolve(true)
|
|
48
|
+
}
|
|
49
|
+
|
|
15
50
|
fun sendInitSuccessEvent(reactContext: ReactContext) {
|
|
16
51
|
sendEvent(reactContext, FWEventName.SDKIni.rawValue, Arguments.createMap())
|
|
17
52
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.utils
|
|
2
|
+
|
|
3
|
+
import android.os.Bundle
|
|
4
|
+
import android.os.Parcelable
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
object FWBundleUtils {
|
|
8
|
+
|
|
9
|
+
fun mapToBundle(map: Map<String, Any?>?): Bundle? {
|
|
10
|
+
if (map == null) {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
val bundle = Bundle()
|
|
14
|
+
for ((key, value) in map) {
|
|
15
|
+
if (value is Double) {
|
|
16
|
+
bundle.putDouble(key, value)
|
|
17
|
+
} else if (value is Int) {
|
|
18
|
+
bundle.putInt(key, value)
|
|
19
|
+
} else if (value is String) {
|
|
20
|
+
bundle.putString(key, value)
|
|
21
|
+
} else if (value is Boolean) {
|
|
22
|
+
bundle.putBoolean(key, value)
|
|
23
|
+
} else if (value is List<*>) {
|
|
24
|
+
val list = value as List<Any>
|
|
25
|
+
val first = list[0]
|
|
26
|
+
if (first == null || first is Double) {
|
|
27
|
+
bundle.putDoubleArray(key, listToDoubleArray(list))
|
|
28
|
+
} else if (first is Int) {
|
|
29
|
+
bundle.putIntArray(key, listToIntArray(list))
|
|
30
|
+
} else if (first is String) {
|
|
31
|
+
bundle.putStringArray(key, listToStringArray(list))
|
|
32
|
+
} else if (first is Map<*, *>) {
|
|
33
|
+
bundle.putParcelableArrayList(key, listToParcelableArrayList(list))
|
|
34
|
+
}
|
|
35
|
+
} else if (value is Map<*, *>) {
|
|
36
|
+
bundle.putBundle(key, mapToBundle(value as Map<String, Any>))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return bundle
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private fun listToDoubleArray(list: List<Any>?): DoubleArray? {
|
|
43
|
+
if (list == null) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
val doubles = DoubleArray(list.size)
|
|
47
|
+
for (i in list.indices) {
|
|
48
|
+
doubles[i] = list[i] as Double
|
|
49
|
+
}
|
|
50
|
+
return doubles
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private fun listToIntArray(list: List<Any>?): IntArray? {
|
|
54
|
+
if (list == null) {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
val integers = IntArray(list.size)
|
|
58
|
+
for (i in list.indices) {
|
|
59
|
+
integers[i] = list[i] as Int
|
|
60
|
+
}
|
|
61
|
+
return integers
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private fun listToStringArray(list: List<Any>?): Array<String?>? {
|
|
65
|
+
if (list == null) {
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
val strings = arrayOfNulls<String>(list.size)
|
|
69
|
+
for (i in list.indices) {
|
|
70
|
+
strings[i] = list[i].toString()
|
|
71
|
+
}
|
|
72
|
+
return strings
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private fun listToParcelableArrayList(list: List<Any>?): ArrayList<Parcelable?>? {
|
|
76
|
+
if (list == null) {
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
79
|
+
val arrayList: ArrayList<Parcelable?> = ArrayList()
|
|
80
|
+
for (item in list) {
|
|
81
|
+
val map = item as Map<String, Any>
|
|
82
|
+
arrayList.add(mapToBundle(map))
|
|
83
|
+
}
|
|
84
|
+
return arrayList
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.fireworksdk.bridge.utils
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
3
4
|
import android.graphics.Color
|
|
4
5
|
import com.loopnow.fireworklibrary.VideoPlayerProperties
|
|
5
6
|
import com.fireworksdk.bridge.constants.FWVideoPlayerConstant
|
|
@@ -16,7 +17,6 @@ import com.loopnow.fireworklibrary.views.VideoFeedView
|
|
|
16
17
|
object FWVideoPlayerUtils {
|
|
17
18
|
|
|
18
19
|
var customCTAClickEnabled: Boolean = false
|
|
19
|
-
var customCTALinkContentRenderEnabled: Boolean = false
|
|
20
20
|
var videoPlaybackEventEnabled: Boolean = false
|
|
21
21
|
|
|
22
22
|
private var hasAssignedLaunchAppWithMute = false
|
|
@@ -45,7 +45,11 @@ object FWVideoPlayerUtils {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
fun setPlaylistGroupFeedConfig(feedView: PlaylistGroupFeedView?, config: FWVideoFeedConfigModel?) {
|
|
48
|
+
fun setPlaylistGroupFeedConfig(context: Context, feedView: PlaylistGroupFeedView?, config: FWVideoFeedConfigModel?) {
|
|
49
|
+
config?.customLayoutName?.let {
|
|
50
|
+
val layout = context.resources.getIdentifier(it, "layout", context.packageName)
|
|
51
|
+
feedView?.setCustomLayout(layout)
|
|
52
|
+
}
|
|
49
53
|
val backgroundColor = config?.backgroundColor
|
|
50
54
|
if (!backgroundColor.isNullOrBlank()) {
|
|
51
55
|
feedView?.setBackgroundColor(Color.parseColor(backgroundColor))
|
|
@@ -63,7 +67,12 @@ object FWVideoPlayerUtils {
|
|
|
63
67
|
VideoFeedProperties.displayAdLabel = config?.showAdBadge == true
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
fun setVideoFeedConfig(feedView: VideoFeedView?, config: FWVideoFeedConfigModel?) {
|
|
70
|
+
fun setVideoFeedConfig(context: Context, feedView: VideoFeedView?, config: FWVideoFeedConfigModel?) {
|
|
71
|
+
config?.customLayoutName?.let {
|
|
72
|
+
val layout = context.resources.getIdentifier(it, "layout", context.packageName)
|
|
73
|
+
feedView?.setCustomLayout(layout)
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
val backgroundColor = config?.backgroundColor
|
|
68
77
|
if (!backgroundColor.isNullOrBlank()) {
|
|
69
78
|
feedView?.setBackgroundColor(Color.parseColor(backgroundColor))
|
|
@@ -13,5 +13,6 @@
|
|
|
13
13
|
|
|
14
14
|
RCT_EXTERN_METHOD(pushNativeContainer:(NSDictionary *)props resolver:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
15
15
|
RCT_EXTERN_METHOD(popNativeContainer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
16
|
+
RCT_EXTERN_METHOD(canPopNativeContainer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
16
17
|
|
|
17
18
|
@end
|