emi-indo-cordova-plugin-admob 2.0.6 → 2.0.8
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/README.md +201 -52
- package/example/capacitor.config.json +1 -1
- package/example/config.xml +7 -0
- package/example/package.json +1 -1
- package/example/www/css/index.css +0 -0
- package/example/www/js/bannerAd.js +9 -68
- package/example/www/js/deviceready.js +1 -1
- package/example/www/js/interstitialAd.js +0 -2
- package/example/www/js/optionalFirebaseAnalytics.js +0 -2
- package/example/www/js/rewardedAd.js +0 -2
- package/package.json +1 -1
- package/plugin.xml +7 -9
- package/src/android/emiAdmobPlugin.kt +287 -265
- package/src/ios/emiAdmobPlugin.m +24 -5
- package/www/emiAdmobPlugin.js +1 -1
- package/.gitattributes +0 -2
- package/.github/FUNDING.yml +0 -13
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -127
@@ -15,6 +15,7 @@ import android.view.Gravity
|
|
15
15
|
import android.view.View
|
16
16
|
import android.view.ViewGroup
|
17
17
|
import android.view.WindowInsets
|
18
|
+
import android.view.WindowManager
|
18
19
|
import android.webkit.WebView
|
19
20
|
import android.widget.FrameLayout
|
20
21
|
import androidx.preference.PreferenceManager
|
@@ -51,7 +52,6 @@ import kotlinx.coroutines.CoroutineScope
|
|
51
52
|
import kotlinx.coroutines.Dispatchers
|
52
53
|
import kotlinx.coroutines.launch
|
53
54
|
import org.apache.cordova.CallbackContext
|
54
|
-
import org.apache.cordova.CordovaInterface
|
55
55
|
import org.apache.cordova.CordovaPlugin
|
56
56
|
import org.apache.cordova.CordovaWebView
|
57
57
|
import org.json.JSONArray
|
@@ -96,20 +96,20 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
96
96
|
private var isStatusBarShow: Boolean = true
|
97
97
|
|
98
98
|
var adType = ""
|
99
|
+
private var bannerViewHeight: Int = 0
|
99
100
|
|
100
101
|
var isBannerLoad: Boolean = false
|
101
102
|
var isBannerShow: Boolean = false
|
102
103
|
|
103
104
|
var isBannerShows: Boolean = true
|
104
105
|
private var bannerAutoShow = false
|
105
|
-
|
106
|
+
// private var isAutoResize: Boolean = false
|
106
107
|
|
107
108
|
|
108
109
|
var appOpenAutoShow: Boolean = false
|
109
110
|
var intAutoShow: Boolean = false
|
110
111
|
var rewardedAutoShow: Boolean = false
|
111
112
|
var rIntAutoShow: Boolean = false
|
112
|
-
private var isCollapsible: Boolean = false
|
113
113
|
var lock: Boolean = true
|
114
114
|
private var setDebugGeography: Boolean = false
|
115
115
|
|
@@ -119,7 +119,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
119
119
|
|
120
120
|
private var mPreferences: SharedPreferences? = null
|
121
121
|
var mBundleExtra: Bundle? = null
|
122
|
-
private var collapsiblePos: String? =
|
122
|
+
private var collapsiblePos: String? = ""
|
123
123
|
|
124
124
|
// only isUsingAdManagerRequest = true
|
125
125
|
private var customTargetingEnabled: Boolean = false
|
@@ -151,84 +151,45 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
151
151
|
private var mContext: Context? = null
|
152
152
|
|
153
153
|
|
154
|
-
|
155
|
-
|
154
|
+
private var isFullScreen: Boolean = false
|
155
|
+
// private var bannerOverlapping: Boolean = false
|
156
|
+
|
157
|
+
override fun pluginInitialize() {
|
158
|
+
super.pluginInitialize()
|
156
159
|
|
157
160
|
cWebView = webView
|
158
161
|
mActivity = cordova.activity
|
159
162
|
|
160
163
|
if (mActivity != null) {
|
161
|
-
|
162
164
|
mContext = mActivity?.applicationContext
|
163
|
-
|
164
165
|
mPreferences = mContext?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
165
|
-
|
166
166
|
} else {
|
167
167
|
Log.e("PluginCordova", "Activity is null during initialization")
|
168
168
|
}
|
169
169
|
}
|
170
170
|
|
171
171
|
|
172
|
-
|
173
|
-
|
174
172
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
175
173
|
super.onConfigurationChanged(newConfig)
|
176
174
|
val orientation = newConfig.orientation
|
177
175
|
if (orientation != isOrientation) {
|
178
176
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.screen.rotated');")
|
179
177
|
isOrientation = orientation
|
180
|
-
if (this.isAutoResize) {
|
181
|
-
if(mActivity != null) {
|
182
|
-
mActivity?.runOnUiThread {
|
183
|
-
try {
|
184
|
-
bannerOverlappingToZero()
|
185
|
-
if (bannerViewLayout != null && bannerView != null) {
|
186
|
-
val parentView = bannerViewLayout?.parent as ViewGroup
|
187
|
-
parentView.removeView(bannerViewLayout)
|
188
|
-
bannerViewLayout = FrameLayout(mActivity!!)
|
189
|
-
val params = FrameLayout.LayoutParams(
|
190
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
191
|
-
FrameLayout.LayoutParams.WRAP_CONTENT
|
192
|
-
)
|
193
|
-
val decorView = mActivity?.window?.decorView as ViewGroup
|
194
|
-
decorView.addView(bannerViewLayout, params)
|
195
|
-
bannerView = AdView(mActivity!!)
|
196
|
-
setBannerPosition(this.isPosition)
|
197
|
-
setBannerSize(this.isSize)
|
198
|
-
bannerView?.adUnitId = bannerAdUnitId!!
|
199
|
-
bannerView?.adListener = bannerAdListener
|
200
|
-
bannerView?.loadAd(buildAdRequest())
|
201
|
-
bannerViewLayout?.addView(bannerView)
|
202
|
-
bannerViewLayout?.bringToFront()
|
203
|
-
bannerViewLayout?.requestFocus();
|
204
|
-
bannerOverlappingToZero()
|
205
|
-
}
|
206
|
-
} catch (e: Exception) {
|
207
|
-
PUBLIC_CALLBACKS?.error("Error adjusting banner size: " + e.message)
|
208
|
-
}
|
209
|
-
}
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
178
|
when (orientation) {
|
214
179
|
Configuration.ORIENTATION_PORTRAIT -> {
|
215
|
-
if (isOverlapping) {
|
216
|
-
bannerOverlapping()
|
217
|
-
}
|
218
180
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.portrait');")
|
219
181
|
}
|
220
182
|
Configuration.ORIENTATION_LANDSCAPE -> {
|
221
|
-
if (isOverlapping) {
|
222
|
-
bannerOverlapping()
|
223
|
-
}
|
224
183
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.landscape');")
|
225
184
|
}
|
226
185
|
Configuration.ORIENTATION_UNDEFINED -> {
|
227
186
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.undefined');")
|
228
187
|
}
|
229
|
-
|
230
|
-
|
188
|
+
else -> {
|
189
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.square');")
|
190
|
+
}
|
231
191
|
}
|
192
|
+
|
232
193
|
}
|
233
194
|
}
|
234
195
|
|
@@ -245,7 +206,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
245
206
|
if (action == "initialize") {
|
246
207
|
val options = args.getJSONObject(0)
|
247
208
|
if (mActivity != null) {
|
248
|
-
mActivity
|
209
|
+
mActivity?.runOnUiThread {
|
249
210
|
val setAdRequest = options.optBoolean("isUsingAdManagerRequest")
|
250
211
|
val responseInfo = options.optBoolean("isResponseInfo")
|
251
212
|
val setDebugGeography = options.optBoolean("isConsentDebug")
|
@@ -284,21 +245,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
284
245
|
params,
|
285
246
|
{
|
286
247
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update');")
|
287
|
-
when (consentInformation
|
288
|
-
ConsentInformation.ConsentStatus.NOT_REQUIRED -> cWebView
|
289
|
-
"javascript:cordova.fireDocumentEvent('on.consent.status.not_required');"
|
290
|
-
)
|
248
|
+
when (consentInformation?.getConsentStatus()) {
|
249
|
+
ConsentInformation.ConsentStatus.NOT_REQUIRED -> cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.not_required');")
|
291
250
|
|
292
|
-
ConsentInformation.ConsentStatus.OBTAINED -> cWebView
|
293
|
-
"javascript:cordova.fireDocumentEvent('on.consent.status.obtained');"
|
294
|
-
)
|
251
|
+
ConsentInformation.ConsentStatus.OBTAINED -> cWebView?.loadUrl( "javascript:cordova.fireDocumentEvent('on.consent.status.obtained');")
|
295
252
|
|
296
|
-
ConsentInformation.ConsentStatus.REQUIRED -> {
|
297
|
-
|
298
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');")
|
253
|
+
ConsentInformation.ConsentStatus.REQUIRED -> { handleConsentForm()
|
254
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');")
|
299
255
|
}
|
300
256
|
|
301
|
-
ConsentInformation.ConsentStatus.UNKNOWN -> cWebView
|
257
|
+
ConsentInformation.ConsentStatus.UNKNOWN -> cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.unknown');")
|
302
258
|
}
|
303
259
|
},
|
304
260
|
{ formError: FormError ->
|
@@ -313,8 +269,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
313
269
|
}
|
314
270
|
}
|
315
271
|
}
|
316
|
-
|
317
272
|
return true
|
273
|
+
|
318
274
|
} else if (action == "targeting") {
|
319
275
|
val options = args.getJSONObject(0)
|
320
276
|
if (mActivity != null) {
|
@@ -329,11 +285,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
329
285
|
targeting(childDirectedTreatment, underAgeOfConsent, contentRating)
|
330
286
|
callbackContext.success();
|
331
287
|
} catch (e: Exception) {
|
332
|
-
callbackContext.error("Error: " + e.message)
|
288
|
+
callbackContext.error("targeting Error: " + e.message)
|
333
289
|
}
|
334
290
|
}
|
335
291
|
}
|
336
292
|
return true
|
293
|
+
|
337
294
|
} else if (action == "targetingAdRequest") {
|
338
295
|
val options = args.getJSONObject(0)
|
339
296
|
if (mActivity != null) {
|
@@ -358,20 +315,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
358
315
|
this.cExclusionsValue = categoryExclusions
|
359
316
|
this.ppIdVl = ppId
|
360
317
|
this.cURLVl = ctURL
|
361
|
-
targetingAdRequest(
|
362
|
-
customTargeting,
|
363
|
-
categoryExclusions,
|
364
|
-
ppId,
|
365
|
-
ctURL,
|
366
|
-
brandSafetyArr
|
367
|
-
)
|
318
|
+
targetingAdRequest( customTargeting, categoryExclusions, ppId, ctURL, brandSafetyArr)
|
368
319
|
callbackContext.success()
|
369
320
|
} catch (e: Exception) {
|
370
|
-
callbackContext.error(e.
|
321
|
+
callbackContext.error("targetingAdRequest Error: " + e.message)
|
371
322
|
}
|
372
323
|
}
|
373
324
|
}
|
374
325
|
return true
|
326
|
+
|
375
327
|
} else if (action == "setPersonalizationState") {
|
376
328
|
val options = args.getJSONObject(0)
|
377
329
|
if (mActivity != null) {
|
@@ -381,11 +333,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
381
333
|
setPersonalizationState(setPPT)
|
382
334
|
callbackContext.success()
|
383
335
|
} catch (e: Exception) {
|
384
|
-
callbackContext.error(e.
|
336
|
+
callbackContext.error("setPersonalizationState Error: " + e.message)
|
385
337
|
}
|
386
338
|
}
|
387
339
|
}
|
388
340
|
return true
|
341
|
+
|
389
342
|
} else if (action == "setPPS") {
|
390
343
|
val options = args.getJSONObject(0)
|
391
344
|
if (mActivity != null) {
|
@@ -399,11 +352,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
399
352
|
setPublisherProvidedSignals(ppsArrValue)
|
400
353
|
callbackContext.success()
|
401
354
|
} catch (e: Exception) {
|
402
|
-
callbackContext.error(e.
|
355
|
+
callbackContext.error("setPPS Error: " + e.message)
|
403
356
|
}
|
404
357
|
}
|
405
358
|
}
|
406
359
|
return true
|
360
|
+
|
407
361
|
} else if (action == "globalSettings") {
|
408
362
|
val options = args.getJSONObject(0)
|
409
363
|
if (mActivity != null) {
|
@@ -414,11 +368,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
414
368
|
try {
|
415
369
|
globalSettings(setAppMuted, setAppVolume, pubIdEnabled)
|
416
370
|
} catch (e: Exception) {
|
417
|
-
callbackContext.error(e.
|
371
|
+
callbackContext.error("globalSettings Error: " + e.message)
|
418
372
|
}
|
419
373
|
}
|
420
374
|
}
|
421
375
|
return true
|
376
|
+
|
422
377
|
} else if (action == "loadAppOpenAd") {
|
423
378
|
val options = args.getJSONObject(0)
|
424
379
|
if (mActivity != null) {
|
@@ -462,7 +417,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
462
417
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.revenue', ${result})")
|
463
418
|
|
464
419
|
} catch (e: JSONException) {
|
465
|
-
callbackContext.error(e.message)
|
420
|
+
callbackContext.error("loadAppOpenAd Error: " + e.message)
|
466
421
|
}
|
467
422
|
}
|
468
423
|
|
@@ -478,7 +433,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
478
433
|
result.put("getBundleExtra", mBundleExtra.toString())
|
479
434
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.responseInfo', ${result})")
|
480
435
|
} catch (e: JSONException) {
|
481
|
-
callbackContext.error(e.message)
|
436
|
+
callbackContext.error("loadAppOpenAd Error: " + e.message)
|
482
437
|
}
|
483
438
|
|
484
439
|
|
@@ -497,7 +452,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
497
452
|
}
|
498
453
|
}
|
499
454
|
} catch (e: Exception) {
|
500
|
-
PUBLIC_CALLBACKS?.error(e.
|
455
|
+
PUBLIC_CALLBACKS?.error("loadAppOpenAd Error: " + e.message)
|
501
456
|
}
|
502
457
|
}
|
503
458
|
|
@@ -528,11 +483,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
528
483
|
|
529
484
|
})
|
530
485
|
} catch (e: Exception) {
|
531
|
-
callbackContext.error(e.
|
486
|
+
callbackContext.error("loadAppOpenAd Error: " + e.message)
|
532
487
|
}
|
533
488
|
}
|
534
489
|
}
|
535
490
|
return true
|
491
|
+
|
536
492
|
} else if (action == "showAppOpenAd") {
|
537
493
|
|
538
494
|
try {
|
@@ -543,7 +499,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
543
499
|
callbackContext.error("The App Open Ad wasn't ready yet")
|
544
500
|
}
|
545
501
|
} catch (e: Exception) {
|
546
|
-
PUBLIC_CALLBACKS
|
502
|
+
PUBLIC_CALLBACKS?.error("showAppOpenAd Error: " + e.message)
|
547
503
|
}
|
548
504
|
|
549
505
|
return true
|
@@ -581,12 +537,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
581
537
|
result.put("getResponseExtras", responseInfo?.responseExtras)
|
582
538
|
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
583
539
|
result.put("getBundleExtra", mBundleExtra.toString())
|
584
|
-
cWebView!!.loadUrl(
|
585
|
-
"javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});"
|
586
|
-
)
|
540
|
+
cWebView!!.loadUrl( "javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});")
|
587
541
|
|
588
542
|
} catch (e: JSONException) {
|
589
|
-
callbackContext.error(e.message)
|
543
|
+
callbackContext.error("loadInterstitialAd Error: " + e.message)
|
590
544
|
}
|
591
545
|
}
|
592
546
|
mInterstitialAd?.onPaidEventListener =
|
@@ -601,12 +555,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
601
555
|
result.put("currency", currencyCode)
|
602
556
|
result.put("precision", precision)
|
603
557
|
result.put("adUnitId", interstitialAdUnitId)
|
604
|
-
cWebView?.loadUrl(
|
605
|
-
"javascript:cordova.fireDocumentEvent('on.interstitial.revenue', ${result});"
|
606
|
-
)
|
558
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.revenue', ${result});")
|
607
559
|
|
608
560
|
} catch (e: JSONException) {
|
609
|
-
callbackContext.error(e.message)
|
561
|
+
callbackContext.error("loadInterstitialAd Error: " + e.message)
|
610
562
|
}
|
611
563
|
|
612
564
|
}
|
@@ -646,18 +598,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
646
598
|
put("responseInfoAdapterResponses", adapterResponses)
|
647
599
|
}
|
648
600
|
|
649
|
-
cWebView?.loadUrl(
|
650
|
-
"javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
|
651
|
-
)
|
601
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});")
|
652
602
|
|
653
603
|
}
|
654
604
|
})
|
655
605
|
} catch (e: Exception) {
|
656
|
-
callbackContext.error(e.
|
606
|
+
callbackContext.error("loadInterstitialAd Error: " + e.message)
|
657
607
|
}
|
658
608
|
}
|
659
609
|
}
|
660
610
|
return true
|
611
|
+
|
661
612
|
} else if (action == "showInterstitialAd") {
|
662
613
|
|
663
614
|
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
@@ -703,9 +654,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
703
654
|
|
704
655
|
}
|
705
656
|
|
706
|
-
cWebView?.loadUrl(
|
707
|
-
"javascript:cordova.fireDocumentEvent('on.rewarded.failed.load', ${errorData});"
|
708
|
-
)
|
657
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.load', ${errorData});")
|
709
658
|
|
710
659
|
}
|
711
660
|
|
@@ -720,9 +669,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
720
669
|
|
721
670
|
rewardedAdLoadCallback()
|
722
671
|
|
723
|
-
cWebView?.loadUrl(
|
724
|
-
"javascript:cordova.fireDocumentEvent('on.rewarded.loaded');"
|
725
|
-
)
|
672
|
+
cWebView?.loadUrl( "javascript:cordova.fireDocumentEvent('on.rewarded.loaded');")
|
726
673
|
|
727
674
|
rewardedAd?.onPaidEventListener =
|
728
675
|
OnPaidEventListener { adValue: AdValue ->
|
@@ -736,11 +683,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
736
683
|
result.put("currency", currencyCode)
|
737
684
|
result.put("precision", precision)
|
738
685
|
result.put("adUnitId", rewardedAdAdUnitId)
|
739
|
-
cWebView?.loadUrl(
|
740
|
-
"javascript:cordova.fireDocumentEvent('on.rewarded.revenue', ${result});"
|
741
|
-
)
|
686
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.revenue', ${result});")
|
742
687
|
} catch (e: JSONException) {
|
743
|
-
callbackContext.error(e.message)
|
688
|
+
callbackContext.error("loadRewardedAd Error: " + e.message)
|
744
689
|
}
|
745
690
|
|
746
691
|
}
|
@@ -758,7 +703,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
758
703
|
result.put("getBundleExtra", mBundleExtra.toString())
|
759
704
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAd.responseInfo', ${result})")
|
760
705
|
} catch (e: JSONException) {
|
761
|
-
callbackContext.error(e.message)
|
706
|
+
callbackContext.error("loadRewardedAd Error: " + e.message)
|
762
707
|
}
|
763
708
|
}
|
764
709
|
|
@@ -779,11 +724,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
779
724
|
try {
|
780
725
|
result.put("rewardType", rewardType)
|
781
726
|
result.put("rewardAmount", rewardAmount)
|
782
|
-
cWebView?.loadUrl(
|
783
|
-
"javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});"
|
784
|
-
)
|
727
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});")
|
785
728
|
} catch (e: JSONException) {
|
786
|
-
callbackContext.error(e.message)
|
729
|
+
callbackContext.error("loadRewardedAd Error: " + e.message)
|
787
730
|
}
|
788
731
|
|
789
732
|
}
|
@@ -793,11 +736,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
793
736
|
}
|
794
737
|
})
|
795
738
|
} catch (e: Exception) {
|
796
|
-
callbackContext.error(e.
|
739
|
+
callbackContext.error("loadRewardedAd Error: " + e.message)
|
797
740
|
}
|
798
741
|
}
|
799
742
|
}
|
800
743
|
return true
|
744
|
+
|
801
745
|
} else if (action == "showRewardedAd") {
|
802
746
|
if (mActivity != null && isRewardedLoad && rewardedAd != null) {
|
803
747
|
mActivity?.runOnUiThread {
|
@@ -812,7 +756,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
812
756
|
result.put("rewardAmount", rewardAmount)
|
813
757
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});")
|
814
758
|
} catch (e: JSONException) {
|
815
|
-
callbackContext.error(e.message)
|
759
|
+
callbackContext.error("showRewardedAd Error: " + e.message)
|
816
760
|
}
|
817
761
|
|
818
762
|
}
|
@@ -824,6 +768,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
824
768
|
callbackContext.error("The rewarded ad wasn't ready yet")
|
825
769
|
}
|
826
770
|
return true
|
771
|
+
|
827
772
|
} else if (action == "loadRewardedInterstitialAd") {
|
828
773
|
val options = args.getJSONObject(0)
|
829
774
|
if (mActivity != null) {
|
@@ -840,9 +785,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
840
785
|
isRewardedInterstitialLoad = true
|
841
786
|
isAdSkip = 0
|
842
787
|
|
843
|
-
cWebView?.loadUrl(
|
844
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');"
|
845
|
-
)
|
788
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');")
|
846
789
|
|
847
790
|
if (rIntAutoShow) {
|
848
791
|
isRIntAutoShow
|
@@ -862,11 +805,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
862
805
|
result.put("currency", currencyCode)
|
863
806
|
result.put("precision", precision)
|
864
807
|
result.put("adUnitId", rewardedIntAdUnitId)
|
865
|
-
cWebView
|
866
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue', ${result});"
|
867
|
-
)
|
808
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue', ${result});")
|
868
809
|
} catch (e: JSONException) {
|
869
|
-
callbackContext.error(e.message)
|
810
|
+
callbackContext.error("loadRewardedInterstitialAd Error: " + e.message)
|
870
811
|
}
|
871
812
|
|
872
813
|
}
|
@@ -881,11 +822,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
881
822
|
result.put("getResponseExtras", responseInfo?.responseExtras)
|
882
823
|
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
883
824
|
result.put("getBundleExtra", mBundleExtra.toString())
|
884
|
-
cWebView?.loadUrl(
|
885
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedIntAd.responseInfo', ${result});"
|
886
|
-
)
|
825
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedIntAd.responseInfo', ${result});")
|
887
826
|
} catch (e: JSONException) {
|
888
|
-
callbackContext.error(e.message)
|
827
|
+
callbackContext.error("loadRewardedInterstitialAd Error: " + e.message)
|
889
828
|
}
|
890
829
|
}
|
891
830
|
|
@@ -907,11 +846,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
907
846
|
try {
|
908
847
|
result.put("rewardType", rewardType)
|
909
848
|
result.put("rewardAmount", rewardAmount)
|
910
|
-
cWebView?.loadUrl(
|
911
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});"
|
912
|
-
)
|
849
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});")
|
913
850
|
} catch (e: JSONException) {
|
914
|
-
callbackContext.error(e.message)
|
851
|
+
callbackContext.error("loadRewardedInterstitialAd Error: " + e.message)
|
915
852
|
}
|
916
853
|
|
917
854
|
}
|
@@ -941,18 +878,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
941
878
|
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
942
879
|
put("responseInfoAdapterResponses", adapterResponses)
|
943
880
|
}
|
944
|
-
cWebView?.loadUrl(
|
945
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load', ${errorData});"
|
946
|
-
)
|
881
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load', ${errorData});")
|
947
882
|
|
948
883
|
}
|
949
884
|
})
|
950
885
|
} catch (e: Exception) {
|
951
|
-
callbackContext.error(e.
|
886
|
+
callbackContext.error("loadRewardedInterstitialAd Error: " + e.message)
|
952
887
|
}
|
953
888
|
}
|
954
889
|
}
|
955
890
|
return true
|
891
|
+
|
956
892
|
} else if (action == "showRewardedInterstitialAd") {
|
957
893
|
if (mActivity != null) {
|
958
894
|
mActivity?.runOnUiThread {
|
@@ -966,11 +902,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
966
902
|
try {
|
967
903
|
result.put("rewardType", rewardType)
|
968
904
|
result.put("rewardAmount", rewardAmount)
|
969
|
-
cWebView?.loadUrl(
|
970
|
-
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});"
|
971
|
-
)
|
905
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});")
|
972
906
|
} catch (e: JSONException) {
|
973
|
-
callbackContext.error(e.message)
|
907
|
+
callbackContext.error("loadRewardedInterstitialAd Error: " + e.message)
|
974
908
|
}
|
975
909
|
|
976
910
|
}
|
@@ -981,6 +915,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
981
915
|
}
|
982
916
|
}
|
983
917
|
return true
|
918
|
+
|
984
919
|
} else if (action == "showPrivacyOptionsForm") {
|
985
920
|
if (mActivity != null) {
|
986
921
|
mActivity?.runOnUiThread {
|
@@ -1041,18 +976,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1041
976
|
})
|
1042
977
|
}
|
1043
978
|
} catch (e: Exception) {
|
1044
|
-
callbackContext.error(e.
|
979
|
+
callbackContext.error("showPrivacyOptionsForm Error: " + e.message)
|
1045
980
|
}
|
1046
981
|
}
|
1047
982
|
}
|
1048
983
|
return true
|
984
|
+
|
1049
985
|
} else if (action == "consentReset") {
|
1050
986
|
if (mActivity != null) {
|
1051
987
|
mActivity?.runOnUiThread {
|
1052
988
|
try {
|
1053
989
|
consentInformation?.reset()
|
1054
990
|
} catch (e: Exception) {
|
1055
|
-
callbackContext.error(e.
|
991
|
+
callbackContext.error("consentReset Error: " + e.message)
|
1056
992
|
}
|
1057
993
|
}
|
1058
994
|
}
|
@@ -1074,17 +1010,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1074
1010
|
editor.putString("IABTCF_TCString", consentString)
|
1075
1011
|
editor.putLong(LAST_ACCESS_SUFFIX, System.currentTimeMillis())
|
1076
1012
|
editor.apply()
|
1077
|
-
//val key = "IABTCF_TCString"
|
1078
1013
|
getString(consentString.toString())
|
1079
1014
|
callbackContext.success(userInfoJson)
|
1080
1015
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc');")
|
1081
1016
|
} catch (e: Exception) {
|
1082
|
-
callbackContext.error(e.
|
1017
|
+
callbackContext.error("getIabTfc Error: " + e.message)
|
1083
1018
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc.error');")
|
1084
1019
|
}
|
1085
1020
|
}
|
1086
1021
|
}
|
1087
1022
|
return true
|
1023
|
+
|
1088
1024
|
} else if (action == "loadBannerAd") {
|
1089
1025
|
if (mActivity != null) {
|
1090
1026
|
val options = args.getJSONObject(0)
|
@@ -1093,24 +1029,26 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1093
1029
|
val position = options.optString("position")
|
1094
1030
|
val collapsible = options.optString("collapsible")
|
1095
1031
|
val size = options.optString("size")
|
1096
|
-
val autoResize = options.optBoolean("autoResize")
|
1097
1032
|
val autoShow = options.optBoolean("autoShow")
|
1033
|
+
val isOverlapping = options.optBoolean("isOverlapping", false)
|
1034
|
+
val paddingPx = options.optInt("padding")
|
1098
1035
|
this.bannerAdUnitId = adUnitId
|
1099
1036
|
this.isPosition = position
|
1100
1037
|
this.isSize = size
|
1101
1038
|
this.bannerAutoShow = autoShow
|
1102
|
-
this.isAutoResize = autoResize
|
1103
1039
|
this.collapsiblePos = collapsible
|
1040
|
+
this.isOverlapping = isOverlapping
|
1041
|
+
this.paddingInPx = paddingPx
|
1104
1042
|
|
1105
|
-
isCollapsible = collapsible.isNotEmpty()
|
1106
1043
|
try {
|
1107
1044
|
loadBannerAd(adUnitId, position, size)
|
1108
1045
|
} catch (e: Exception) {
|
1109
|
-
callbackContext.error(e.
|
1046
|
+
callbackContext.error("loadBannerAd Error: " + e.message)
|
1110
1047
|
}
|
1111
1048
|
}
|
1112
1049
|
}
|
1113
1050
|
return true
|
1051
|
+
|
1114
1052
|
} else if (action == "showBannerAd") {
|
1115
1053
|
if (mActivity != null) {
|
1116
1054
|
mActivity?.runOnUiThread {
|
@@ -1121,20 +1059,22 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1121
1059
|
bannerView?.visibility = View.VISIBLE
|
1122
1060
|
bannerView?.resume()
|
1123
1061
|
|
1124
|
-
if (
|
1125
|
-
|
1062
|
+
if (isPosition == "top-center") {
|
1063
|
+
setBannerAdTop()
|
1064
|
+
} else {
|
1065
|
+
setBannerAdBottom()
|
1126
1066
|
}
|
1127
1067
|
|
1128
|
-
bannerViewLayout?.requestFocus()
|
1129
|
-
|
1068
|
+
bannerViewLayout?.requestFocus()
|
1130
1069
|
|
1131
1070
|
} catch (e: Exception) {
|
1132
|
-
callbackContext.error(e.
|
1071
|
+
callbackContext.error("showBannerAd Error: " + e.message)
|
1133
1072
|
}
|
1134
1073
|
}
|
1135
1074
|
}
|
1136
1075
|
}
|
1137
1076
|
return true
|
1077
|
+
|
1138
1078
|
} else if (action == "styleBannerAd") {
|
1139
1079
|
val options = args.getJSONObject(0)
|
1140
1080
|
if (mActivity != null) {
|
@@ -1148,10 +1088,13 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1148
1088
|
screenHeight = windowMetrics.bounds.height()
|
1149
1089
|
usableHeight = screenHeight - insets.bottom
|
1150
1090
|
} else {
|
1091
|
+
@Suppress("DEPRECATION")
|
1151
1092
|
val display = cordova.activity.windowManager.defaultDisplay
|
1152
1093
|
val size = Point()
|
1153
1094
|
val realSize = Point()
|
1095
|
+
@Suppress("DEPRECATION")
|
1154
1096
|
display.getSize(size)
|
1097
|
+
@Suppress("DEPRECATION")
|
1155
1098
|
display.getRealSize(realSize)
|
1156
1099
|
|
1157
1100
|
usableHeight = size.y
|
@@ -1188,9 +1131,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1188
1131
|
}
|
1189
1132
|
""".trimIndent()
|
1190
1133
|
|
1191
|
-
mActivity?.runOnUiThread {
|
1192
|
-
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.style.banner.ad', $eventData)")
|
1193
|
-
}
|
1134
|
+
mActivity?.runOnUiThread { cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.style.banner.ad', $eventData)") }
|
1194
1135
|
} catch (e: Exception) {
|
1195
1136
|
callbackContext.error("Error in styleBannerAd: ${e.message}")
|
1196
1137
|
}
|
@@ -1198,6 +1139,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1198
1139
|
}
|
1199
1140
|
}
|
1200
1141
|
return true
|
1142
|
+
|
1201
1143
|
} else if (action == "metaData") {
|
1202
1144
|
val options = args.getJSONObject(0)
|
1203
1145
|
val useCustomConsentManager = options.optBoolean("useCustomConsentManager")
|
@@ -1220,12 +1162,13 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1220
1162
|
isBannerPause = 1
|
1221
1163
|
bannerOverlappingToZero()
|
1222
1164
|
} catch (e: Exception) {
|
1223
|
-
callbackContext.error(e.
|
1165
|
+
callbackContext.error("hideBannerAd Error: " + e.message)
|
1224
1166
|
}
|
1225
1167
|
}
|
1226
1168
|
}
|
1227
1169
|
}
|
1228
1170
|
return true
|
1171
|
+
|
1229
1172
|
} else if (action == "removeBannerAd") {
|
1230
1173
|
if (mActivity != null) {
|
1231
1174
|
mActivity?.runOnUiThread {
|
@@ -1242,7 +1185,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1242
1185
|
lock = true
|
1243
1186
|
}
|
1244
1187
|
} catch (e: Exception) {
|
1245
|
-
PUBLIC_CALLBACKS
|
1188
|
+
PUBLIC_CALLBACKS?.error("Error removing banner: " + e.message)
|
1246
1189
|
}
|
1247
1190
|
}
|
1248
1191
|
}
|
@@ -1254,7 +1197,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1254
1197
|
try {
|
1255
1198
|
registerWebView(callbackContext)
|
1256
1199
|
} catch (e: Exception) {
|
1257
|
-
PUBLIC_CALLBACKS
|
1200
|
+
PUBLIC_CALLBACKS?.error("Error register WebView: " + e.message)
|
1258
1201
|
}
|
1259
1202
|
}
|
1260
1203
|
}
|
@@ -1273,6 +1216,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1273
1216
|
|
1274
1217
|
}
|
1275
1218
|
return true
|
1219
|
+
|
1276
1220
|
}
|
1277
1221
|
return false
|
1278
1222
|
}
|
@@ -1330,11 +1274,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1330
1274
|
bannerView?.adListener = bannerAdListener
|
1331
1275
|
bannerView?.loadAd(buildAdRequest())
|
1332
1276
|
} else {
|
1333
|
-
|
1277
|
+
PUBLIC_CALLBACKS?.error("Banner view layout already exists.")
|
1334
1278
|
}
|
1335
1279
|
} catch (e: Exception) {
|
1336
1280
|
PUBLIC_CALLBACKS?.error("Error showing banner: " + e.message)
|
1337
|
-
Log.d(TAG, "Error showing banner: " + e.message)
|
1338
1281
|
}
|
1339
1282
|
}
|
1340
1283
|
|
@@ -1397,7 +1340,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1397
1340
|
}
|
1398
1341
|
}
|
1399
1342
|
|
1400
|
-
bannerViewLayout
|
1343
|
+
bannerViewLayout?.layoutParams = bannerParams
|
1401
1344
|
}
|
1402
1345
|
|
1403
1346
|
|
@@ -1414,12 +1357,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1414
1357
|
isBannerLoad = true
|
1415
1358
|
} else {
|
1416
1359
|
val errorMessage = "Error showing banner: bannerView or bannerViewLayout is null."
|
1417
|
-
// Log.e("isBannerAutoShow", errorMessage)
|
1418
1360
|
PUBLIC_CALLBACKS?.error(errorMessage)
|
1419
1361
|
}
|
1420
1362
|
} catch (e: Exception) {
|
1421
1363
|
val errorMessage = "Error showing banner: " + e.message
|
1422
|
-
// Log.e("isBannerAutoShow", errorMessage, e)
|
1423
1364
|
PUBLIC_CALLBACKS?.error(errorMessage)
|
1424
1365
|
}
|
1425
1366
|
}
|
@@ -1434,11 +1375,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1434
1375
|
bannerViewLayout?.bringToFront()
|
1435
1376
|
bannerViewLayout?.requestFocus();
|
1436
1377
|
lock = false
|
1378
|
+
|
1437
1379
|
}
|
1438
1380
|
isBannerShow = true
|
1439
1381
|
} catch (e: Exception) {
|
1440
1382
|
lock = true
|
1441
|
-
PUBLIC_CALLBACKS?.error(e.
|
1383
|
+
PUBLIC_CALLBACKS?.error("Error isShowBannerAds: ${e.message}")
|
1442
1384
|
}
|
1443
1385
|
}
|
1444
1386
|
}
|
@@ -1474,7 +1416,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1474
1416
|
put("responseInfoAdapterResponses", adapterResponses)
|
1475
1417
|
}
|
1476
1418
|
|
1477
|
-
cWebView
|
1419
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
|
1478
1420
|
|
1479
1421
|
bannerOverlappingToZero()
|
1480
1422
|
|
@@ -1489,12 +1431,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1489
1431
|
lock = true
|
1490
1432
|
}
|
1491
1433
|
|
1492
|
-
|
1493
|
-
|
1494
1434
|
}
|
1495
1435
|
|
1496
1436
|
override fun onAdImpression() {
|
1497
|
-
cWebView
|
1437
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.impression');")
|
1498
1438
|
}
|
1499
1439
|
|
1500
1440
|
private fun getAdHeightInDp(adSize: AdSize, context: Context): Int {
|
@@ -1505,45 +1445,41 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1505
1445
|
|
1506
1446
|
|
1507
1447
|
override fun onAdLoaded() {
|
1508
|
-
|
1448
|
+
|
1509
1449
|
isBannerLoad = true
|
1510
1450
|
isBannerPause = 0
|
1511
1451
|
|
1512
|
-
|
1513
|
-
|
1452
|
+
bannerView?.post {
|
1453
|
+
val heightInPx = bannerView?.height
|
1454
|
+
bannerViewHeight = heightInPx ?: 0
|
1514
1455
|
}
|
1515
1456
|
|
1516
|
-
if (
|
1517
|
-
|
1457
|
+
if (isPosition == "top-center") {
|
1458
|
+
setBannerAdTop()
|
1459
|
+
} else {
|
1460
|
+
setBannerAdBottom()
|
1518
1461
|
}
|
1519
1462
|
|
1463
|
+
if (bannerAutoShow) {
|
1464
|
+
isBannerAutoShow()
|
1465
|
+
}
|
1520
1466
|
|
1521
1467
|
val context = cordova.activity.applicationContext
|
1522
|
-
//val adType="fluid";
|
1523
|
-
// Get the AdSize object based on the type
|
1524
1468
|
var currentAdSize = when (adType) {
|
1525
1469
|
"banner" -> AdSize.BANNER
|
1526
1470
|
"large_banner" -> AdSize.LARGE_BANNER
|
1527
1471
|
"medium_rectangle" -> AdSize.MEDIUM_RECTANGLE
|
1528
1472
|
"full_banner" -> AdSize.FULL_BANNER
|
1529
1473
|
"leaderboard" -> AdSize.LEADERBOARD
|
1530
|
-
|
1531
|
-
//"fluid" -> AdSize.FLUID
|
1532
|
-
//"in_line_adaptive" -> AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(context, adWidth)
|
1533
|
-
|
1534
|
-
else -> adSize // Default fallback to the adaptive ad size
|
1474
|
+
else -> adSize
|
1535
1475
|
}
|
1536
1476
|
|
1537
|
-
// Calculate the height in dp
|
1538
1477
|
val bannerHeightDp = getAdHeightInDp(currentAdSize, context)
|
1539
1478
|
|
1540
|
-
//bannerHeight=currentAdSize;
|
1541
|
-
|
1542
|
-
|
1543
1479
|
val bannerLoadEventData = String.format(Locale.US, "{\"height\": %d}", bannerHeightDp)
|
1544
1480
|
|
1545
1481
|
|
1546
|
-
cWebView
|
1482
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load', $bannerLoadEventData);")
|
1547
1483
|
|
1548
1484
|
val eventData = String.format(
|
1549
1485
|
"{\"collapsible\": \"%s\"}",
|
@@ -1568,16 +1504,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1568
1504
|
} else {
|
1569
1505
|
result.put("getBundleExtra", JSONObject.NULL)
|
1570
1506
|
}
|
1571
|
-
cWebView
|
1507
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAd.responseInfo', ${result});")
|
1572
1508
|
} catch (e: JSONException) {
|
1573
|
-
PUBLIC_CALLBACKS
|
1509
|
+
PUBLIC_CALLBACKS?.error("Error isResponseInfo: ${e.message}")
|
1574
1510
|
}
|
1575
1511
|
}
|
1576
1512
|
}
|
1577
1513
|
|
1578
1514
|
|
1579
1515
|
override fun onAdOpened() {
|
1580
|
-
cWebView
|
1516
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.open');")
|
1581
1517
|
isBannerShows = false
|
1582
1518
|
}
|
1583
1519
|
}
|
@@ -1590,25 +1526,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1590
1526
|
try {
|
1591
1527
|
val rootView = (cWebView?.view?.parent as View)
|
1592
1528
|
rootView.post {
|
1593
|
-
// Get the total height of the parent view
|
1594
1529
|
val totalHeight = rootView.height
|
1595
|
-
|
1596
|
-
// Adjust WebView height to match parent height
|
1597
1530
|
val layoutParams = cWebView?.view?.layoutParams
|
1598
1531
|
layoutParams?.height = totalHeight
|
1599
1532
|
cWebView?.view?.layoutParams = layoutParams
|
1600
|
-
|
1601
|
-
// Ensure no padding/margin in WebView or its parent
|
1602
1533
|
cWebView?.view?.setPadding(0, 0, 0, 0)
|
1603
1534
|
(cWebView?.view?.parent as? ViewGroup)?.setPadding(0, 0, 0, 0)
|
1604
|
-
|
1605
|
-
// Force layout update
|
1606
1535
|
cWebView?.view?.requestLayout()
|
1607
1536
|
|
1608
|
-
Log.d("BannerAdjustment", "WebView set to full height: $totalHeight")
|
1609
1537
|
}
|
1610
1538
|
} catch (e: Exception) {
|
1611
|
-
|
1539
|
+
PUBLIC_CALLBACKS?.error("Error bannerOverlappingToZero: ${e.message}")
|
1612
1540
|
}
|
1613
1541
|
}
|
1614
1542
|
}
|
@@ -1616,35 +1544,104 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1616
1544
|
|
1617
1545
|
|
1618
1546
|
|
1547
|
+
private fun setBannerAdBottom() {
|
1548
|
+
if (bannerView != null && mActivity != null && cWebView != null) {
|
1549
|
+
mActivity?.runOnUiThread {
|
1550
|
+
bannerView?.post {
|
1551
|
+
try {
|
1552
|
+
val screenHeightInPx = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
1553
|
+
val windowMetrics = mActivity!!.windowManager.currentWindowMetrics
|
1554
|
+
val insets = windowMetrics.windowInsets.getInsets(WindowInsets.Type.systemBars())
|
1555
|
+
val height = windowMetrics.bounds.height() - insets.top - insets.bottom
|
1556
|
+
height
|
1557
|
+
} else {
|
1558
|
+
val displayMetrics = DisplayMetrics()
|
1559
|
+
@Suppress("DEPRECATION")
|
1560
|
+
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1561
|
+
displayMetrics.heightPixels
|
1562
|
+
}
|
1619
1563
|
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
cWebView!!.view.layoutParams = layoutParams
|
1564
|
+
val webViewHeight = screenHeightInPx - bannerViewHeight
|
1565
|
+
|
1566
|
+
if (!isFullScreen) {
|
1567
|
+
val navBarHeight = getNavigationBarHeight(mActivity!!)
|
1568
|
+
bannerViewLayout?.let { container ->
|
1569
|
+
container.post {
|
1570
|
+
val params = container.layoutParams
|
1571
|
+
if (params is ViewGroup.MarginLayoutParams) {
|
1572
|
+
params.bottomMargin = navBarHeight
|
1573
|
+
container.layoutParams = params
|
1574
|
+
container.requestLayout()
|
1575
|
+
}
|
1576
|
+
}
|
1577
|
+
}
|
1578
|
+
}
|
1636
1579
|
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1580
|
+
if (!isOverlapping) {
|
1581
|
+
val layoutParams = cWebView!!.view.layoutParams
|
1582
|
+
layoutParams.height = webViewHeight
|
1583
|
+
cWebView!!.view.layoutParams = layoutParams
|
1584
|
+
}
|
1585
|
+
|
1586
|
+
} catch (e: Exception) {
|
1587
|
+
PUBLIC_CALLBACKS?.error("Error bannerOverlapping: ${e.message}")
|
1588
|
+
}
|
1589
|
+
}
|
1640
1590
|
}
|
1641
1591
|
}
|
1642
1592
|
}
|
1643
|
-
}
|
1644
1593
|
|
1645
1594
|
|
1595
|
+
private fun setBannerAdTop() {
|
1596
|
+
mActivity?.let { activity ->
|
1597
|
+
bannerView?.post {
|
1598
|
+
val bannerHeightPx = bannerViewHeight
|
1599
|
+
val statusBarHeight = getStatusBarHeight(activity)
|
1600
|
+
if (isPosition.equals("top-center", ignoreCase = true)) {
|
1601
|
+
val bannerLp = bannerView?.layoutParams as? FrameLayout.LayoutParams
|
1602
|
+
bannerLp?.let { lp ->
|
1603
|
+
if (isOverlapping) {
|
1604
|
+
if (isFullScreen) {
|
1605
|
+
lp.topMargin = 0
|
1606
|
+
bannerView?.layoutParams = lp
|
1607
|
+
} else {
|
1608
|
+
lp.topMargin = statusBarHeight
|
1609
|
+
bannerView?.layoutParams = lp
|
1610
|
+
}
|
1611
|
+
} else {
|
1612
|
+
if (isFullScreen) {
|
1613
|
+
lp.topMargin = 0
|
1614
|
+
bannerView?.layoutParams = lp
|
1615
|
+
} else {
|
1616
|
+
lp.topMargin = statusBarHeight
|
1617
|
+
bannerView?.layoutParams = lp
|
1618
|
+
}
|
1619
|
+
}
|
1646
1620
|
|
1647
|
-
|
1621
|
+
}
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
cWebView?.let { webView ->
|
1625
|
+
val webLp = webView.view.layoutParams as FrameLayout.LayoutParams
|
1626
|
+
if (isPosition.equals("top-center", ignoreCase = true)) {
|
1627
|
+
|
1628
|
+
if (isOverlapping) {
|
1629
|
+
webLp.topMargin = 0
|
1630
|
+
} else {
|
1631
|
+
webLp.topMargin = bannerHeightPx
|
1632
|
+
}
|
1633
|
+
}
|
1634
|
+
webView.view.layoutParams = webLp
|
1635
|
+
webView.view.requestLayout()
|
1636
|
+
}
|
1637
|
+
}}
|
1638
|
+
}
|
1639
|
+
|
1640
|
+
|
1641
|
+
|
1642
|
+
|
1643
|
+
|
1644
|
+
private val bannerPaidAdListener = OnPaidEventListener { adValue ->
|
1648
1645
|
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
1649
1646
|
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
1650
1647
|
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
@@ -1657,9 +1654,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1657
1654
|
result.put("adUnitId", adUnitId)
|
1658
1655
|
isBannerLoad = false
|
1659
1656
|
isBannerShow = true
|
1660
|
-
cWebView
|
1657
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.revenue', ${result});")
|
1661
1658
|
} catch (e: JSONException) {
|
1662
|
-
PUBLIC_CALLBACKS
|
1659
|
+
PUBLIC_CALLBACKS?.error("Error bannerPaidAdListener: ${e.message}")
|
1663
1660
|
}
|
1664
1661
|
}
|
1665
1662
|
|
@@ -1738,7 +1735,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1738
1735
|
val bounds = windowMetrics.bounds
|
1739
1736
|
val widthPixels = bounds.width() - insets.left - insets.right
|
1740
1737
|
outMetrics.widthPixels = widthPixels
|
1741
|
-
outMetrics.density = mActivity
|
1738
|
+
outMetrics.density = mActivity?.resources?.displayMetrics!!.density
|
1742
1739
|
}
|
1743
1740
|
} else {
|
1744
1741
|
@Suppress("DEPRECATION")
|
@@ -1784,14 +1781,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1784
1781
|
this.isUsingAdManagerRequest = isUsingAdManagerRequest
|
1785
1782
|
}
|
1786
1783
|
|
1787
|
-
|
1788
|
-
private fun targetingAdRequest(
|
1789
|
-
customTargeting: JSONArray?,
|
1790
|
-
categoryExclusions: String,
|
1791
|
-
ppId: String,
|
1792
|
-
ctURL: String,
|
1793
|
-
brandSafetyArr: JSONArray?
|
1794
|
-
) {
|
1784
|
+
private fun targetingAdRequest(customTargeting: JSONArray?, categoryExclusions: String, ppId: String, ctURL: String, brandSafetyArr: JSONArray?) {
|
1795
1785
|
try {
|
1796
1786
|
customTargetingList = ArrayList()
|
1797
1787
|
|
@@ -1842,6 +1832,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1842
1832
|
@SuppressLint("DefaultLocale")
|
1843
1833
|
private fun initializeMobileAdsSdk() {
|
1844
1834
|
|
1835
|
+
isFullScreen = isFullScreenMode(mActivity!!)
|
1836
|
+
|
1845
1837
|
if (isMobileAdsInitializeCalled.getAndSet(true)) {
|
1846
1838
|
return
|
1847
1839
|
}
|
@@ -1888,12 +1880,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1888
1880
|
""".trimIndent()
|
1889
1881
|
|
1890
1882
|
mActivity?.runOnUiThread {
|
1891
|
-
// Log.d(TAG, "Google Mobile Ads SDK Initialization: $eventData")
|
1892
1883
|
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization', $eventData)")
|
1893
1884
|
}
|
1894
1885
|
}
|
1895
1886
|
} catch (e: Exception) {
|
1896
|
-
|
1887
|
+
PUBLIC_CALLBACKS?.error("Error during MobileAds initialization: ${e.message}")
|
1897
1888
|
}
|
1898
1889
|
}
|
1899
1890
|
}
|
@@ -1909,7 +1900,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1909
1900
|
|
1910
1901
|
if (this.customTargetingEnabled) {
|
1911
1902
|
if (customTargetingList!!.isEmpty()) {
|
1912
|
-
Log.d(TAG, "List is empty")
|
1913
1903
|
PUBLIC_CALLBACKS?.error("List is empty")
|
1914
1904
|
} else {
|
1915
1905
|
builder.addCustomTargeting("age", customTargetingList!!)
|
@@ -1938,7 +1928,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1938
1928
|
|
1939
1929
|
if (this.brandSafetyEnabled) {
|
1940
1930
|
if (brandSafetyUrls!!.isEmpty()) {
|
1941
|
-
Log.d(TAG, "List is empty")
|
1942
1931
|
PUBLIC_CALLBACKS?.error("List is empty")
|
1943
1932
|
} else {
|
1944
1933
|
builder.setNeighboringContentUrls(brandSafetyUrls!!)
|
@@ -1953,7 +1942,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1953
1942
|
|
1954
1943
|
val bundleExtra = Bundle()
|
1955
1944
|
// bundleExtra.putString("npa", this.Npa); DEPRECATED Beginning January 16, 2024
|
1956
|
-
if (
|
1945
|
+
if (collapsiblePos !== "") {
|
1957
1946
|
bundleExtra.putString("collapsible", this.collapsiblePos)
|
1958
1947
|
}
|
1959
1948
|
bundleExtra.putBoolean("is_designed_for_families", this.isSetTagForChildDirectedTreatment)
|
@@ -1981,7 +1970,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1981
1970
|
val builder = AdRequest.Builder()
|
1982
1971
|
val bundleExtra = Bundle()
|
1983
1972
|
// bundleExtra.putString("npa", this.Npa); DEPRECATED Beginning January 16, 2024
|
1984
|
-
if (
|
1973
|
+
if (collapsiblePos !== "") {
|
1985
1974
|
bundleExtra.putString("collapsible", this.collapsiblePos)
|
1986
1975
|
}
|
1987
1976
|
|
@@ -2023,6 +2012,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2023
2012
|
return sb.toString().uppercase(Locale.getDefault())
|
2024
2013
|
} catch (e: NoSuchAlgorithmException) {
|
2025
2014
|
algorithm = "SHA-1"
|
2015
|
+
PUBLIC_CALLBACKS?.error(e.message)
|
2026
2016
|
try {
|
2027
2017
|
val messageDigest = MessageDigest.getInstance(algorithm)
|
2028
2018
|
val contentResolver = mContext!!.contentResolver
|
@@ -2052,19 +2042,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2052
2042
|
val currentTime = System.currentTimeMillis()
|
2053
2043
|
if (currentTime - lastAccessTime > EXPIRATION_TIME) {
|
2054
2044
|
removeKey(key)
|
2055
|
-
cWebView
|
2045
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.TCString.expired');")
|
2056
2046
|
}
|
2057
|
-
val editor = mPreferences
|
2058
|
-
editor
|
2059
|
-
editor
|
2047
|
+
val editor = mPreferences?.edit()
|
2048
|
+
editor?.putLong(key + LAST_ACCESS_SUFFIX, currentTime)
|
2049
|
+
editor?.apply()
|
2060
2050
|
}
|
2061
2051
|
|
2062
2052
|
private fun removeKey(key: String) {
|
2063
|
-
val editor = mPreferences
|
2064
|
-
editor
|
2065
|
-
editor
|
2066
|
-
editor
|
2067
|
-
cWebView
|
2053
|
+
val editor = mPreferences?.edit()
|
2054
|
+
editor?.remove(key)
|
2055
|
+
editor?.remove(key + LAST_ACCESS_SUFFIX)
|
2056
|
+
editor?.apply()
|
2057
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.TCString.remove');")
|
2068
2058
|
}
|
2069
2059
|
|
2070
2060
|
|
@@ -2075,7 +2065,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2075
2065
|
private fun appOpenAdLoadCallback() {
|
2076
2066
|
appOpenAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2077
2067
|
override fun onAdDismissedFullScreenContent() {
|
2078
|
-
cWebView
|
2068
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');")
|
2079
2069
|
val mainView: View? = view
|
2080
2070
|
mainView?.requestFocus()
|
2081
2071
|
}
|
@@ -2138,7 +2128,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2138
2128
|
private fun rewardedAdLoadCallback() {
|
2139
2129
|
rewardedAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2140
2130
|
override fun onAdClicked() {
|
2141
|
-
cWebView
|
2131
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');")
|
2142
2132
|
}
|
2143
2133
|
|
2144
2134
|
override fun onAdDismissedFullScreenContent() {
|
@@ -2151,7 +2141,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2151
2141
|
}
|
2152
2142
|
rewardedAd = null
|
2153
2143
|
isRewardedLoad = false
|
2154
|
-
cWebView
|
2144
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.dismissed');")
|
2155
2145
|
}
|
2156
2146
|
|
2157
2147
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
@@ -2163,16 +2153,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2163
2153
|
put("domain", adError.domain)
|
2164
2154
|
put("cause", adError.cause?.toString() ?: "null")
|
2165
2155
|
}
|
2166
|
-
cWebView
|
2156
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.show', ${errorData});")
|
2167
2157
|
}
|
2168
2158
|
|
2169
2159
|
override fun onAdImpression() {
|
2170
|
-
cWebView
|
2160
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.impression');")
|
2171
2161
|
}
|
2172
2162
|
|
2173
2163
|
override fun onAdShowedFullScreenContent() {
|
2174
2164
|
isAdSkip = 1
|
2175
|
-
cWebView
|
2165
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.show');")
|
2176
2166
|
}
|
2177
2167
|
}
|
2178
2168
|
}
|
@@ -2180,20 +2170,20 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2180
2170
|
private fun rewardedInterstitialAdLoadCallback() {
|
2181
2171
|
rewardedInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2182
2172
|
override fun onAdClicked() {
|
2183
|
-
cWebView
|
2173
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');")
|
2184
2174
|
}
|
2185
2175
|
|
2186
2176
|
override fun onAdDismissedFullScreenContent() {
|
2187
2177
|
if (isAdSkip != 2) {
|
2188
2178
|
rewardedInterstitialAd = null
|
2189
2179
|
isRewardedInterstitialLoad = false
|
2190
|
-
cWebView
|
2180
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.ad.skip');")
|
2191
2181
|
}
|
2192
2182
|
rewardedInterstitialAd = null
|
2193
2183
|
isRewardedInterstitialLoad = false
|
2194
2184
|
val mainView: View? = view
|
2195
2185
|
mainView?.requestFocus()
|
2196
|
-
cWebView
|
2186
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.dismissed');")
|
2197
2187
|
}
|
2198
2188
|
|
2199
2189
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
@@ -2205,17 +2195,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2205
2195
|
put("domain", adError.domain)
|
2206
2196
|
put("cause", adError.cause?.toString() ?: "null")
|
2207
2197
|
}
|
2208
|
-
cWebView
|
2198
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.show', ${errorData});")
|
2209
2199
|
}
|
2210
2200
|
|
2211
2201
|
override fun onAdImpression() {
|
2212
|
-
cWebView
|
2202
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.impression');")
|
2213
2203
|
}
|
2214
2204
|
|
2215
2205
|
override fun onAdShowedFullScreenContent() {
|
2216
2206
|
isAdSkip = 1
|
2217
|
-
|
2218
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.showed');")
|
2207
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.showed');")
|
2219
2208
|
}
|
2220
2209
|
}
|
2221
2210
|
}
|
@@ -2226,11 +2215,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2226
2215
|
MobileAds.putPublisherFirstPartyIdEnabled(pubIdEnabled)
|
2227
2216
|
}
|
2228
2217
|
|
2229
|
-
private fun targeting(
|
2230
|
-
childDirectedTreatment: Boolean,
|
2231
|
-
underAgeOfConsent: Boolean,
|
2232
|
-
contentRating: String?
|
2233
|
-
) {
|
2218
|
+
private fun targeting(childDirectedTreatment: Boolean, underAgeOfConsent: Boolean, contentRating: String) {
|
2234
2219
|
val requestConfiguration = MobileAds.getRequestConfiguration().toBuilder()
|
2235
2220
|
requestConfiguration.setTagForChildDirectedTreatment(if (childDirectedTreatment) RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE else RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE)
|
2236
2221
|
requestConfiguration.setTagForUnderAgeOfConsent(if (underAgeOfConsent) RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE else RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE)
|
@@ -2244,8 +2229,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2244
2229
|
MobileAds.setRequestConfiguration(requestConfiguration.build())
|
2245
2230
|
}
|
2246
2231
|
|
2247
|
-
private val isPrivacyOptionsRequired: ConsentInformation.PrivacyOptionsRequirementStatus
|
2248
|
-
get() = consentInformation?.getPrivacyOptionsRequirementStatus() ?: ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
|
2232
|
+
private val isPrivacyOptionsRequired: ConsentInformation.PrivacyOptionsRequirementStatus get() = consentInformation?.getPrivacyOptionsRequirementStatus() ?: ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
|
2249
2233
|
|
2250
2234
|
|
2251
2235
|
|
@@ -2263,18 +2247,56 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2263
2247
|
}
|
2264
2248
|
|
2265
2249
|
|
2250
|
+
private fun isFullScreenMode(activity: Activity): Boolean {
|
2251
|
+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
2252
|
+
activity.window.decorView.rootWindowInsets?.isVisible(WindowInsets.Type.statusBars()) == false
|
2253
|
+
} else {
|
2254
|
+
@Suppress("DEPRECATION")
|
2255
|
+
(activity.window.attributes.flags and WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0
|
2256
|
+
}
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
@SuppressLint("DiscouragedApi", "InternalInsetResource")
|
2260
|
+
private fun getNavigationBarHeight(context: Context): Int {
|
2261
|
+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
2262
|
+
// Preferred method for API 30+
|
2263
|
+
val windowMetrics = context.getSystemService(WindowManager::class.java).currentWindowMetrics
|
2264
|
+
val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility(
|
2265
|
+
WindowInsets.Type.navigationBars()
|
2266
|
+
)
|
2267
|
+
insets.bottom
|
2268
|
+
} else {
|
2269
|
+
val resources = context.resources
|
2270
|
+
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
|
2271
|
+
if (resourceId > 0) resources.getDimensionPixelSize(resourceId) else 0
|
2272
|
+
}
|
2273
|
+
}
|
2274
|
+
|
2275
|
+
|
2276
|
+
|
2277
|
+
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
2278
|
+
private fun getStatusBarHeight(context: Context): Int {
|
2279
|
+
var result = 0
|
2280
|
+
val resourceId = context.resources.getIdentifier("status_bar_height", "dimen", "android")
|
2281
|
+
if (resourceId > 0) {
|
2282
|
+
result = context.resources.getDimensionPixelSize(resourceId)
|
2283
|
+
}
|
2284
|
+
return result
|
2285
|
+
}
|
2286
|
+
|
2287
|
+
|
2266
2288
|
|
2267
2289
|
private val view: View?
|
2268
2290
|
get() {
|
2269
2291
|
if (View::class.java.isAssignableFrom(CordovaWebView::class.java)) {
|
2270
2292
|
return cWebView as View?
|
2271
2293
|
}
|
2272
|
-
return mActivity
|
2294
|
+
return mActivity?.window?.decorView?.findViewById(View.generateViewId())
|
2273
2295
|
}
|
2274
2296
|
|
2275
2297
|
override fun onPause(multitasking: Boolean) {
|
2276
2298
|
if (bannerView != null) {
|
2277
|
-
bannerView
|
2299
|
+
bannerView?.pause()
|
2278
2300
|
}
|
2279
2301
|
|
2280
2302
|
super.onPause(multitasking)
|
@@ -2283,7 +2305,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2283
2305
|
override fun onResume(multitasking: Boolean) {
|
2284
2306
|
super.onResume(multitasking)
|
2285
2307
|
if (bannerView != null) {
|
2286
|
-
bannerView
|
2308
|
+
bannerView?.resume()
|
2287
2309
|
}
|
2288
2310
|
}
|
2289
2311
|
|
@@ -2293,11 +2315,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2293
2315
|
|
2294
2316
|
override fun onDestroy() {
|
2295
2317
|
if (bannerView != null) {
|
2296
|
-
bannerView
|
2318
|
+
bannerView?.destroy()
|
2297
2319
|
bannerView = null
|
2298
2320
|
}
|
2299
2321
|
if (bannerViewLayout != null) {
|
2300
|
-
val parentView = bannerViewLayout
|
2322
|
+
val parentView = bannerViewLayout?.parent as ViewGroup
|
2301
2323
|
parentView.removeView(bannerViewLayout)
|
2302
2324
|
bannerViewLayout = null
|
2303
2325
|
}
|
@@ -2306,7 +2328,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2306
2328
|
|
2307
2329
|
|
2308
2330
|
companion object {
|
2309
|
-
|
2331
|
+
// private const val TAG = "emiAdmobPlugin"
|
2310
2332
|
|
2311
2333
|
// Consent status will automatically reset after 12 months
|
2312
2334
|
// https://support.google.com/admanager/answer/9999955?hl=en
|