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.
- package/LICENSE +1 -1
- package/README.md +30 -30
- package/android/build.gradle +52 -59
- package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +23 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/{darom → daro/reactnative}/DaroMAdBannerViewManager.kt +38 -15
- package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +167 -0
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +257 -0
- package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +45 -0
- package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
- package/android/src/main/java/com/{darom → daro/reactnative}/constants/InternalDaroMBannerSize.kt +1 -1
- package/android/src/main/java/com/{darom → daro/reactnative}/event/DaroMEvent.kt +19 -8
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMBannerViewModuleImpl.kt +2 -2
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMInterstitialModuleImpl.kt +26 -26
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMLightPopupModuleImpl.kt +30 -29
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMRewardedAdModuleImpl.kt +27 -27
- package/android/src/main/java/com/{darom → daro/reactnative}/util/AdInfoUtil.kt +25 -1
- package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +37 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdBannerViewContainer.kt +417 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +624 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
- package/android/src/newarch/java/com/daro/reactnative/DaroMModuleSpec.kt +6 -0
- package/android/src/oldarch/java/com/daro/reactnative/DaroMModuleSpec.kt +90 -0
- package/app.plugin.js +1 -0
- package/ios/DaroMModule+AppOpen.swift +38 -32
- package/ios/DaroMModule+Interstitial.swift +32 -26
- package/ios/DaroMModule+LightPopup.swift +43 -33
- package/ios/DaroMModule+Rewarded.swift +38 -27
- package/ios/DaroMModule.mm +45 -17
- package/ios/DaroMModule.swift +24 -17
- package/ios/Fabric/DaroMAdBannerComponentView.mm +207 -0
- package/ios/Fabric/DaroMFabricEventSink.mm +31 -0
- package/ios/Fabric/DaroMFabricPropApplier.mm +123 -0
- package/ios/Fabric/DaroMNativeAdComponentView.mm +294 -0
- package/ios/{DaroMAdBannerViewManager.m → Paper/DaroMAdBannerViewManager.m} +3 -1
- package/ios/Paper/DaroMAdBannerViewManager.swift +21 -0
- package/ios/{DaroMNativeAdViewManager.m → Paper/DaroMNativeAdViewManager.m} +2 -1
- package/ios/Paper/DaroMNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMAdEventSink.swift +24 -0
- package/ios/Shared/DaroMBannerAdView.swift +188 -0
- package/ios/Shared/DaroMNativeAdLoadCoordinator.swift +49 -0
- package/ios/Shared/DaroMNativeAdView.swift +575 -0
- package/ios/Shared/DaroMNativeAssetResolver.swift +53 -0
- package/ios/mediation/admob/DaroMediationDebugger.swift +11 -0
- package/ios/mediation/admob/DaroMediationTypes.swift +23 -0
- package/lib/commonjs/AdBannerView.js +21 -35
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +80 -21
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/lib/commonjs/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/commonjs/ErrorCode.js.map +1 -1
- package/lib/commonjs/EventEmitter.js +4 -5
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/InterstitialAd.js +48 -22
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/LightPopupAd.js +64 -46
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js +9 -0
- package/lib/commonjs/NativeDaroModule.js.map +1 -0
- package/lib/commonjs/RewardedAd.js +47 -23
- package/lib/commonjs/RewardedAd.js.map +1 -1
- package/lib/commonjs/codegen-env.d.js +2 -0
- package/lib/commonjs/codegen-env.d.js.map +1 -0
- package/lib/commonjs/hooks/useInterstitialAd.js +110 -0
- package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
- package/lib/commonjs/hooks/useLightPopupAd.js +114 -0
- package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedAd.js +113 -0
- package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
- package/lib/commonjs/index.js +29 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +23 -18
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js +43 -31
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js +34 -7
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/module/AdBannerView.js +20 -36
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +80 -22
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/lib/module/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/module/ErrorCode.js.map +1 -1
- package/lib/module/EventEmitter.js +4 -6
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/InterstitialAd.js +47 -22
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/LightPopupAd.js +65 -47
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js +5 -0
- package/lib/module/NativeDaroModule.js.map +1 -0
- package/lib/module/RewardedAd.js +46 -23
- package/lib/module/RewardedAd.js.map +1 -1
- package/lib/module/codegen-env.d.js +2 -0
- package/lib/module/codegen-env.d.js.map +1 -0
- package/lib/module/hooks/useInterstitialAd.js +106 -0
- package/lib/module/hooks/useInterstitialAd.js.map +1 -0
- package/lib/module/hooks/useLightPopupAd.js +110 -0
- package/lib/module/hooks/useLightPopupAd.js.map +1 -0
- package/lib/module/hooks/useRewardedAd.js +109 -0
- package/lib/module/hooks/useRewardedAd.js.map +1 -0
- package/lib/module/index.js +7 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +22 -19
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewComponents.js +45 -34
- package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewProvider.js +35 -8
- package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/plugin/src/index.d.ts +19 -0
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts +6 -0
- package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +8 -0
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts +8 -0
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +126 -4
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +61 -0
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +19 -0
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +23 -0
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +20 -0
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +7 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +125 -2
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts +19 -0
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts +6 -0
- package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/withAndroid.d.ts +8 -0
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/withIos.d.ts +8 -0
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -0
- package/lib/typescript/module/src/AdBannerView.d.ts +126 -4
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AppOpenAd.d.ts +6 -0
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/module/src/InterstitialAd.d.ts +6 -0
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/module/src/LightPopupAd.d.ts +6 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts +61 -0
- package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -0
- package/lib/typescript/module/src/RewardedAd.d.ts +6 -0
- package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +19 -0
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +23 -0
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +20 -0
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +7 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +125 -2
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +2 -2
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts +2 -2
- package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +95 -105
- package/plugin/build/index.d.ts +18 -0
- package/plugin/build/index.js +71 -0
- package/plugin/build/skAdNetworkIds.d.ts +5 -0
- package/plugin/build/skAdNetworkIds.js +205 -0
- package/plugin/build/withAndroid.d.ts +7 -0
- package/plugin/build/withAndroid.js +222 -0
- package/plugin/build/withIos.d.ts +7 -0
- package/plugin/build/withIos.js +82 -0
- package/react-native-daro.podspec +28 -0
- package/src/AdBannerView.tsx +48 -48
- package/src/AppOpenAd.ts +101 -20
- package/src/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/src/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/src/DaroMediaViewNativeComponent.ts +9 -0
- package/src/ErrorCode.ts +1 -2
- package/src/EventEmitter.ts +9 -7
- package/src/InterstitialAd.ts +75 -21
- package/src/LightPopupAd.ts +90 -51
- package/src/NativeDaroModule.ts +91 -0
- package/src/RewardedAd.ts +72 -22
- package/src/codegen-env.d.ts +45 -0
- package/src/hooks/useInterstitialAd.ts +117 -0
- package/src/hooks/useLightPopupAd.ts +132 -0
- package/src/hooks/useRewardedAd.ts +122 -0
- package/src/index.tsx +21 -22
- package/src/nativeAd/NativeAdView.tsx +83 -45
- package/src/nativeAd/NativeAdViewComponents.tsx +129 -64
- package/src/nativeAd/NativeAdViewProvider.tsx +84 -16
- package/src/types/AdBannerViewProps.ts +11 -11
- package/src/types/AdInfo.ts +17 -17
- package/src/types/AdProps.ts +8 -9
- package/src/types/DaroMMobileAds.ts +3 -6
- package/src/types/NativeAdViewProps.ts +12 -5
- package/src/types/index.ts +1 -1
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifestNew.xml +0 -7
- package/android/src/main/java/com/darom/DaroMAdNativeViewManager.kt +0 -136
- package/android/src/main/java/com/darom/DaroMModule.kt +0 -203
- package/android/src/main/java/com/darom/DaroMPackage.kt +0 -21
- package/android/src/main/java/com/darom/util/EventEmitterUtil.kt +0 -24
- package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +0 -163
- package/android/src/main/java/com/darom/view/DaroMAdNativeViewContainer.kt +0 -375
- package/android/src/main/res/layout/layout_activity_transparent.xml +0 -7
- package/android/src/main/res/values/styles.xml +0 -11
- package/ios/DaroM-Bridging-Header.h +0 -6
- package/ios/DaroMAdBannerViewManager.swift +0 -91
- package/ios/DaroMNativeAdViewManager.swift +0 -291
- 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,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,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
|
-
}
|