cordova-plugin-admob-nextgen 1.0.0 → 1.0.1
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 +4 -0
- package/package.json +2 -2
- package/plugin.xml +2 -1
- package/src/android/BannerExecutor.java +81 -23
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
[](https://ads-developers.googleblog.com/2026/01/announcing-google-mobile-ads-next-gen.html)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/cordova-plugin-admob-nextgen)
|
|
8
|
+
[](https://www.npmjs.com/package/cordova-plugin-admob-nextgen)
|
|
9
|
+
[](https://github.com/swaplab-engine/cordova-plugin-admob-nextgen/blob/main/LICENSE)
|
|
10
|
+
|
|
7
11
|
**The Ultimate AdMob Monetization Solution for Cordova/Capacitor/Framework7.**
|
|
8
12
|
|
|
9
13
|
This plugin is a complete **rewrite and re-architecture** of the classic AdMob integration, built specifically for the **[Google Mobile Ads Next Generation SDK](https://ads-developers.googleblog.com/2026/01/announcing-google-mobile-ads-next-gen.html)**. It moves away from legacy implementations to modern `SurfaceControl`, optimized layouts, and background threading, ensuring maximum performance, stability, and revenue.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cordova-plugin-admob-nextgen",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Google Mobile Ads Next Gen SDK for Cordova. High performance and modular architecture.",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Google Mobile Ads Next Gen SDK for Cordova. High performance and modular architecture. ",
|
|
5
5
|
"cordova": {
|
|
6
6
|
"id": "cordova-plugin-admob-nextgen",
|
|
7
7
|
"platforms": [
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="cordova-plugin-admob-nextgen"
|
|
2
|
+
<plugin id="cordova-plugin-admob-nextgen"
|
|
3
|
+
version="1.0.1"
|
|
3
4
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
5
6
|
|
|
@@ -53,6 +53,9 @@ public class BannerExecutor {
|
|
|
53
53
|
|
|
54
54
|
private int lastAdHeight = 0;
|
|
55
55
|
|
|
56
|
+
private int systemSafeTop = 0;
|
|
57
|
+
private int systemSafeBottom = 0;
|
|
58
|
+
|
|
56
59
|
private long lastLoadTime = 0;
|
|
57
60
|
private long minLoadInterval = 5000;
|
|
58
61
|
|
|
@@ -301,20 +304,30 @@ public class BannerExecutor {
|
|
|
301
304
|
|
|
302
305
|
if (adLayout == null) {
|
|
303
306
|
adLayout = new RelativeLayout(cordova.getActivity());
|
|
307
|
+
|
|
304
308
|
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
|
305
309
|
RelativeLayout.LayoutParams.MATCH_PARENT,
|
|
306
|
-
RelativeLayout.LayoutParams.
|
|
310
|
+
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
311
|
+
|
|
312
|
+
if ("top".equalsIgnoreCase(currentPosition)) {
|
|
313
|
+
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
|
314
|
+
} else {
|
|
315
|
+
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
|
316
|
+
}
|
|
317
|
+
|
|
307
318
|
adLayout.setClickable(false);
|
|
308
319
|
adLayout.setFocusable(false);
|
|
309
320
|
cordova.getActivity().addContentView(adLayout, params);
|
|
310
321
|
}
|
|
311
322
|
|
|
323
|
+
isBannerVisible = true;
|
|
312
324
|
updateBannerLayout();
|
|
313
325
|
|
|
314
326
|
adLayout.bringToFront();
|
|
315
327
|
adLayout.setVisibility(View.VISIBLE);
|
|
328
|
+
adView.setVisibility(View.VISIBLE);
|
|
329
|
+
|
|
316
330
|
updateWebViewMargins();
|
|
317
|
-
isBannerVisible = true;
|
|
318
331
|
}
|
|
319
332
|
|
|
320
333
|
private void updateBannerLayout() {
|
|
@@ -340,12 +353,37 @@ public class BannerExecutor {
|
|
|
340
353
|
} else {
|
|
341
354
|
adView.setLayoutParams(bannerParams);
|
|
342
355
|
}
|
|
343
|
-
}
|
|
344
356
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
357
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
|
358
|
+
adLayout.setOnApplyWindowInsetsListener((v, insets) -> {
|
|
359
|
+
|
|
360
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
|
361
|
+
systemSafeTop = insets.getInsets(android.view.WindowInsets.Type.systemBars()).top;
|
|
362
|
+
systemSafeBottom = insets.getInsets(android.view.WindowInsets.Type.systemBars()).bottom;
|
|
363
|
+
} else {
|
|
364
|
+
systemSafeTop = insets.getSystemWindowInsetTop();
|
|
365
|
+
systemSafeBottom = insets.getSystemWindowInsetBottom();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (adView != null && adView.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
|
|
369
|
+
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) adView.getLayoutParams();
|
|
370
|
+
if ("top".equalsIgnoreCase(currentPosition)) {
|
|
371
|
+
params.topMargin = systemSafeTop;
|
|
372
|
+
params.bottomMargin = 0;
|
|
373
|
+
} else {
|
|
374
|
+
params.bottomMargin = systemSafeBottom;
|
|
375
|
+
params.topMargin = 0;
|
|
376
|
+
}
|
|
377
|
+
adView.setLayoutParams(params);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
updateWebViewMargins();
|
|
381
|
+
|
|
382
|
+
return insets;
|
|
383
|
+
});
|
|
384
|
+
adLayout.requestApplyInsets();
|
|
385
|
+
}
|
|
386
|
+
|
|
349
387
|
}
|
|
350
388
|
|
|
351
389
|
private void updateWebViewMargins() {
|
|
@@ -357,31 +395,49 @@ public class BannerExecutor {
|
|
|
357
395
|
if (lp instanceof ViewGroup.MarginLayoutParams) {
|
|
358
396
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) lp;
|
|
359
397
|
|
|
360
|
-
if (
|
|
398
|
+
if ("top".equalsIgnoreCase(currentPosition)) {
|
|
399
|
+
|
|
361
400
|
params.setMargins(0, 0, 0, 0);
|
|
362
|
-
|
|
363
|
-
if (
|
|
364
|
-
|
|
401
|
+
|
|
402
|
+
if (isBannerVisible && !isOverlapping) {
|
|
403
|
+
float shift = (float) (lastAdHeight + systemSafeTop);
|
|
404
|
+
webViewView.setTranslationY(shift);
|
|
405
|
+
|
|
365
406
|
} else {
|
|
366
|
-
|
|
407
|
+
webViewView.setTranslationY(0);
|
|
408
|
+
|
|
367
409
|
}
|
|
368
410
|
}
|
|
411
|
+
|
|
412
|
+
else {
|
|
413
|
+
|
|
414
|
+
webViewView.setTranslationY(0);
|
|
415
|
+
|
|
416
|
+
if (!isBannerVisible || isOverlapping) {
|
|
417
|
+
params.setMargins(0, 0, 0, 0);
|
|
418
|
+
} else {
|
|
419
|
+
|
|
420
|
+
int finalBottom = lastAdHeight + systemSafeBottom;
|
|
421
|
+
params.setMargins(0, 0, 0, finalBottom);
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
369
426
|
webViewView.setLayoutParams(params);
|
|
370
427
|
webViewView.requestLayout();
|
|
371
428
|
}
|
|
372
429
|
}
|
|
373
430
|
|
|
374
|
-
private void
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
|
|
431
|
+
private void hideBannerView() {
|
|
432
|
+
if (adLayout == null || adView == null) return;
|
|
433
|
+
|
|
434
|
+
isBannerVisible = false;
|
|
435
|
+
|
|
436
|
+
adView.setVisibility(View.GONE);
|
|
437
|
+
adLayout.setVisibility(View.GONE);
|
|
438
|
+
|
|
439
|
+
updateWebViewMargins();
|
|
378
440
|
|
|
379
|
-
if (lp instanceof ViewGroup.MarginLayoutParams) {
|
|
380
|
-
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) lp;
|
|
381
|
-
params.setMargins(0, 0, 0, 0);
|
|
382
|
-
webViewView.setLayoutParams(params);
|
|
383
|
-
webViewView.requestLayout();
|
|
384
|
-
}
|
|
385
441
|
}
|
|
386
442
|
|
|
387
443
|
public void hideBanner(CallbackContext callbackContext) {
|
|
@@ -404,7 +460,9 @@ public class BannerExecutor {
|
|
|
404
460
|
|
|
405
461
|
private void destroyBannerInternal() {
|
|
406
462
|
if (adView != null) {
|
|
407
|
-
|
|
463
|
+
isBannerVisible = false;
|
|
464
|
+
updateWebViewMargins();
|
|
465
|
+
|
|
408
466
|
if (adView.getParent() != null) {
|
|
409
467
|
((ViewGroup) adView.getParent()).removeView(adView);
|
|
410
468
|
}
|