react-native-daro 1.0.13 → 1.0.16

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.
Files changed (262) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -30
  3. package/android/build.gradle +52 -59
  4. package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +23 -0
  5. package/android/src/main/AndroidManifest.xml +1 -2
  6. package/android/src/main/java/com/{darom → daro/reactnative}/DaroMAdBannerViewManager.kt +38 -15
  7. package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +167 -0
  8. package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +257 -0
  9. package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +45 -0
  10. package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
  11. package/android/src/main/java/com/{darom → daro/reactnative}/constants/InternalDaroMBannerSize.kt +1 -1
  12. package/android/src/main/java/com/{darom → daro/reactnative}/event/DaroMEvent.kt +19 -8
  13. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMBannerViewModuleImpl.kt +2 -2
  14. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMInterstitialModuleImpl.kt +26 -26
  15. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMLightPopupModuleImpl.kt +30 -29
  16. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMRewardedAdModuleImpl.kt +27 -27
  17. package/android/src/main/java/com/{darom → daro/reactnative}/util/AdInfoUtil.kt +25 -1
  18. package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +37 -0
  19. package/android/src/main/java/com/daro/reactnative/view/DaroMAdBannerViewContainer.kt +417 -0
  20. package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +624 -0
  21. package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
  22. package/android/src/newarch/java/com/daro/reactnative/DaroMModuleSpec.kt +6 -0
  23. package/android/src/oldarch/java/com/daro/reactnative/DaroMModuleSpec.kt +90 -0
  24. package/app.plugin.js +1 -0
  25. package/ios/DaroMModule+AppOpen.swift +38 -32
  26. package/ios/DaroMModule+Interstitial.swift +32 -26
  27. package/ios/DaroMModule+LightPopup.swift +43 -33
  28. package/ios/DaroMModule+Rewarded.swift +38 -27
  29. package/ios/DaroMModule.mm +45 -17
  30. package/ios/DaroMModule.swift +24 -17
  31. package/ios/Fabric/DaroMAdBannerComponentView.mm +207 -0
  32. package/ios/Fabric/DaroMFabricEventSink.mm +31 -0
  33. package/ios/Fabric/DaroMFabricPropApplier.mm +123 -0
  34. package/ios/Fabric/DaroMNativeAdComponentView.mm +294 -0
  35. package/ios/{DaroMAdBannerViewManager.m → Paper/DaroMAdBannerViewManager.m} +3 -1
  36. package/ios/Paper/DaroMAdBannerViewManager.swift +21 -0
  37. package/ios/{DaroMNativeAdViewManager.m → Paper/DaroMNativeAdViewManager.m} +2 -1
  38. package/ios/Paper/DaroMNativeAdViewManager.swift +22 -0
  39. package/ios/Shared/DaroMAdEventSink.swift +24 -0
  40. package/ios/Shared/DaroMBannerAdView.swift +188 -0
  41. package/ios/Shared/DaroMNativeAdLoadCoordinator.swift +49 -0
  42. package/ios/Shared/DaroMNativeAdView.swift +575 -0
  43. package/ios/Shared/DaroMNativeAssetResolver.swift +53 -0
  44. package/ios/mediation/admob/DaroMediationDebugger.swift +11 -0
  45. package/ios/mediation/admob/DaroMediationTypes.swift +23 -0
  46. package/lib/commonjs/AdBannerView.js +21 -35
  47. package/lib/commonjs/AdBannerView.js.map +1 -1
  48. package/lib/commonjs/AppOpenAd.js +80 -21
  49. package/lib/commonjs/AppOpenAd.js.map +1 -1
  50. package/lib/commonjs/DaroMAdBannerViewNativeComponent.ts +47 -0
  51. package/lib/commonjs/DaroMNativeAdViewNativeComponent.ts +62 -0
  52. package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
  53. package/lib/commonjs/ErrorCode.js.map +1 -1
  54. package/lib/commonjs/EventEmitter.js +4 -5
  55. package/lib/commonjs/EventEmitter.js.map +1 -1
  56. package/lib/commonjs/InterstitialAd.js +48 -22
  57. package/lib/commonjs/InterstitialAd.js.map +1 -1
  58. package/lib/commonjs/LightPopupAd.js +64 -46
  59. package/lib/commonjs/LightPopupAd.js.map +1 -1
  60. package/lib/commonjs/NativeDaroModule.js +9 -0
  61. package/lib/commonjs/NativeDaroModule.js.map +1 -0
  62. package/lib/commonjs/RewardedAd.js +47 -23
  63. package/lib/commonjs/RewardedAd.js.map +1 -1
  64. package/lib/commonjs/codegen-env.d.js +2 -0
  65. package/lib/commonjs/codegen-env.d.js.map +1 -0
  66. package/lib/commonjs/hooks/useInterstitialAd.js +110 -0
  67. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  68. package/lib/commonjs/hooks/useLightPopupAd.js +114 -0
  69. package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -0
  70. package/lib/commonjs/hooks/useRewardedAd.js +113 -0
  71. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  72. package/lib/commonjs/index.js +29 -13
  73. package/lib/commonjs/index.js.map +1 -1
  74. package/lib/commonjs/nativeAd/NativeAdView.js +23 -18
  75. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  76. package/lib/commonjs/nativeAd/NativeAdViewComponents.js +43 -31
  77. package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
  78. package/lib/commonjs/nativeAd/NativeAdViewProvider.js +34 -7
  79. package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
  80. package/lib/commonjs/package.json +1 -0
  81. package/lib/module/AdBannerView.js +20 -36
  82. package/lib/module/AdBannerView.js.map +1 -1
  83. package/lib/module/AppOpenAd.js +80 -22
  84. package/lib/module/AppOpenAd.js.map +1 -1
  85. package/lib/module/DaroMAdBannerViewNativeComponent.ts +47 -0
  86. package/lib/module/DaroMNativeAdViewNativeComponent.ts +62 -0
  87. package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
  88. package/lib/module/ErrorCode.js.map +1 -1
  89. package/lib/module/EventEmitter.js +4 -6
  90. package/lib/module/EventEmitter.js.map +1 -1
  91. package/lib/module/InterstitialAd.js +47 -22
  92. package/lib/module/InterstitialAd.js.map +1 -1
  93. package/lib/module/LightPopupAd.js +65 -47
  94. package/lib/module/LightPopupAd.js.map +1 -1
  95. package/lib/module/NativeDaroModule.js +5 -0
  96. package/lib/module/NativeDaroModule.js.map +1 -0
  97. package/lib/module/RewardedAd.js +46 -23
  98. package/lib/module/RewardedAd.js.map +1 -1
  99. package/lib/module/codegen-env.d.js +2 -0
  100. package/lib/module/codegen-env.d.js.map +1 -0
  101. package/lib/module/hooks/useInterstitialAd.js +106 -0
  102. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  103. package/lib/module/hooks/useLightPopupAd.js +110 -0
  104. package/lib/module/hooks/useLightPopupAd.js.map +1 -0
  105. package/lib/module/hooks/useRewardedAd.js +109 -0
  106. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  107. package/lib/module/index.js +7 -13
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/nativeAd/NativeAdView.js +22 -19
  110. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  111. package/lib/module/nativeAd/NativeAdViewComponents.js +45 -34
  112. package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
  113. package/lib/module/nativeAd/NativeAdViewProvider.js +35 -8
  114. package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
  115. package/lib/module/package.json +1 -0
  116. package/lib/typescript/commonjs/plugin/src/index.d.ts +19 -0
  117. package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts +6 -0
  119. package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +8 -0
  121. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/plugin/src/withIos.d.ts +8 -0
  123. package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/src/AdBannerView.d.ts +126 -4
  125. package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/AppOpenAd.d.ts +6 -0
  127. package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
  129. package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
  131. package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts +6 -0
  133. package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/InterstitialAd.d.ts +6 -0
  137. package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/src/LightPopupAd.d.ts +6 -0
  139. package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +61 -0
  141. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/src/RewardedAd.d.ts +6 -0
  143. package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +19 -0
  145. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +23 -0
  147. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +20 -0
  149. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/src/index.d.ts +7 -1
  151. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +125 -2
  153. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
  156. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +2 -2
  158. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
  160. package/lib/typescript/commonjs/src/types/AdProps.d.ts +2 -2
  161. package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +2 -0
  164. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
  165. package/lib/typescript/module/plugin/src/index.d.ts +19 -0
  166. package/lib/typescript/module/plugin/src/index.d.ts.map +1 -0
  167. package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts +6 -0
  168. package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts.map +1 -0
  169. package/lib/typescript/module/plugin/src/withAndroid.d.ts +8 -0
  170. package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -0
  171. package/lib/typescript/module/plugin/src/withIos.d.ts +8 -0
  172. package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -0
  173. package/lib/typescript/module/src/AdBannerView.d.ts +126 -4
  174. package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
  175. package/lib/typescript/module/src/AppOpenAd.d.ts +6 -0
  176. package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
  177. package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
  178. package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
  179. package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
  180. package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
  181. package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts +6 -0
  182. package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
  183. package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -1
  184. package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
  185. package/lib/typescript/module/src/InterstitialAd.d.ts +6 -0
  186. package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
  187. package/lib/typescript/module/src/LightPopupAd.d.ts +6 -0
  188. package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
  189. package/lib/typescript/module/src/NativeDaroModule.d.ts +61 -0
  190. package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -0
  191. package/lib/typescript/module/src/RewardedAd.d.ts +6 -0
  192. package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
  193. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +19 -0
  194. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -0
  195. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +23 -0
  196. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -0
  197. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +20 -0
  198. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -0
  199. package/lib/typescript/module/src/index.d.ts +7 -1
  200. package/lib/typescript/module/src/index.d.ts.map +1 -1
  201. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +125 -2
  202. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
  203. package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  204. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
  205. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  206. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +2 -2
  207. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
  208. package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
  209. package/lib/typescript/module/src/types/AdProps.d.ts +2 -2
  210. package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
  211. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -1
  212. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +2 -0
  213. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
  214. package/package.json +95 -105
  215. package/plugin/build/index.d.ts +18 -0
  216. package/plugin/build/index.js +71 -0
  217. package/plugin/build/skAdNetworkIds.d.ts +5 -0
  218. package/plugin/build/skAdNetworkIds.js +205 -0
  219. package/plugin/build/withAndroid.d.ts +7 -0
  220. package/plugin/build/withAndroid.js +222 -0
  221. package/plugin/build/withIos.d.ts +7 -0
  222. package/plugin/build/withIos.js +82 -0
  223. package/react-native-daro.podspec +28 -0
  224. package/src/AdBannerView.tsx +48 -48
  225. package/src/AppOpenAd.ts +101 -20
  226. package/src/DaroMAdBannerViewNativeComponent.ts +47 -0
  227. package/src/DaroMNativeAdViewNativeComponent.ts +62 -0
  228. package/src/DaroMediaViewNativeComponent.ts +9 -0
  229. package/src/ErrorCode.ts +1 -2
  230. package/src/EventEmitter.ts +9 -7
  231. package/src/InterstitialAd.ts +75 -21
  232. package/src/LightPopupAd.ts +90 -51
  233. package/src/NativeDaroModule.ts +91 -0
  234. package/src/RewardedAd.ts +72 -22
  235. package/src/codegen-env.d.ts +45 -0
  236. package/src/hooks/useInterstitialAd.ts +117 -0
  237. package/src/hooks/useLightPopupAd.ts +132 -0
  238. package/src/hooks/useRewardedAd.ts +122 -0
  239. package/src/index.tsx +21 -22
  240. package/src/nativeAd/NativeAdView.tsx +83 -45
  241. package/src/nativeAd/NativeAdViewComponents.tsx +129 -64
  242. package/src/nativeAd/NativeAdViewProvider.tsx +84 -16
  243. package/src/types/AdBannerViewProps.ts +11 -11
  244. package/src/types/AdInfo.ts +17 -17
  245. package/src/types/AdProps.ts +8 -9
  246. package/src/types/DaroMMobileAds.ts +3 -6
  247. package/src/types/NativeAdViewProps.ts +12 -5
  248. package/src/types/index.ts +1 -1
  249. package/android/gradle.properties +0 -5
  250. package/android/src/main/AndroidManifestNew.xml +0 -7
  251. package/android/src/main/java/com/darom/DaroMAdNativeViewManager.kt +0 -136
  252. package/android/src/main/java/com/darom/DaroMModule.kt +0 -203
  253. package/android/src/main/java/com/darom/DaroMPackage.kt +0 -21
  254. package/android/src/main/java/com/darom/util/EventEmitterUtil.kt +0 -24
  255. package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +0 -163
  256. package/android/src/main/java/com/darom/view/DaroMAdNativeViewContainer.kt +0 -375
  257. package/android/src/main/res/layout/layout_activity_transparent.xml +0 -7
  258. package/android/src/main/res/values/styles.xml +0 -11
  259. package/ios/DaroM-Bridging-Header.h +0 -6
  260. package/ios/DaroMAdBannerViewManager.swift +0 -91
  261. package/ios/DaroMNativeAdViewManager.swift +0 -291
  262. package/react-native-daro-m.podspec +0 -44
@@ -1,375 +0,0 @@
1
- package com.darom.view
2
-
3
- import android.annotation.SuppressLint
4
- import android.os.Handler
5
- import android.os.Looper
6
- import android.text.SpannableString
7
- import android.text.Spanned
8
- import android.view.View
9
- import android.view.ViewGroup
10
- import android.widget.ImageView
11
- import androidx.annotation.IdRes
12
- import androidx.core.view.children
13
- import com.darom.event.AdViewEvent
14
- import com.darom.util.AdInfoUtil
15
- import com.darom.util.EventEmitterUtil.sendNativeViewEvent
16
- import com.facebook.react.bridge.ReactContext
17
- import com.facebook.react.views.text.ReactTextView
18
- import com.facebook.react.views.view.ReactViewGroup
19
- import droom.daro.core.adunit.DaroNativeAdUnit
20
- import droom.daro.core.model.DaroAdInfo
21
- import droom.daro.core.model.DaroAdLoadError
22
- import droom.daro.core.model.DaroNativeAdBinder
23
- import droom.daro.core.model.DaroViewAd
24
- import droom.daro.view.DaroAdViewListener
25
- import droom.daro.view.DaroNativeAdView
26
- import kotlin.math.min
27
- import kotlin.math.roundToInt
28
-
29
-
30
- @SuppressLint("ViewConstructor")
31
- class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(context),
32
- DaroAdViewListener {
33
-
34
- private val adViewContainer: ReactViewGroup = ReactViewGroup(context)
35
-
36
- init {
37
- post {
38
- setOnClickListener {
39
- adView?.performClick()
40
- }
41
- }
42
- }
43
-
44
- private var adView: DaroNativeAdView? = null
45
-
46
- internal var adUnitId: String = ""
47
-
48
- internal var loadOnMount: Boolean = true
49
-
50
- private var isFirstLoad: Boolean = true
51
-
52
- fun loadAd() {
53
- (adView ?: buildAdView())?.apply {
54
-
55
- adView = this
56
-
57
- if (this.parent == null) {
58
- this@DaroMAdNativeViewContainer.addView(this)
59
- }
60
-
61
- loadAd()
62
- }
63
- }
64
-
65
- internal fun applyPrevSetting() {
66
- if(adView!= null && adView!!.parent == null) addView(adView)
67
- }
68
-
69
- private fun buildAdView(): DaroNativeAdView? {
70
- if (adUnitId.isEmpty()) {
71
- return null
72
- }
73
-
74
- return DaroNativeAdView(
75
- context,
76
- DaroNativeAdUnit(
77
- key = adUnitId,
78
- placement = adUnitId,
79
- )
80
- ).also { view ->
81
- view.setAdBinder(
82
- DaroNativeAdBinder
83
- .Builder(adViewContainer)
84
- .let { if (titleViewId != null) it.setTitleViewId(titleViewId!!) else it }
85
- .let { if (bodyViewId != null) it.setBodyTextViewId(bodyViewId!!) else it }
86
- .let { if (iconViewId != null) it.setIconViewId(iconViewId!!) else it }
87
- .let { if (mediaViewId != null) it.setMediaViewGroupId(mediaViewId!!) else it }
88
- .let { if (callToActionViewId != null) it.setCallToActionViewId(callToActionViewId!!) else it }
89
- .build()
90
- )
91
-
92
- view.setListener(this)
93
- view.setOnHierarchyChangeListener(
94
- object : OnHierarchyChangeListener {
95
- override fun onChildViewAdded(parent: View?, child: View?) {
96
- if (child != null && parent != null) {
97
- view.layoutParams = LayoutParams(
98
- LayoutParams.WRAP_CONTENT,
99
- LayoutParams.WRAP_CONTENT,
100
- )
101
- view.layout(0, 0, parent.width, parent.height)
102
- }
103
- }
104
-
105
- override fun onChildViewRemoved(parent: View?, child: View?) {}
106
- }
107
- )
108
- }
109
- }
110
-
111
- fun destroy() {
112
- adView?.destroy()
113
- }
114
-
115
- override fun onAdLoadSuccess(
116
- ad: DaroViewAd,
117
- adInfo: DaroAdInfo,
118
- ) {
119
- sendNativeViewEvent(
120
- reactContext = context,
121
- event = AdViewEvent.ON_AD_LOADED,
122
- params = AdInfoUtil.getAdInfo(adUnitId, adInfo)
123
- )
124
-
125
- post({
126
- context.currentActivity?.window.let { window ->
127
- window?.decorView?.requestLayout()
128
- }
129
- })
130
- }
131
-
132
- override fun onAdLoadFail(err: DaroAdLoadError) {
133
- sendNativeViewEvent(
134
- reactContext = context,
135
- event = AdViewEvent.ON_AD_FAILED_TO_LOAD,
136
- params = AdInfoUtil.getAdLoadFailedInfo(adUnitId, err)
137
- )
138
- }
139
-
140
- override fun onAdClicked(adInfo: DaroAdInfo) {
141
- sendNativeViewEvent(
142
- reactContext = context,
143
- event = AdViewEvent.ON_AD_CLICKED,
144
- params = AdInfoUtil.getAdInfo(adUnitId, adInfo)
145
- )
146
- }
147
-
148
- override fun onAdImpression(adInfo: DaroAdInfo) {
149
- sendNativeViewEvent(
150
- reactContext = context,
151
- event = AdViewEvent.ON_AD_IMPRESSION,
152
- params = AdInfoUtil.getAdInfo(adUnitId, adInfo)
153
- )
154
- }
155
-
156
- private val loadAdHandler = Handler(Looper.getMainLooper())
157
- private val loadAdTask = LoadAdTask(this)
158
-
159
- private inner class LoadAdTask(private val nativeAdView: DaroMAdNativeViewContainer) :
160
- Runnable {
161
-
162
- override fun run() {
163
- nativeAdView.loadAd()
164
- nativeAdView.isFirstLoad = false
165
- }
166
- }
167
-
168
- internal fun onSetProps() {
169
- if (loadOnMount && isFirstLoad) {
170
- loadAdHandler.removeCallbacksAndMessages(null)
171
- loadAdHandler.postDelayed(loadAdTask, 50)
172
- }
173
- }
174
-
175
- override fun requestLayout() {
176
- super.requestLayout()
177
-
178
- // https://stackoverflow.com/a/39838774/5477988
179
- // This is required to ensure ad refreshes render correctly in RN Android due to known issue
180
- // where `getWidth()` and `getHeight()` return 0 on attach
181
- try {
182
- adView?.measure(
183
- MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
184
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
185
- )
186
-
187
- adView?.layout(0, 0, width, height)
188
-
189
- adViewContainer.parent?.let {
190
- (it as ViewGroup).children.filter { it != adViewContainer && it is ViewGroup }.lastOrNull()
191
- ?.let {
192
- it.measure(
193
- MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
194
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
195
- )
196
-
197
- it.layout(0, 0, width, height)
198
-
199
- findImageView(it as ViewGroup)?.let { adChoiceImageView ->
200
- if ((adChoiceImageView.parent as View).measuredWidth == adChoiceImageView.measuredWidth) return@let
201
-
202
- val ratio =
203
- adChoiceImageView.drawable.intrinsicHeight.toFloat() / (adChoiceImageView.parent as View).height
204
-
205
- val w = ((adChoiceImageView.parent as View).width * ratio).roundToInt()
206
- val h = ((adChoiceImageView.parent as View).height * ratio).roundToInt()
207
-
208
- it.measure(
209
- MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY),
210
- MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY)
211
- )
212
-
213
- it.layout(width - w, 0, width, height)
214
-
215
- (adChoiceImageView.parent as View).let { v ->
216
- v.measure(
217
- MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY),
218
- MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY)
219
- )
220
-
221
- v.layout(0, 0, w, h)
222
- }
223
- }
224
- }
225
- }
226
-
227
- mediaViewId?.let { adViewContainer.findViewById<View>(it) }?.let {
228
- (it as ViewGroup).children.forEach { child ->
229
- val width = it.width
230
- val height = it.height
231
-
232
- child.measure(
233
- MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
234
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
235
- )
236
-
237
- child.layout(0, 0, width, height)
238
- }
239
- }
240
-
241
- titleViewId?.let { adViewContainer.findViewById<ReactTextView>(it) }
242
- ?.restoreSpannableFromMap()
243
- bodyViewId?.let { adViewContainer.findViewById<ReactTextView>(it) }?.restoreSpannableFromMap()
244
- callToActionViewId?.let { adViewContainer.findViewById<ReactTextView>(it) }
245
- ?.restoreSpannableFromMap()
246
-
247
- } catch (_: Exception) {
248
- // Ignore
249
- }
250
- }
251
-
252
- private fun findImageView(root: ViewGroup): ImageView? {
253
- for (i in 0 until root.childCount) {
254
- val child = root.getChildAt(i)
255
- if (child is ImageView) {
256
- return child
257
- } else if (child is ViewGroup) {
258
- val result = findImageView(child)
259
- if (result != null) return result
260
- }
261
- }
262
- return null
263
- }
264
-
265
- /*
266
- * Mapping View
267
- * */
268
-
269
- @IdRes
270
- private var titleViewId: Int? = null
271
-
272
- @IdRes
273
- private var bodyViewId: Int? = null
274
-
275
- @IdRes
276
- private var callToActionViewId: Int? = null
277
-
278
- @IdRes
279
- private var iconViewId: Int? = null
280
-
281
- @IdRes
282
- private var mediaViewId: Int? = null
283
-
284
- fun setTitleView(tag: Int) {
285
- if (titleViewId != null) return
286
-
287
- this.titleViewId = tag
288
- findViewById<ReactTextView>(tag)?.let {
289
- it.moveViewsToAdViewContainer()
290
- it.saveSpannableToMap()
291
- }
292
- }
293
-
294
- fun setBodyView(tag: Int) {
295
- if (bodyViewId != null) return
296
-
297
- this.bodyViewId = tag
298
- findViewById<ReactTextView>(tag)?.let {
299
- it.moveViewsToAdViewContainer()
300
- it.saveSpannableToMap()
301
- }
302
- }
303
-
304
- fun setCallToActionView(tag: Int) {
305
- if (callToActionViewId != null) return
306
-
307
- this.callToActionViewId = tag
308
- findViewById<ReactTextView>(tag)?.let {
309
- it.moveViewsToAdViewContainer()
310
- it.saveSpannableToMap()
311
- }
312
- }
313
-
314
- fun setIconView(tag: Int) {
315
- if (iconViewId != null) return
316
-
317
- this.iconViewId = tag
318
- findViewById<View>(tag)?.moveViewsToAdViewContainer()
319
- }
320
-
321
- fun setMediaView(tag: Int) {
322
- if (mediaViewId != null) return
323
-
324
- this.mediaViewId = tag
325
- findViewById<View>(tag)?.moveViewsToAdViewContainer()
326
- }
327
-
328
- /*
329
- * Setting View
330
- * */
331
-
332
- private fun View.moveViewsToAdViewContainer() {
333
- val layoutParams = layoutParams
334
-
335
- (this.parent as? ViewGroup)?.removeView(this)
336
- adViewContainer.addView(this, layoutParams)
337
- }
338
-
339
- private val testSpanMap: MutableMap<Int, Spanned> = mutableMapOf()
340
-
341
- private fun ReactTextView.saveSpannableToMap() {
342
- val text: CharSequence? = getText()
343
-
344
- if (text is Spanned) {
345
- testSpanMap[id] = text
346
- }
347
- }
348
-
349
- private fun ReactTextView.restoreSpannableFromMap() {
350
- testSpanMap[id]?.let {
351
- val newSpannable = replaceTextPreserveSpans(it, text.toString())
352
- text = newSpannable
353
- }
354
- }
355
-
356
- fun replaceTextPreserveSpans(oldSpanned: Spanned, newText: String): SpannableString {
357
- val newSpannable = SpannableString(newText)
358
-
359
- val spans = oldSpanned.getSpans<Any>(0, oldSpanned.length, Any::class.java)
360
- for (span in spans) {
361
- val start = oldSpanned.getSpanStart(span)
362
- val end = oldSpanned.getSpanEnd(span)
363
- val flags = oldSpanned.getSpanFlags(span)
364
-
365
- val newStart = start.coerceAtMost(newText.length)
366
- val newEnd = if (end == oldSpanned.length) newText.length else min(end, newText.length)
367
-
368
- if (newStart < newEnd) {
369
- newSpannable.setSpan(span, newStart, newEnd, flags)
370
- }
371
- }
372
-
373
- return newSpannable
374
- }
375
- }
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <LinearLayout
3
- xmlns:android="http://schemas.android.com/apk/res/android"
4
- android:layout_width="match_parent"
5
- android:layout_height="match_parent"
6
- android:orientation="vertical">
7
- </LinearLayout>
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
- <style name="Theme.TransparentActivity" parent="Theme.AppCompat.NoActionBar">
4
- <item name="android:windowBackground">@android:color/transparent</item>
5
- <item name="android:windowIsTranslucent">true</item>
6
- <item name="android:windowNoTitle">true</item>
7
- <item name="android:statusBarColor">@android:color/transparent</item> <!-- 상태 바 투명 -->
8
- <item name="android:windowDrawsSystemBarBackgrounds">true</item>
9
- <item name="android:fitsSystemWindows">true</item>
10
- </style>
11
- </resources>
@@ -1,6 +0,0 @@
1
- #import <React/RCTViewManager.h>
2
- #import <React/RCTBridgeModule.h>
3
- #import <React/RCTEventEmitter.h>
4
- #import <React/RCTUIManager.h>
5
- #import <React/RCTImageView.h>
6
- #import <React/RCTTextView.h>
@@ -1,91 +0,0 @@
1
- import Daro
2
-
3
- @objc(DaroMAdBannerViewManager)
4
- class DaroMAdBannerViewManager: RCTViewManager {
5
- override func view() -> DaroMAdBannerView {
6
- DaroMAdBannerView()
7
- }
8
-
9
- @objc override static func requiresMainQueueSetup() -> Bool {
10
- false
11
- }
12
- }
13
-
14
- final class DaroMAdBannerView: UIView {
15
-
16
- var adBannerView: DaroAdBannerView?
17
-
18
- @objc var adUnitId: String?
19
- @objc var adFormat: String = DaroMModule.Constants.bannerAdFormatLabel.value
20
-
21
- // MARK: - Events
22
- @objc var onAdLoadedEvent: RCTDirectEventBlock?
23
- @objc var onAdLoadFailedEvent: RCTDirectEventBlock?
24
- @objc var onAdClickedEvent: RCTDirectEventBlock?
25
- @objc var onAdImpressionRecordedEvent: RCTDirectEventBlock?
26
-
27
- init() {
28
- super.init(frame: CGRect.zero)
29
- }
30
-
31
- required init?(coder: NSCoder) {
32
- fatalError("init(coder:) has not been implemented")
33
- }
34
-
35
- /// Invoked after all the JavaScript properties are set when mounting AdView
36
- override func didSetProps(_ changedProps: [String]!) {
37
- initialize()
38
- adBannerView?.loadAd()
39
- }
40
-
41
- @objc
42
- func loadAd() {
43
- adBannerView?.loadAd()
44
- }
45
-
46
- @objc(initialize)
47
- func initialize() {
48
- guard adBannerView == nil else {
49
- DaroMModule.logger.warning("AdView is already initialized")
50
- return
51
- }
52
- guard let adUnitId else {
53
- DaroMModule.logger.warning("AdUnitId is required")
54
- return
55
- }
56
-
57
- let bannerSize = adFormat == DaroMModule.Constants.bannerAdFormatLabel.value ? DaroAdBannerSize.banner : DaroAdBannerSize.MREC
58
- let adUnit = DaroAdUnit(unitId: adUnitId)
59
- let adBannerView = DaroAdBannerView(unit: adUnit, bannerSize: bannerSize)
60
- setupBannerListener(for: adBannerView)
61
-
62
- adBannerView.translatesAutoresizingMaskIntoConstraints = false
63
- addSubview(adBannerView)
64
- self.adBannerView = adBannerView
65
-
66
- NSLayoutConstraint.activate([
67
- adBannerView.widthAnchor.constraint(equalToConstant: bannerSize.width),
68
- adBannerView.heightAnchor.constraint(equalToConstant: bannerSize.height),
69
- adBannerView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
70
- adBannerView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
71
- ])
72
- }
73
-
74
- private func setupBannerListener(for bannerView: DaroAdBannerView) {
75
- bannerView.listener.onAdLoadSuccess = { [weak self] ad, adInfo in
76
- self?.onAdLoadedEvent?(adInfo?.toBody)
77
- }
78
-
79
- bannerView.listener.onAdLoadFail = { [weak self] error in
80
- self?.onAdLoadFailedEvent?(error.toBody)
81
- }
82
-
83
- bannerView.listener.onAdImpression = { [weak self] adInfo in
84
- self?.onAdImpressionRecordedEvent?(adInfo?.toBody)
85
- }
86
-
87
- bannerView.listener.onAdClicked = { [weak self] adInfo in
88
- self?.onAdClickedEvent?(adInfo?.toBody)
89
- }
90
- }
91
- }