codeplay-common 4.11.41-alpha.0 → 4.11.41-alpha.3
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 +42 -19
- package/files/buildCodeplay/codeplayBeforeBuild.js +22 -6
- package/files/buildCodeplay/project-scripts.cjs +2 -0
- package/files/patches/catalog/capacitor-admob-nextgen+1.6.0.patch +219 -0
- package/files/patches/catalog/capacitor-admob-nextgen+1.6.2-beta.patch +209 -0
- package/files/scripts-common/setup-baseline-profile.js +18 -15
- package/package.json +3 -3
- package/scripts/capacitor-9-migration.test.cjs +174 -0
- package/scripts/prepare-capacitor-9.cjs +113 -14
- package/scripts/saf-mediastore-dependency.test.cjs +3 -2
- package/scripts/squeezeback-config.test.cjs +38 -4
- package/scripts/sync-files.js +19 -6
- package/migration/capacitor-8-to-9-migration.md +0 -49
- package/migration/patches/capacitor-admob-nextgen+1.6.0.patch +0 -10
- /package/{migration/patches → files/patches/catalog}/@byteowls+capacitor-filesharer+7.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+file-opener+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+in-app-review+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+native-audio+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+play-integrity+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+privacy-screen+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+safe-area+7.0.0-alpha.1.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+speech-recognition+7.0.1.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@capacitor-community+text-to-speech+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@mozartec+capacitor-microphone+7.1.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@ottimis+capacitor-volumes+7.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/@whiteguru+capacitor-plugin-media+8.0.1.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/capacitor-music-controls-plugin+8.0.0.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/capacitor-native-biometric+4.2.2.patch +0 -0
- /package/{migration/patches → files/patches/catalog}/capacitor-voice-recorder+7.0.6.patch +0 -0
package/README.md
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
# codeplay-common
|
|
2
2
|
|
|
3
|
-
## Capacitor 9 migration
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
## Capacitor 9 migration
|
|
4
|
+
|
|
5
|
+
Use the current stable release (`codeplay-common@latest`) when it contains the
|
|
6
|
+
migration helpers. Until then, use `codeplay-common@alpha` for testing. Verify
|
|
7
|
+
that `scripts/prepare-capacitor-9.cjs` and `files/patches/catalog/` are present
|
|
8
|
+
in the installed package. A stable publication does not automatically replace
|
|
9
|
+
an app's pinned alpha dependency; update and test that app explicitly. The
|
|
10
|
+
migration guide is delivered separately in the server's versioned
|
|
11
|
+
`agents-<version>.zip`; the npm package does not ship or copy it. Follow that
|
|
12
|
+
guide for each app's dependency, Android, iOS, and device migration.
|
|
8
13
|
The package does not migrate an arbitrary app merely by being installed.
|
|
9
14
|
|
|
10
|
-
After the app uses Capacitor 9,
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
After the app uses Capacitor 9, installation copies the full catalog from
|
|
16
|
+
`files/patches/catalog/` to the app's `patches/catalog/`, then selects exact-version
|
|
17
|
+
patches for `patches/active/` and applies them with the
|
|
18
|
+
package-owned `patch-package`, and adds a root postinstall hook for future
|
|
19
|
+
installs. Every build checks and reapplies the active patches before native
|
|
20
|
+
work. Run `node node_modules/codeplay-common/scripts/prepare-capacitor-9.cjs`
|
|
21
|
+
for a read-only report. An active patch for an absent or newer plugin stops the
|
|
22
|
+
install/build with its old and installed versions so the team can review it.
|
|
23
|
+
Existing app-specific patches for the same version are preserved. The AdMob
|
|
24
|
+
1.6.0 patch includes the removed `hasOption()` API fix and banner/WebView inset
|
|
25
|
+
changes. The 1.6.2-beta patch keeps only the inset changes because its API fix
|
|
26
|
+
is upstream. For a newer AdMob version, preparation verifies that both API calls
|
|
27
|
+
remain fixed and every inset patch hunk still fits. It then creates an active
|
|
28
|
+
patch named for the installed version. Changed Java code stops the build for
|
|
29
|
+
review. An older installation must first be upgraded to 1.6.0.
|
|
30
|
+
|
|
31
|
+
The migration build helper no longer rewrites Capacitor's `BridgeWebViewClient.java` or
|
|
19
32
|
`SystemBars.java`. In Capacitor 9 apps, the installer leaves the old custom splash
|
|
20
33
|
scripts uninstalled and uses the notification icon sync helper instead. Inspect
|
|
21
34
|
existing scripts and native files as described in the guide before building.
|
|
@@ -212,6 +225,14 @@ All fix implementations ship under `buildCodeplay/fix-optimize-builld/`, includi
|
|
|
212
225
|
|
|
213
226
|
After installing this package update, rebuild and test each app's optimized release. Updating build tooling cannot change APKs or app-store releases already distributed to users.
|
|
214
227
|
|
|
228
|
+
## Capacitor 9 migration helpers
|
|
229
|
+
|
|
230
|
+
The server agent archive supplies `AGENTS/capacitor-8-to-9-migration.md`. Installing this package alone does not migrate an app's native projects. Use the guide in a disposable branch or test copy and review the app's custom Android and iOS code.
|
|
231
|
+
|
|
232
|
+
The installer copies exact-version plugin patches into `patches/catalog/`. On Capacitor 9 it selects matching patches into `patches/active/` and applies them. The before-sync and before-update hooks repeat that check, remove the old `setSplashAnimation.js` call, and leave Capacitor 8 projects unchanged. A mismatched active patch stops the operation for review. Apps that enable Squeezeback use AdMob NextGen 1.6.2-beta until a stable 1.6.2+ release appears, then the updater can install that stable version. Before native work, patch preparation checks the new plugin's Capacitor API calls and every banner/inset patch hunk. If unchanged, it creates a version-named active patch; otherwise it stops for review. The beta upstream release contains the Capacitor 9 `PluginCall` API fix, while its shared patch retains the banner/WebView inset behavior. Known prior patches are replaced; unknown app-specific edits stop for review. A successful patch application still requires device layout validation before publishing the app.
|
|
233
|
+
|
|
234
|
+
For apps with a baseline-profile module, installation and the Capacitor 9 before-sync/update hooks automatically run the bundled baseline helper. It selects the AGP 9 compatible baseline-profile Gradle plugin and removes duplicate module includes before native sync. Verify the native diff under each app's protected-file rules. Native template cleanup, safe-area CSS, store-specific rules, iOS SwiftUI changes, and device validation remain per-app migration steps.
|
|
235
|
+
|
|
215
236
|
## App helper folder
|
|
216
237
|
|
|
217
238
|
Application helper scripts are kept in `scripts-common/`. Installation migrates the old `scripts/` folder and package command paths automatically, preserving every existing file. A conflicting destination file stops migration before any files are moved. The plugin’s internal npm lifecycle folder remains `scripts/`.
|
|
@@ -220,7 +241,7 @@ Application helper scripts are kept in `scripts-common/`. Installation migrates
|
|
|
220
241
|
|
|
221
242
|
The plugin keeps the master build templates in files/buildCodeplay and copies them into each app's buildCodeplay folder during installation/update. Test changes in the application folder, then update these master templates for distribution to other apps.
|
|
222
243
|
|
|
223
|
-
App package scripts run local files
|
|
244
|
+
App package scripts run local files such as node buildCodeplay/codeplayBeforeBuild.js and node buildCodeplay/packageidBaseModification.js. Capacitor 8 apps can still use the legacy splash helpers; Capacitor 9 preparation removes the obsolete setSplashAnimation sync call. Filenames have no version suffixes. The versions.json plugin manifest remains alongside these scripts and is copied too.
|
|
224
245
|
|
|
225
246
|
Installation migrates both legacy versioned filenames and the temporary node_modules runner commands to these local paths. It removes only superseded versioned build scripts, preserves app-owned release configuration and splash XML overrides, and keeps screenshot data and custom helpers. The root finalrelease script is also copied as a local implementation.
|
|
226
247
|
|
|
@@ -307,10 +328,12 @@ The build script reads the `agents` version from
|
|
|
307
328
|
`agents-<version>.zip` archive when the project has no agent instructions or the
|
|
308
329
|
server version is newer.
|
|
309
330
|
|
|
310
|
-
The ZIP root must contain `AGENTS.md` and
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
331
|
+
The ZIP root must contain `AGENTS.md` and at least one supporting instruction
|
|
332
|
+
file; supporting files can be at the ZIP root or under `AGENTS/`. They are installed
|
|
333
|
+
in the project's `AGENTS/` directory. The installed version is stored in
|
|
334
|
+
`AGENTS/.codeplay-version`.
|
|
335
|
+
On a version update, the existing `AGENTS/` directory is replaced by the ZIP's
|
|
336
|
+
contents. Include every instruction file that consuming apps need in that archive.
|
|
314
337
|
|
|
315
338
|
For example, publish `agents-1.1.zip` and add this entry to the server's
|
|
316
339
|
`versions.json`:
|
|
@@ -555,11 +555,13 @@ function checkPackageVersion() {
|
|
|
555
555
|
return;
|
|
556
556
|
}
|
|
557
557
|
const installedVersion = getInstalledVersion(packageName);
|
|
558
|
-
const
|
|
558
|
+
const registryPackage = installedVersion?.includes('-') || declaredPackage.includes('-alpha.')
|
|
559
|
+
? `${packageName}@alpha` : packageName;
|
|
560
|
+
const latestVersion = getLatestVersion(registryPackage);
|
|
559
561
|
|
|
560
562
|
if (!installedVersion) {
|
|
561
563
|
console.error(`${packageName} is not installed. Installing now...`);
|
|
562
|
-
execSync(`npm install ${
|
|
564
|
+
execSync(`npm install ${registryPackage}`, { stdio: 'inherit' });
|
|
563
565
|
return;
|
|
564
566
|
}
|
|
565
567
|
|
|
@@ -567,7 +569,7 @@ function checkPackageVersion() {
|
|
|
567
569
|
console.log(`${packageName} is outdated (installed: ${installedVersion}, latest: ${latestVersion}). Updating now...`);
|
|
568
570
|
|
|
569
571
|
try {
|
|
570
|
-
execSync(`npm install ${
|
|
572
|
+
execSync(`npm install ${registryPackage}`, { stdio: 'inherit' });
|
|
571
573
|
console.log(`${packageName} successfully updated.`);
|
|
572
574
|
} catch (err) {
|
|
573
575
|
console.error(`Failed to update ${packageName}:`, err.message);
|
|
@@ -3222,9 +3224,18 @@ const syncAdmobNextgenPackage = () => {
|
|
|
3222
3224
|
const installedAdmob = getInstalledVersion("capacitor-admob-nextgen");
|
|
3223
3225
|
const squeezebackEnabled = readJsonSafe(getAdmobJsonPath())?.config?.squeezebackEnabled;
|
|
3224
3226
|
const needsSqueezeback = [true, 1, "true", "1"].includes(squeezebackEnabled);
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3227
|
+
const latestStable = needsSqueezeback ? getLatestVersion("capacitor-admob-nextgen") : null;
|
|
3228
|
+
const fixedStable = /^\d+\.\d+\.\d+$/.test(latestStable || "") &&
|
|
3229
|
+
compareVersionStrings(latestStable, "1.6.2") >= 0;
|
|
3230
|
+
const installedBase = installedAdmob?.split("-")[0];
|
|
3231
|
+
if (!installedAdmob) {
|
|
3232
|
+
runNpmCommand(`npm install capacitor-admob-nextgen${needsSqueezeback && !fixedStable ? "@1.6.2-beta" : ""}`);
|
|
3233
|
+
} else if (needsSqueezeback && fixedStable &&
|
|
3234
|
+
(compareVersionStrings(installedBase, latestStable) < 0 ||
|
|
3235
|
+
(installedAdmob.includes("-") && compareVersionStrings(installedBase, latestStable) === 0))) {
|
|
3236
|
+
runNpmCommand(`npm install capacitor-admob-nextgen@${latestStable}`);
|
|
3237
|
+
} else if (needsSqueezeback && !fixedStable && compareVersionStrings(installedBase, "1.6.2") < 0) {
|
|
3238
|
+
runNpmCommand("npm install capacitor-admob-nextgen@1.6.2-beta");
|
|
3228
3239
|
} else {
|
|
3229
3240
|
console.log("ℹ️ Keeping the installed capacitor-admob-nextgen version.");
|
|
3230
3241
|
}
|
|
@@ -4362,6 +4373,11 @@ function syncAndroidCordovaResourceKeep() {
|
|
|
4362
4373
|
async function main() {
|
|
4363
4374
|
require('./saf-mediastore-dependency.cjs').syncSafMediastoreDependency(process.cwd());
|
|
4364
4375
|
const buildPackage = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
4376
|
+
const capacitorCore = require('@capacitor/core/package.json').version;
|
|
4377
|
+
if (Number(capacitorCore.split('.')[0]) >= 9) {
|
|
4378
|
+
const patchResult = require('codeplay-common/scripts/prepare-capacitor-9.cjs').prepare(process.cwd(), true);
|
|
4379
|
+
for (const item of patchResult.review) console.warn(`codeplay-common patch review: ${item}`);
|
|
4380
|
+
}
|
|
4365
4381
|
const buildScripts = updateBuildEntrypoints(buildPackage.scripts || {});
|
|
4366
4382
|
if (JSON.stringify(buildScripts) !== JSON.stringify(buildPackage.scripts)) {
|
|
4367
4383
|
buildPackage.scripts = buildScripts;
|
|
@@ -33,10 +33,12 @@ function updateBuildScripts(scripts) {
|
|
|
33
33
|
if (!/VITE_STORE_ID=6\b/.test(next['build:ios'])) next['build:ios'] = next['build:ios'].replace('CODEPLAY_BUILD_PLATFORM=ios ', 'CODEPLAY_BUILD_PLATFORM=ios VITE_STORE_ID=6 ');
|
|
34
34
|
next['capacitor:sync:after'] = next['capacitor:sync:after'] || syncAfter;
|
|
35
35
|
const safDependency = 'node buildCodeplay/saf-mediastore-dependency.cjs';
|
|
36
|
+
const cap9Prepare = 'node node_modules/codeplay-common/scripts/prepare-capacitor-9.cjs --apply-if-cap9';
|
|
36
37
|
for (const hook of ['capacitor:sync:before', 'capacitor:update:before']) {
|
|
37
38
|
if (!(next[hook] || '').includes(safDependency)) {
|
|
38
39
|
next[hook] = next[hook] ? `${safDependency} && ${next[hook]}` : safDependency;
|
|
39
40
|
}
|
|
41
|
+
if (!next[hook].includes(cap9Prepare)) next[hook] = `${cap9Prepare} && ${next[hook]}`;
|
|
40
42
|
}
|
|
41
43
|
next['build-capacitor-android'] = next['build-capacitor-android'] || 'npm run build && npx cap copy android';
|
|
42
44
|
next['build-capacitor-ios'] = next['build-capacitor-ios']
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
diff --git a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/AdMobNextGenPlugin.java b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/AdMobNextGenPlugin.java
|
|
2
|
+
--- a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/AdMobNextGenPlugin.java
|
|
3
|
+
+++ b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/AdMobNextGenPlugin.java
|
|
4
|
+
@@ -185,4 +185,4 @@ public class AdMobNextGenPlugin extends Plugin {
|
|
5
|
+
String maxAdContentRating = call.getString("maxAdContentRating", "");
|
|
6
|
+
- Boolean tagForChildDirectedTreatment = call.hasOption("tagForChildDirectedTreatment") ? call.getBoolean("tagForChildDirectedTreatment") : null;
|
|
7
|
+
- Boolean tagForUnderAgeOfConsent = call.hasOption("tagForUnderAgeOfConsent") ? call.getBoolean("tagForUnderAgeOfConsent") : null;
|
|
8
|
+
+ Boolean tagForChildDirectedTreatment = call.getData().has("tagForChildDirectedTreatment") ? call.getBoolean("tagForChildDirectedTreatment") : null;
|
|
9
|
+
+ Boolean tagForUnderAgeOfConsent = call.getData().has("tagForUnderAgeOfConsent") ? call.getBoolean("tagForUnderAgeOfConsent") : null;
|
|
10
|
+
Boolean isTesting = call.getBoolean("isTesting", false);
|
|
11
|
+
diff --git a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java
|
|
12
|
+
index 8b984f2..e2cf878 100644
|
|
13
|
+
--- a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java
|
|
14
|
+
+++ b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java
|
|
15
|
+
@@ -330,6 +330,30 @@ public class BannerExecutor {
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
+ private int getEffectiveSystemInset(int inset, boolean top) {
|
|
20
|
+
+ if (inset <= 0) return 0;
|
|
21
|
+
+
|
|
22
|
+
+ Activity activity = plugin.getActivity();
|
|
23
|
+
+ if (activity == null) return 0;
|
|
24
|
+
+
|
|
25
|
+
+ View layoutView = capacitorAdLayout != null && capacitorAdLayout.getHeight() > 0
|
|
26
|
+
+ ? capacitorAdLayout : activity.getWindow().getDecorView();
|
|
27
|
+
+ int[] location = new int[2];
|
|
28
|
+
+ layoutView.getLocationOnScreen(location);
|
|
29
|
+
+ if (top) return Math.min(inset, Math.max(0, inset - location[1]));
|
|
30
|
+
+
|
|
31
|
+
+ int screenBottom;
|
|
32
|
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
33
|
+
+ screenBottom = activity.getWindowManager().getCurrentWindowMetrics().getBounds().bottom;
|
|
34
|
+
+ } else {
|
|
35
|
+
+ android.graphics.Point screenSize = new android.graphics.Point();
|
|
36
|
+
+ activity.getWindowManager().getDefaultDisplay().getRealSize(screenSize);
|
|
37
|
+
+ screenBottom = screenSize.y;
|
|
38
|
+
+ }
|
|
39
|
+
+ int layoutBottom = location[1] + layoutView.getHeight();
|
|
40
|
+
+ return Math.min(inset, Math.max(0, layoutBottom - (screenBottom - inset)));
|
|
41
|
+
+ }
|
|
42
|
+
+
|
|
43
|
+
private void updateBannerLayout() {
|
|
44
|
+
|
|
45
|
+
if (Build.VERSION.SDK_INT < 35) {
|
|
46
|
+
@@ -346,10 +370,10 @@ public class BannerExecutor {
|
|
47
|
+
|
|
48
|
+
if ("TOP".equals(currentPosition)) {
|
|
49
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
50
|
+
- bannerParams.setMargins(0, systemSafeTop, 0, 0);
|
|
51
|
+
+ bannerParams.setMargins(0, getEffectiveSystemInset(systemSafeTop, true), 0, 0);
|
|
52
|
+
} else {
|
|
53
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
54
|
+
- bannerParams.setMargins(0, 0, 0, systemSafeBottom);
|
|
55
|
+
+ bannerParams.setMargins(0, 0, 0, getEffectiveSystemInset(systemSafeBottom, false));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
adView.setLayoutParams(bannerParams);
|
|
59
|
+
@@ -399,11 +423,11 @@ public class BannerExecutor {
|
|
60
|
+
|
|
61
|
+
if ("TOP".equals(currentPosition)) {
|
|
62
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
63
|
+
- int baseTop = legacyApplyBannerInsets ? topMargin : 0;
|
|
64
|
+
+ int baseTop = legacyApplyBannerInsets ? getEffectiveSystemInset(topMargin, true) : 0;
|
|
65
|
+
bannerParams.setMargins(0, baseTop + legacyMarginOffset, 0, 0);
|
|
66
|
+
} else {
|
|
67
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
68
|
+
- int baseBottom = legacyApplyBannerInsets ? bottomMargin : 0;
|
|
69
|
+
+ int baseBottom = legacyApplyBannerInsets ? getEffectiveSystemInset(bottomMargin, false) : 0;
|
|
70
|
+
bannerParams.setMargins(0, 0, 0, baseBottom + legacyMarginOffset);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@@ -440,8 +464,10 @@ public class BannerExecutor {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
- int baseTop = legacyApplyWebviewInsets ? topMargin : 0;
|
|
78
|
+
- int baseBottom = legacyApplyWebviewInsets ? bottomMargin : 0;
|
|
79
|
+
+ int effectiveTop = getEffectiveSystemInset(topMargin, true);
|
|
80
|
+
+ int effectiveBottom = getEffectiveSystemInset(bottomMargin, false);
|
|
81
|
+
+ int baseTop = legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
82
|
+
+ int baseBottom = legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
83
|
+
|
|
84
|
+
if (!isBannerVisible) {
|
|
85
|
+
|
|
86
|
+
@@ -454,11 +480,13 @@ public class BannerExecutor {
|
|
87
|
+
} else {
|
|
88
|
+
|
|
89
|
+
if ("TOP".equals(currentPosition)) {
|
|
90
|
+
- params.topMargin = lastAdHeight + baseTop + legacyMarginOffset;
|
|
91
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
92
|
+
+ params.topMargin = lastAdHeight + baseTop + bannerInset + legacyMarginOffset;
|
|
93
|
+
params.bottomMargin = baseBottom;
|
|
94
|
+
} else {
|
|
95
|
+
params.topMargin = baseTop;
|
|
96
|
+
- params.bottomMargin = lastAdHeight + baseBottom + legacyMarginOffset;
|
|
97
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
98
|
+
+ params.bottomMargin = lastAdHeight + baseBottom + bannerInset + legacyMarginOffset;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@@ -487,11 +515,11 @@ public class BannerExecutor {
|
|
103
|
+
params.bottomMargin = 0;
|
|
104
|
+
} else {
|
|
105
|
+
if ("TOP".equals(currentPosition)) {
|
|
106
|
+
- params.topMargin = lastAdHeight;
|
|
107
|
+
+ params.topMargin = lastAdHeight + getEffectiveSystemInset(systemSafeTop, true);
|
|
108
|
+
params.bottomMargin = 0;
|
|
109
|
+
} else {
|
|
110
|
+
params.topMargin = 0;
|
|
111
|
+
- params.bottomMargin = lastAdHeight;
|
|
112
|
+
+ params.bottomMargin = lastAdHeight + getEffectiveSystemInset(systemSafeBottom, false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
diff --git a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java
|
|
117
|
+
index 4a445fe..ee0a633 100644
|
|
118
|
+
--- a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java
|
|
119
|
+
+++ b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java
|
|
120
|
+
@@ -291,6 +291,30 @@ public class BannerPreloadExecutor {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
+ private int getEffectiveSystemInset(int inset, boolean top) {
|
|
125
|
+
+ if (inset <= 0) return 0;
|
|
126
|
+
+
|
|
127
|
+
+ Activity activity = plugin.getActivity();
|
|
128
|
+
+ if (activity == null) return 0;
|
|
129
|
+
+
|
|
130
|
+
+ View layoutView = capacitorAdLayout != null && capacitorAdLayout.getHeight() > 0
|
|
131
|
+
+ ? capacitorAdLayout : activity.getWindow().getDecorView();
|
|
132
|
+
+ int[] location = new int[2];
|
|
133
|
+
+ layoutView.getLocationOnScreen(location);
|
|
134
|
+
+ if (top) return Math.min(inset, Math.max(0, inset - location[1]));
|
|
135
|
+
+
|
|
136
|
+
+ int screenBottom;
|
|
137
|
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
138
|
+
+ screenBottom = activity.getWindowManager().getCurrentWindowMetrics().getBounds().bottom;
|
|
139
|
+
+ } else {
|
|
140
|
+
+ android.graphics.Point screenSize = new android.graphics.Point();
|
|
141
|
+
+ activity.getWindowManager().getDefaultDisplay().getRealSize(screenSize);
|
|
142
|
+
+ screenBottom = screenSize.y;
|
|
143
|
+
+ }
|
|
144
|
+
+ int layoutBottom = location[1] + layoutView.getHeight();
|
|
145
|
+
+ return Math.min(inset, Math.max(0, layoutBottom - (screenBottom - inset)));
|
|
146
|
+
+ }
|
|
147
|
+
+
|
|
148
|
+
private void updateBannerLayout() {
|
|
149
|
+
|
|
150
|
+
if (Build.VERSION.SDK_INT < 35) {
|
|
151
|
+
@@ -307,10 +331,10 @@ public class BannerPreloadExecutor {
|
|
152
|
+
|
|
153
|
+
if ("TOP".equals(currentPosition)) {
|
|
154
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
155
|
+
- bannerParams.setMargins(0, systemSafeTop, 0, 0);
|
|
156
|
+
+ bannerParams.setMargins(0, getEffectiveSystemInset(systemSafeTop, true), 0, 0);
|
|
157
|
+
} else {
|
|
158
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
159
|
+
- bannerParams.setMargins(0, 0, 0, systemSafeBottom);
|
|
160
|
+
+ bannerParams.setMargins(0, 0, 0, getEffectiveSystemInset(systemSafeBottom, false));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
adView.setLayoutParams(bannerParams);
|
|
164
|
+
@@ -360,11 +384,11 @@ public class BannerPreloadExecutor {
|
|
165
|
+
|
|
166
|
+
if ("TOP".equals(currentPosition)) {
|
|
167
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
168
|
+
- int baseTop = legacyApplyBannerInsets ? topMargin : 0;
|
|
169
|
+
+ int baseTop = legacyApplyBannerInsets ? getEffectiveSystemInset(topMargin, true) : 0;
|
|
170
|
+
bannerParams.setMargins(0, baseTop + legacyMarginOffset, 0, 0);
|
|
171
|
+
} else {
|
|
172
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
173
|
+
- int baseBottom = legacyApplyBannerInsets ? bottomMargin : 0;
|
|
174
|
+
+ int baseBottom = legacyApplyBannerInsets ? getEffectiveSystemInset(bottomMargin, false) : 0;
|
|
175
|
+
bannerParams.setMargins(0, 0, 0, baseBottom + legacyMarginOffset);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@@ -401,8 +425,10 @@ public class BannerPreloadExecutor {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
- int baseTop = legacyApplyWebviewInsets ? topMargin : 0;
|
|
183
|
+
- int baseBottom = legacyApplyWebviewInsets ? bottomMargin : 0;
|
|
184
|
+
+ int effectiveTop = getEffectiveSystemInset(topMargin, true);
|
|
185
|
+
+ int effectiveBottom = getEffectiveSystemInset(bottomMargin, false);
|
|
186
|
+
+ int baseTop = legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
187
|
+
+ int baseBottom = legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
188
|
+
|
|
189
|
+
if (!isBannerVisible) {
|
|
190
|
+
|
|
191
|
+
@@ -415,11 +441,13 @@ public class BannerPreloadExecutor {
|
|
192
|
+
} else {
|
|
193
|
+
|
|
194
|
+
if ("TOP".equals(currentPosition)) {
|
|
195
|
+
- params.topMargin = lastAdHeight + baseTop + legacyMarginOffset;
|
|
196
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
197
|
+
+ params.topMargin = lastAdHeight + baseTop + bannerInset + legacyMarginOffset;
|
|
198
|
+
params.bottomMargin = baseBottom;
|
|
199
|
+
} else {
|
|
200
|
+
params.topMargin = baseTop;
|
|
201
|
+
- params.bottomMargin = lastAdHeight + baseBottom + legacyMarginOffset;
|
|
202
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
203
|
+
+ params.bottomMargin = lastAdHeight + baseBottom + bannerInset + legacyMarginOffset;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@@ -448,10 +476,10 @@ public class BannerPreloadExecutor {
|
|
208
|
+
params.bottomMargin = 0;
|
|
209
|
+
} else {
|
|
210
|
+
if ("TOP".equals(currentPosition)) {
|
|
211
|
+
- params.topMargin = lastAdHeight;
|
|
212
|
+
+ params.topMargin = lastAdHeight + getEffectiveSystemInset(systemSafeTop, true);
|
|
213
|
+
params.bottomMargin = 0;
|
|
214
|
+
} else {
|
|
215
|
+
params.topMargin = 0;
|
|
216
|
+
- params.bottomMargin = lastAdHeight;
|
|
217
|
+
+ params.bottomMargin = lastAdHeight + getEffectiveSystemInset(systemSafeBottom, false);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
diff --git a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java
|
|
2
|
+
index 8b984f2..e2cf878 100644
|
|
3
|
+
--- a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java
|
|
4
|
+
+++ b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/banner/BannerExecutor.java
|
|
5
|
+
@@ -330,6 +330,30 @@ public class BannerExecutor {
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
+ private int getEffectiveSystemInset(int inset, boolean top) {
|
|
10
|
+
+ if (inset <= 0) return 0;
|
|
11
|
+
+
|
|
12
|
+
+ Activity activity = plugin.getActivity();
|
|
13
|
+
+ if (activity == null) return 0;
|
|
14
|
+
+
|
|
15
|
+
+ View layoutView = capacitorAdLayout != null && capacitorAdLayout.getHeight() > 0
|
|
16
|
+
+ ? capacitorAdLayout : activity.getWindow().getDecorView();
|
|
17
|
+
+ int[] location = new int[2];
|
|
18
|
+
+ layoutView.getLocationOnScreen(location);
|
|
19
|
+
+ if (top) return Math.min(inset, Math.max(0, inset - location[1]));
|
|
20
|
+
+
|
|
21
|
+
+ int screenBottom;
|
|
22
|
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
23
|
+
+ screenBottom = activity.getWindowManager().getCurrentWindowMetrics().getBounds().bottom;
|
|
24
|
+
+ } else {
|
|
25
|
+
+ android.graphics.Point screenSize = new android.graphics.Point();
|
|
26
|
+
+ activity.getWindowManager().getDefaultDisplay().getRealSize(screenSize);
|
|
27
|
+
+ screenBottom = screenSize.y;
|
|
28
|
+
+ }
|
|
29
|
+
+ int layoutBottom = location[1] + layoutView.getHeight();
|
|
30
|
+
+ return Math.min(inset, Math.max(0, layoutBottom - (screenBottom - inset)));
|
|
31
|
+
+ }
|
|
32
|
+
+
|
|
33
|
+
private void updateBannerLayout() {
|
|
34
|
+
|
|
35
|
+
if (Build.VERSION.SDK_INT < 35) {
|
|
36
|
+
@@ -346,10 +370,10 @@ public class BannerExecutor {
|
|
37
|
+
|
|
38
|
+
if ("TOP".equals(currentPosition)) {
|
|
39
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
40
|
+
- bannerParams.setMargins(0, systemSafeTop, 0, 0);
|
|
41
|
+
+ bannerParams.setMargins(0, getEffectiveSystemInset(systemSafeTop, true), 0, 0);
|
|
42
|
+
} else {
|
|
43
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
44
|
+
- bannerParams.setMargins(0, 0, 0, systemSafeBottom);
|
|
45
|
+
+ bannerParams.setMargins(0, 0, 0, getEffectiveSystemInset(systemSafeBottom, false));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
adView.setLayoutParams(bannerParams);
|
|
49
|
+
@@ -399,11 +423,11 @@ public class BannerExecutor {
|
|
50
|
+
|
|
51
|
+
if ("TOP".equals(currentPosition)) {
|
|
52
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
53
|
+
- int baseTop = legacyApplyBannerInsets ? topMargin : 0;
|
|
54
|
+
+ int baseTop = legacyApplyBannerInsets ? getEffectiveSystemInset(topMargin, true) : 0;
|
|
55
|
+
bannerParams.setMargins(0, baseTop + legacyMarginOffset, 0, 0);
|
|
56
|
+
} else {
|
|
57
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
58
|
+
- int baseBottom = legacyApplyBannerInsets ? bottomMargin : 0;
|
|
59
|
+
+ int baseBottom = legacyApplyBannerInsets ? getEffectiveSystemInset(bottomMargin, false) : 0;
|
|
60
|
+
bannerParams.setMargins(0, 0, 0, baseBottom + legacyMarginOffset);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@@ -440,8 +464,10 @@ public class BannerExecutor {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- int baseTop = legacyApplyWebviewInsets ? topMargin : 0;
|
|
68
|
+
- int baseBottom = legacyApplyWebviewInsets ? bottomMargin : 0;
|
|
69
|
+
+ int effectiveTop = getEffectiveSystemInset(topMargin, true);
|
|
70
|
+
+ int effectiveBottom = getEffectiveSystemInset(bottomMargin, false);
|
|
71
|
+
+ int baseTop = legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
72
|
+
+ int baseBottom = legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
73
|
+
|
|
74
|
+
if (!isBannerVisible) {
|
|
75
|
+
|
|
76
|
+
@@ -454,11 +480,13 @@ public class BannerExecutor {
|
|
77
|
+
} else {
|
|
78
|
+
|
|
79
|
+
if ("TOP".equals(currentPosition)) {
|
|
80
|
+
- params.topMargin = lastAdHeight + baseTop + legacyMarginOffset;
|
|
81
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
82
|
+
+ params.topMargin = lastAdHeight + baseTop + bannerInset + legacyMarginOffset;
|
|
83
|
+
params.bottomMargin = baseBottom;
|
|
84
|
+
} else {
|
|
85
|
+
params.topMargin = baseTop;
|
|
86
|
+
- params.bottomMargin = lastAdHeight + baseBottom + legacyMarginOffset;
|
|
87
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
88
|
+
+ params.bottomMargin = lastAdHeight + baseBottom + bannerInset + legacyMarginOffset;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@@ -487,11 +515,11 @@ public class BannerExecutor {
|
|
93
|
+
params.bottomMargin = 0;
|
|
94
|
+
} else {
|
|
95
|
+
if ("TOP".equals(currentPosition)) {
|
|
96
|
+
- params.topMargin = lastAdHeight;
|
|
97
|
+
+ params.topMargin = lastAdHeight + getEffectiveSystemInset(systemSafeTop, true);
|
|
98
|
+
params.bottomMargin = 0;
|
|
99
|
+
} else {
|
|
100
|
+
params.topMargin = 0;
|
|
101
|
+
- params.bottomMargin = lastAdHeight;
|
|
102
|
+
+ params.bottomMargin = lastAdHeight + getEffectiveSystemInset(systemSafeBottom, false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
diff --git a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java
|
|
107
|
+
index 4a445fe..ee0a633 100644
|
|
108
|
+
--- a/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java
|
|
109
|
+
+++ b/node_modules/capacitor-admob-nextgen/android/src/main/java/com/emi/plugins/admob/preloading/BannerPreloadExecutor.java
|
|
110
|
+
@@ -291,6 +291,30 @@ public class BannerPreloadExecutor {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
+ private int getEffectiveSystemInset(int inset, boolean top) {
|
|
115
|
+
+ if (inset <= 0) return 0;
|
|
116
|
+
+
|
|
117
|
+
+ Activity activity = plugin.getActivity();
|
|
118
|
+
+ if (activity == null) return 0;
|
|
119
|
+
+
|
|
120
|
+
+ View layoutView = capacitorAdLayout != null && capacitorAdLayout.getHeight() > 0
|
|
121
|
+
+ ? capacitorAdLayout : activity.getWindow().getDecorView();
|
|
122
|
+
+ int[] location = new int[2];
|
|
123
|
+
+ layoutView.getLocationOnScreen(location);
|
|
124
|
+
+ if (top) return Math.min(inset, Math.max(0, inset - location[1]));
|
|
125
|
+
+
|
|
126
|
+
+ int screenBottom;
|
|
127
|
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
128
|
+
+ screenBottom = activity.getWindowManager().getCurrentWindowMetrics().getBounds().bottom;
|
|
129
|
+
+ } else {
|
|
130
|
+
+ android.graphics.Point screenSize = new android.graphics.Point();
|
|
131
|
+
+ activity.getWindowManager().getDefaultDisplay().getRealSize(screenSize);
|
|
132
|
+
+ screenBottom = screenSize.y;
|
|
133
|
+
+ }
|
|
134
|
+
+ int layoutBottom = location[1] + layoutView.getHeight();
|
|
135
|
+
+ return Math.min(inset, Math.max(0, layoutBottom - (screenBottom - inset)));
|
|
136
|
+
+ }
|
|
137
|
+
+
|
|
138
|
+
private void updateBannerLayout() {
|
|
139
|
+
|
|
140
|
+
if (Build.VERSION.SDK_INT < 35) {
|
|
141
|
+
@@ -307,10 +331,10 @@ public class BannerPreloadExecutor {
|
|
142
|
+
|
|
143
|
+
if ("TOP".equals(currentPosition)) {
|
|
144
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
145
|
+
- bannerParams.setMargins(0, systemSafeTop, 0, 0);
|
|
146
|
+
+ bannerParams.setMargins(0, getEffectiveSystemInset(systemSafeTop, true), 0, 0);
|
|
147
|
+
} else {
|
|
148
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
149
|
+
- bannerParams.setMargins(0, 0, 0, systemSafeBottom);
|
|
150
|
+
+ bannerParams.setMargins(0, 0, 0, getEffectiveSystemInset(systemSafeBottom, false));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
adView.setLayoutParams(bannerParams);
|
|
154
|
+
@@ -360,11 +384,11 @@ public class BannerPreloadExecutor {
|
|
155
|
+
|
|
156
|
+
if ("TOP".equals(currentPosition)) {
|
|
157
|
+
bannerParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
|
158
|
+
- int baseTop = legacyApplyBannerInsets ? topMargin : 0;
|
|
159
|
+
+ int baseTop = legacyApplyBannerInsets ? getEffectiveSystemInset(topMargin, true) : 0;
|
|
160
|
+
bannerParams.setMargins(0, baseTop + legacyMarginOffset, 0, 0);
|
|
161
|
+
} else {
|
|
162
|
+
bannerParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
|
163
|
+
- int baseBottom = legacyApplyBannerInsets ? bottomMargin : 0;
|
|
164
|
+
+ int baseBottom = legacyApplyBannerInsets ? getEffectiveSystemInset(bottomMargin, false) : 0;
|
|
165
|
+
bannerParams.setMargins(0, 0, 0, baseBottom + legacyMarginOffset);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@@ -401,8 +425,10 @@ public class BannerPreloadExecutor {
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
- int baseTop = legacyApplyWebviewInsets ? topMargin : 0;
|
|
173
|
+
- int baseBottom = legacyApplyWebviewInsets ? bottomMargin : 0;
|
|
174
|
+
+ int effectiveTop = getEffectiveSystemInset(topMargin, true);
|
|
175
|
+
+ int effectiveBottom = getEffectiveSystemInset(bottomMargin, false);
|
|
176
|
+
+ int baseTop = legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
177
|
+
+ int baseBottom = legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
178
|
+
|
|
179
|
+
if (!isBannerVisible) {
|
|
180
|
+
|
|
181
|
+
@@ -415,11 +441,13 @@ public class BannerPreloadExecutor {
|
|
182
|
+
} else {
|
|
183
|
+
|
|
184
|
+
if ("TOP".equals(currentPosition)) {
|
|
185
|
+
- params.topMargin = lastAdHeight + baseTop + legacyMarginOffset;
|
|
186
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveTop : 0;
|
|
187
|
+
+ params.topMargin = lastAdHeight + baseTop + bannerInset + legacyMarginOffset;
|
|
188
|
+
params.bottomMargin = baseBottom;
|
|
189
|
+
} else {
|
|
190
|
+
params.topMargin = baseTop;
|
|
191
|
+
- params.bottomMargin = lastAdHeight + baseBottom + legacyMarginOffset;
|
|
192
|
+
+ int bannerInset = legacyApplyBannerInsets && !legacyApplyWebviewInsets ? effectiveBottom : 0;
|
|
193
|
+
+ params.bottomMargin = lastAdHeight + baseBottom + bannerInset + legacyMarginOffset;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@@ -448,10 +476,10 @@ public class BannerPreloadExecutor {
|
|
198
|
+
params.bottomMargin = 0;
|
|
199
|
+
} else {
|
|
200
|
+
if ("TOP".equals(currentPosition)) {
|
|
201
|
+
- params.topMargin = lastAdHeight;
|
|
202
|
+
+ params.topMargin = lastAdHeight + getEffectiveSystemInset(systemSafeTop, true);
|
|
203
|
+
params.bottomMargin = 0;
|
|
204
|
+
} else {
|
|
205
|
+
params.topMargin = 0;
|
|
206
|
+
- params.bottomMargin = lastAdHeight;
|
|
207
|
+
+ params.bottomMargin = lastAdHeight + getEffectiveSystemInset(systemSafeBottom, false);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -127,24 +127,27 @@ function getBaselineProfileGenerator(modulePackage, appId) {
|
|
|
127
127
|
|
|
128
128
|
function ensureBaselineProfilePlugin() {
|
|
129
129
|
const rootBuildGradle = path.join(androidDir, 'build.gradle');
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
const coreFile = path.join(rootDir, 'node_modules', '@capacitor', 'core', 'package.json');
|
|
131
|
+
const capacitor9 = fs.existsSync(coreFile) && JSON.parse(readFile(coreFile)).version.startsWith('9.');
|
|
132
|
+
const version = capacitor9 ? '1.5.0' : '1.4.1';
|
|
133
|
+
patchFile(rootBuildGradle, (content) => {
|
|
134
|
+
const plugin = /classpath ['"]androidx\.baselineprofile:androidx\.baselineprofile\.gradle\.plugin:[^'"]+['"]/;
|
|
135
|
+
const declaration = `classpath 'androidx.baselineprofile:androidx.baselineprofile.gradle.plugin:${version}'`;
|
|
136
|
+
if (plugin.test(content)) return content.replace(plugin, declaration);
|
|
137
|
+
const agp = /classpath ['"]com\.android\.tools\.build:gradle:[^'"]+['"]/;
|
|
138
|
+
if (!agp.test(content)) throw new Error('Android Gradle plugin declaration not found; baseline profile setup stopped.');
|
|
139
|
+
return content.replace(agp, match => `${match}\n ${declaration}`);
|
|
140
|
+
});
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
function ensureSettingsModule() {
|
|
140
144
|
const settingsGradle = path.join(androidDir, 'settings.gradle');
|
|
141
|
-
patchFile(settingsGradle, (content) =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
145
|
+
patchFile(settingsGradle, (content) => {
|
|
146
|
+
const block = "include ':baselineprofile'\nproject(':baselineprofile').projectDir = new File('./baselineprofile/')";
|
|
147
|
+
const normalized = content.replace(/^include ':baselineprofile'\r?\nproject\(':baselineprofile'\)\.projectDir = new File\('\.\/baselineprofile\/'\)\r?\n?/gm, '').replace(/\n{3,}/g, '\n\n');
|
|
148
|
+
if (!normalized.includes("include ':app'")) throw new Error('Android app module not found; baseline profile setup stopped.');
|
|
149
|
+
return normalized.replace("include ':app'", `include ':app'\n${block}`);
|
|
150
|
+
});
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
function ensureAppGradle() {
|
|
@@ -278,7 +281,7 @@ function main() {
|
|
|
278
281
|
console.log('Baseline Profile setup is ready.');
|
|
279
282
|
}
|
|
280
283
|
|
|
281
|
-
module.exports = { syncGeneratedProfileBackup };
|
|
284
|
+
module.exports = { main, syncGeneratedProfileBackup };
|
|
282
285
|
|
|
283
286
|
if (require.main === module) main();
|
|
284
287
|
|