react-native-firework-sdk 1.2.0-beta.9 → 1.2.2
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/main/AndroidManifest.xml +0 -8
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedItemDetailsModel.kt +6 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +18 -2
- 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 +125 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +39 -9
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWBundleUtils.kt +86 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +0 -1
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +0 -4
- package/ios/Models/NativeToRN/FireworkSDK+Json.swift +24 -9
- package/ios/Modules/FWNavigatorModule/FWNavigatorContainerViewController.swift +3 -11
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +3 -2
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +46 -8
- package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +4 -3
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +14 -6
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +2 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +12 -4
- 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 +17 -14
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +24 -12
- 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.map +1 -1
- package/lib/commonjs/index.js +0 -14
- 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/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FWNavigator.js +18 -15
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +23 -11
- 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.map +1 -1
- package/lib/module/index.js +0 -7
- 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/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +14 -8
- package/lib/typescript/FireworkSDK.d.ts +11 -6
- package/lib/typescript/VideoShopping.d.ts +2 -9
- package/lib/typescript/components/VideoFeed.d.ts +5 -5
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/models/FeedItemDetails.d.ts +25 -3
- package/lib/typescript/models/NewNativeContainerProps.d.ts +6 -0
- package/lib/typescript/modules/FWNavigatorModule.d.ts +4 -1
- package/lib/typescript/modules/FireworkSDKModule.d.ts +2 -1
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -2
- package/package.json +1 -1
- package/src/FWNavigator.tsx +21 -12
- package/src/FireworkSDK.ts +24 -20
- package/src/VideoShopping.ts +5 -17
- package/src/components/VideoFeed.tsx +5 -8
- package/src/index.tsx +2 -15
- package/src/models/FeedItemDetails.ts +23 -3
- package/src/models/NewNativeContainerProps.ts +4 -0
- package/src/modules/FWNavigatorModule.ts +2 -1
- package/src/modules/FireworkSDKModule.ts +2 -1
- 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/ios/Modules/FireworkSDKModule/FWCustomCTALinkContentContainerViewController.swift +0 -31
- package/lib/commonjs/components/CartContainer.js +0 -35
- package/lib/commonjs/components/CartContainer.js.map +0 -1
- package/lib/commonjs/components/CustomCTALinkContentContainer.js +0 -43
- package/lib/commonjs/components/CustomCTALinkContentContainer.js.map +0 -1
- package/lib/commonjs/components/NavigationContainer.js +0 -40
- package/lib/commonjs/components/NavigationContainer.js.map +0 -1
- package/lib/module/components/CartContainer.js +0 -18
- package/lib/module/components/CartContainer.js.map +0 -1
- package/lib/module/components/CustomCTALinkContentContainer.js +0 -26
- package/lib/module/components/CustomCTALinkContentContainer.js.map +0 -1
- package/lib/module/components/NavigationContainer.js +0 -23
- package/lib/module/components/NavigationContainer.js.map +0 -1
- package/lib/typescript/components/CartContainer.d.ts +0 -3
- package/lib/typescript/components/CustomCTALinkContentContainer.d.ts +0 -6
- package/lib/typescript/components/NavigationContainer.d.ts +0 -6
- package/src/components/CartContainer.tsx +0 -20
- package/src/components/CustomCTALinkContentContainer.tsx +0 -28
- package/src/components/NavigationContainer.tsx +0 -24
|
@@ -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"
|
|
@@ -7,6 +7,11 @@ import kotlinx.android.parcel.Parcelize
|
|
|
7
7
|
data class FWVideoFeedItemDetailsModel(
|
|
8
8
|
val index: Int?,
|
|
9
9
|
val id: String?,
|
|
10
|
-
val
|
|
10
|
+
val duration: Int?,
|
|
11
11
|
val source: String?,
|
|
12
|
+
val title: String?,
|
|
13
|
+
val playlistGroup: String?,
|
|
14
|
+
val playlist: String?,
|
|
15
|
+
val channel: String?,
|
|
16
|
+
val dynamicContentParameters: HashMap<String, List<String>>?,
|
|
12
17
|
) : Parcelable
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt
CHANGED
|
@@ -43,7 +43,15 @@ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
|
|
|
43
43
|
videoFeedView?.addOnItemClickedListener(object: OnItemClickedListener {
|
|
44
44
|
override fun onItemClicked(index: Int, title: String, id: String, videoDuration: Long) {
|
|
45
45
|
val fwVideoFeedItemDetailsModel = FWVideoFeedItemDetailsModel(
|
|
46
|
-
index,
|
|
46
|
+
index,
|
|
47
|
+
id,
|
|
48
|
+
videoDuration.toInt(),
|
|
49
|
+
videoFeed.videoFeedPropsModel.source,
|
|
50
|
+
title,
|
|
51
|
+
videoFeed.videoFeedPropsModel.playlistGroup,
|
|
52
|
+
videoFeed.videoFeedPropsModel.playlist,
|
|
53
|
+
videoFeed.videoFeedPropsModel.channel,
|
|
54
|
+
videoFeed.videoFeedPropsModel.dynamicContentParameters
|
|
47
55
|
)
|
|
48
56
|
FWEventUtils.sendVideoFeedClickEvent(reactContext, fwVideoFeedItemDetailsModel)
|
|
49
57
|
}
|
|
@@ -80,7 +88,15 @@ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
|
|
|
80
88
|
playlistGroupFeedView?.itemClickHandler = object : OnPlaylistGroupItemClickedListener {
|
|
81
89
|
override fun onItemClicked(index: Int, id: String?): Boolean {
|
|
82
90
|
val fwVideoFeedItemDetailsModel = FWVideoFeedItemDetailsModel(
|
|
83
|
-
index,
|
|
91
|
+
index,
|
|
92
|
+
id,
|
|
93
|
+
0,
|
|
94
|
+
videoFeed?.videoFeedPropsModel?.source,
|
|
95
|
+
"",
|
|
96
|
+
videoFeed?.videoFeedPropsModel?.playlistGroup,
|
|
97
|
+
videoFeed?.videoFeedPropsModel?.playlist,
|
|
98
|
+
videoFeed?.videoFeedPropsModel?.channel,
|
|
99
|
+
videoFeed?.videoFeedPropsModel?.dynamicContentParameters
|
|
84
100
|
)
|
|
85
101
|
FWEventUtils.sendVideoFeedClickEvent(reactContext, fwVideoFeedItemDetailsModel)
|
|
86
102
|
return false
|
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,125 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.reactnative.utils
|
|
2
|
+
import com.facebook.react.bridge.*
|
|
3
|
+
import com.fireworksdk.bridge.utils.FWJsonUtils
|
|
4
|
+
import org.json.JSONArray
|
|
5
|
+
import org.json.JSONException
|
|
6
|
+
import org.json.JSONObject
|
|
7
|
+
|
|
8
|
+
inline fun <reified T : Any> T.asMap(): WritableMap {
|
|
9
|
+
val jsonString = FWJsonUtils.toJson(this)
|
|
10
|
+
val jsonObject = JSONObject(jsonString)
|
|
11
|
+
return FWDataUtils.convertJsonObjectToWritableMap(jsonObject)?: Arguments.createMap()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
object FWDataUtils {
|
|
15
|
+
|
|
16
|
+
@Throws(JSONException::class)
|
|
17
|
+
fun convertJsonObjectToWritableMap(jsonObject: JSONObject?): WritableMap? {
|
|
18
|
+
if (jsonObject == null) {
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
val map: WritableMap = WritableNativeMap()
|
|
22
|
+
val iterator = jsonObject.keys()
|
|
23
|
+
while (iterator.hasNext()) {
|
|
24
|
+
val key = iterator.next()
|
|
25
|
+
when (val value = jsonObject[key]) {
|
|
26
|
+
is JSONObject -> {
|
|
27
|
+
map.putMap(key, convertJsonObjectToWritableMap(value))
|
|
28
|
+
}
|
|
29
|
+
is JSONArray -> {
|
|
30
|
+
map.putArray(key, convertJsonObjectToWritableArray(value))
|
|
31
|
+
}
|
|
32
|
+
is Boolean -> {
|
|
33
|
+
map.putBoolean(key, value)
|
|
34
|
+
}
|
|
35
|
+
is Int -> {
|
|
36
|
+
map.putInt(key, value)
|
|
37
|
+
}
|
|
38
|
+
is Double -> {
|
|
39
|
+
map.putDouble(key, value)
|
|
40
|
+
}
|
|
41
|
+
is String -> {
|
|
42
|
+
map.putString(key, value)
|
|
43
|
+
}
|
|
44
|
+
else -> {
|
|
45
|
+
map.putString(key, value.toString())
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return map
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Throws(JSONException::class)
|
|
53
|
+
fun convertJsonObjectToWritableArray(jsonArray: JSONArray?): WritableArray? {
|
|
54
|
+
if (jsonArray == null) {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
val array: WritableArray = WritableNativeArray()
|
|
58
|
+
for (i in 0 until jsonArray.length()) {
|
|
59
|
+
when (val value = jsonArray[i]) {
|
|
60
|
+
is JSONObject -> {
|
|
61
|
+
array.pushMap(convertJsonObjectToWritableMap(value))
|
|
62
|
+
}
|
|
63
|
+
is JSONArray -> {
|
|
64
|
+
array.pushArray(convertJsonObjectToWritableArray(value))
|
|
65
|
+
}
|
|
66
|
+
is Boolean -> {
|
|
67
|
+
array.pushBoolean(value)
|
|
68
|
+
}
|
|
69
|
+
is Int -> {
|
|
70
|
+
array.pushInt(value)
|
|
71
|
+
}
|
|
72
|
+
is Double -> {
|
|
73
|
+
array.pushDouble(value)
|
|
74
|
+
}
|
|
75
|
+
is String -> {
|
|
76
|
+
array.pushString(value)
|
|
77
|
+
}
|
|
78
|
+
else -> {
|
|
79
|
+
array.pushString(value.toString())
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return array
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Throws(JSONException::class)
|
|
87
|
+
fun convertReadableMapToJsonObject(readableMap: ReadableMap?): JSONObject? {
|
|
88
|
+
if (readableMap == null) {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
val `object` = JSONObject()
|
|
92
|
+
val iterator = readableMap.keySetIterator()
|
|
93
|
+
while (iterator.hasNextKey()) {
|
|
94
|
+
val key = iterator.nextKey()
|
|
95
|
+
when (readableMap.getType(key)) {
|
|
96
|
+
ReadableType.Null -> `object`.put(key, JSONObject.NULL)
|
|
97
|
+
ReadableType.Boolean -> `object`.put(key, readableMap.getBoolean(key))
|
|
98
|
+
ReadableType.Number -> `object`.put(key, readableMap.getDouble(key))
|
|
99
|
+
ReadableType.String -> `object`.put(key, readableMap.getString(key))
|
|
100
|
+
ReadableType.Map -> `object`.put(key, convertReadableMapToJsonObject(readableMap.getMap(key)))
|
|
101
|
+
ReadableType.Array -> `object`.put(key, convertReadableArrayToJsonObject(readableMap.getArray(key)))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return `object`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Throws(JSONException::class)
|
|
108
|
+
fun convertReadableArrayToJsonObject(readableArray: ReadableArray?): JSONArray? {
|
|
109
|
+
if (readableArray == null) {
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
val array = JSONArray()
|
|
113
|
+
for (i in 0 until readableArray.size()) {
|
|
114
|
+
when (readableArray.getType(i)) {
|
|
115
|
+
ReadableType.Null -> {}
|
|
116
|
+
ReadableType.Boolean -> array.put(readableArray.getBoolean(i))
|
|
117
|
+
ReadableType.Number -> array.put(readableArray.getDouble(i))
|
|
118
|
+
ReadableType.String -> array.put(readableArray.getString(i))
|
|
119
|
+
ReadableType.Map -> array.put(convertReadableMapToJsonObject(readableArray.getMap(i)))
|
|
120
|
+
ReadableType.Array -> array.put(convertReadableArrayToJsonObject(readableArray.getArray(i)))
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return array
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -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
|
}
|
|
@@ -26,12 +61,7 @@ object FWEventUtils {
|
|
|
26
61
|
|
|
27
62
|
fun sendVideoFeedClickEvent(reactContext: ReactContext, info: FWVideoFeedItemDetailsModel) {
|
|
28
63
|
val eventMap = Arguments.createMap()
|
|
29
|
-
|
|
30
|
-
contentMap.putInt("index", info.index?:0)
|
|
31
|
-
contentMap.putString("id", info.id)
|
|
32
|
-
contentMap.putInt("duration", info.videoDuration?:0)
|
|
33
|
-
contentMap.putString("source", info.source)
|
|
34
|
-
eventMap.putMap("info", contentMap)
|
|
64
|
+
eventMap.putMap("info", info.asMap())
|
|
35
65
|
sendEvent(reactContext, FWEventName.VideoFeedClick.rawValue, eventMap)
|
|
36
66
|
}
|
|
37
67
|
|
|
@@ -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
|
+
}
|
|
@@ -17,7 +17,6 @@ import com.loopnow.fireworklibrary.views.VideoFeedView
|
|
|
17
17
|
object FWVideoPlayerUtils {
|
|
18
18
|
|
|
19
19
|
var customCTAClickEnabled: Boolean = false
|
|
20
|
-
var customCTALinkContentRenderEnabled: Boolean = false
|
|
21
20
|
var videoPlaybackEventEnabled: Boolean = false
|
|
22
21
|
|
|
23
22
|
private var hasAssignedLaunchAppWithMute = false
|