emi-indo-cordova-plugin-admob 1.5.6 → 1.5.7
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 +4 -4
- package/example/www/js/bannerAd.js +8 -1
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/emiAdmobPlugin.kt +41 -3
package/README.md
CHANGED
@@ -333,7 +333,7 @@ document.addEventListener('on.appOpenAd.loaded', () => {
|
|
333
333
|
</pre>
|
334
334
|
</details>
|
335
335
|
|
336
|
-
- [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
336
|
+
- [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/appOpenAd.js)
|
337
337
|
|
338
338
|
|
339
339
|
|
@@ -436,7 +436,7 @@ console.log("Collapsible Status: " + event.collapsible);
|
|
436
436
|
</pre>
|
437
437
|
</details>
|
438
438
|
|
439
|
-
[FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
439
|
+
[FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/bannerAd.js)
|
440
440
|
|
441
441
|
|
442
442
|
## Interstitial ADS
|
@@ -499,7 +499,7 @@ document.addEventListener('on.interstitial.dismissed', () => {
|
|
499
499
|
</details>
|
500
500
|
|
501
501
|
|
502
|
-
[FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
502
|
+
[FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/interstitialAd.js)
|
503
503
|
|
504
504
|
|
505
505
|
|
@@ -628,7 +628,7 @@ document.addEventListener('on.rewarded.dismissed', () => {
|
|
628
628
|
</pre>
|
629
629
|
</details>
|
630
630
|
|
631
|
-
[FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
631
|
+
[FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/rewardedAd.js)
|
632
632
|
|
633
633
|
|
634
634
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
//
|
1
|
+
// ccordova.plugins.emiAdmobPlugin.styleBannerAd({isOverlapping: true, overlappingHeight: 5, padding: 0, margins: 0 }); // ( only android)
|
2
2
|
//cordova.plugins.emiAdmobPlugin.loadBannerAd({config});
|
3
3
|
//cordova.plugins.emiAdmobPlugin.showBannerAd(); // default
|
4
4
|
//cordova.plugins.emiAdmobPlugin.hideBannerAd(); // default
|
@@ -10,6 +10,13 @@ function loadBanner() {
|
|
10
10
|
|
11
11
|
if (typeof cordova !== 'undefined') {
|
12
12
|
|
13
|
+
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
14
|
+
isOverlapping: true,
|
15
|
+
overlappingHeight: 5,
|
16
|
+
padding: 0,
|
17
|
+
margins: 0
|
18
|
+
});
|
19
|
+
|
13
20
|
cordova.plugins.emiAdmobPlugin.loadBannerAd({
|
14
21
|
adUnitId: Banner_ID, //Banner_ID,
|
15
22
|
position: "bottom-center",
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
2
2
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
id="emi-indo-cordova-plugin-admob" version="1.5.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="1.5.7">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova Plugin Admob Android IOS</description>
|
@@ -86,12 +86,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
86
86
|
|
87
87
|
private var consentInformation: ConsentInformation? = null
|
88
88
|
|
89
|
+
private var isOverlapping: Boolean = false
|
90
|
+
private var overlappingHeight: Int = 0
|
91
|
+
|
89
92
|
var isBannerLoad: Boolean = false
|
90
93
|
var isBannerShow: Boolean = false
|
91
94
|
|
92
95
|
var isBannerShows: Boolean = true
|
93
96
|
private var bannerAutoShow = false
|
94
97
|
private var isAutoResize: Boolean = false
|
98
|
+
|
99
|
+
|
95
100
|
var appOpenAutoShow: Boolean = false
|
96
101
|
var intAutoShow: Boolean = false
|
97
102
|
var rewardedAutoShow: Boolean = false
|
@@ -1077,13 +1082,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1077
1082
|
val options = args.getJSONObject(0)
|
1078
1083
|
if(mActivity != null) {
|
1079
1084
|
mActivity!!.runOnUiThread {
|
1085
|
+
val isOverlapping = options.optBoolean("isOverlapping")
|
1086
|
+
val overlappingHeight = options.optInt("overlappingHeight")
|
1080
1087
|
val paddingPx = options.optInt("padding")
|
1081
1088
|
val marginsPx = options.optInt("margins")
|
1082
|
-
// final boolean autoResize = options.optBoolean("autoResize");
|
1083
1089
|
try {
|
1090
|
+
this.isOverlapping = isOverlapping
|
1091
|
+
this.overlappingHeight = overlappingHeight
|
1084
1092
|
this.paddingInPx = paddingPx
|
1085
1093
|
this.marginsInPx = marginsPx
|
1086
|
-
// this.isAutoResize = autoResize;
|
1087
1094
|
} catch (e: Exception) {
|
1088
1095
|
callbackContext.error(e.toString())
|
1089
1096
|
}
|
@@ -1192,7 +1199,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1192
1199
|
bannerView!!.adUnitId = adUnitId
|
1193
1200
|
bannerView!!.adListener = bannerAdListener
|
1194
1201
|
bannerView!!.loadAd(buildAdRequest())
|
1195
|
-
adjustWebViewForBanner(position)
|
1202
|
+
// adjustWebViewForBanner(position)
|
1196
1203
|
} else {
|
1197
1204
|
Log.d(TAG, "Banner view layout already exists.")
|
1198
1205
|
}
|
@@ -1369,6 +1376,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1369
1376
|
if (bannerAutoShow) {
|
1370
1377
|
isBannerAutoShow()
|
1371
1378
|
}
|
1379
|
+
|
1380
|
+
if (isOverlapping) {
|
1381
|
+
bannerOverlapping()
|
1382
|
+
}
|
1383
|
+
|
1372
1384
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load');")
|
1373
1385
|
|
1374
1386
|
val eventData = String.format(
|
@@ -1412,6 +1424,32 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1412
1424
|
}
|
1413
1425
|
|
1414
1426
|
|
1427
|
+
// fix https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/26
|
1428
|
+
private fun bannerOverlapping() {
|
1429
|
+
if (bannerView != null && mActivity != null && cWebView != null) {
|
1430
|
+
mActivity!!.runOnUiThread {
|
1431
|
+
try {
|
1432
|
+
val bannerHeightInPx = bannerView!!.height
|
1433
|
+
val displayMetrics = DisplayMetrics()
|
1434
|
+
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1435
|
+
val screenHeightInPx = displayMetrics.heightPixels
|
1436
|
+
|
1437
|
+
// Adjust the WebView height to account for the banner ad
|
1438
|
+
val webViewHeight = screenHeightInPx - (adSize.height+overlappingHeight)
|
1439
|
+
val layoutParams = cWebView!!.view.layoutParams
|
1440
|
+
layoutParams.height = webViewHeight
|
1441
|
+
cWebView!!.view.layoutParams = layoutParams
|
1442
|
+
|
1443
|
+
// Log for debugging
|
1444
|
+
Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1445
|
+
} catch (e: Exception) {
|
1446
|
+
Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
|
1447
|
+
}
|
1448
|
+
}
|
1449
|
+
}
|
1450
|
+
}
|
1451
|
+
|
1452
|
+
|
1415
1453
|
private val bannerPaidAdListener = OnPaidEventListener { adValue ->
|
1416
1454
|
val valueMicros = adValue.valueMicros
|
1417
1455
|
val currencyCode = adValue.currencyCode
|