Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.sh text eol=lf
config.xml text eol=lf
101 changes: 101 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

on:
push:
branches:
- main
pull_request:
merge_group:

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
spell-check:
timeout-minutes: 5
Expand Down Expand Up @@ -35,7 +41,102 @@
- name: Run Biome
run: biome ci .

unit-tests:
timeout-minutes: 15
name: Unit and dependency checks
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Use Node.js
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
cache-dependency-path: |
package-lock.json
src/plugins/admob/package-lock.json
src/plugins/cordova-plugin-advanced-http/package-lock.json
- name: Use Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.9

- name: Install dependencies
run: npm ci --no-audit --no-fund

- name: Run JavaScript tests
run: npm test

- name: Run typecheck
run: npm run typecheck

- name: Verify generated AdMob bundle
run: |
npm run build:admob
npm run check:admob-bundle
git diff --exit-code -- src/plugins/admob/www/admob.js
- name: Verify Bun lockfile
run: bun install --frozen-lockfile --dry-run

- name: Reject critical dependency advisories
run: |
npm audit --package-lock-only --audit-level=critical
npm audit --prefix src/plugins/admob --package-lock-only --audit-level=critical
npm audit --prefix src/plugins/cordova-plugin-advanced-http --package-lock-only --audit-level=critical
admob-native-tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +45 to +92
timeout-minutes: 30
name: AdMob Android unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Use Node.js
uses: actions/setup-node@v7
with:
node-version: 22
cache: npm

- name: Use Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"

- name: Use Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.14.2"

- name: Install dependencies
run: npm ci --no-audit --no-fund

- name: Prepare Android test project
run: |
npx cordova platform add android --nosave
NPM_CONFIG_LEGACY_PEER_DEPS=true npx cordova plugin add src/plugins/admob --nosave
- name: Run AdMob Android unit tests
run: npm run test:admob:native

- name: Verify native setup kept tracked sources clean
run: |
git diff --exit-code -- \
package.json \
package-lock.json \
bun.lock \
config.xml \
res/android/values/ic_launcher_background.xml \
src/plugins/admob/www/admob.js
translation-check:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Translation Check (On PR Only)
timeout-minutes: 5
runs-on: ubuntu-latest
Expand Down
2,936 changes: 1,048 additions & 1,888 deletions bun.lock

Large diffs are not rendered by default.

183 changes: 93 additions & 90 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,90 +1,93 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foxdebug.acode" android-versionCode="1001" version="1.12.6"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Acode</name>
<description>
Light weight code editor and web IDE for android.
</description>
<author email="ajit@foxdebug.com" href="https://foxdebug.com">
Foxdebug
</author>
<content src="index.html" />
<access launch-external="yes" origin="*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="http://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

<platform name="android">
<allow-intent href="market:*" />
<preference name="fullscreen" value="false" />
<preference name="SplashScreen" value="none" />
<preference name="ShowTitle" value="true" />
<preference name="DisallowOverscroll" value="true" />
<preference name="BackgroundColor" value="0xFF313131" />
<preference name="AndroidWindowSplashScreenBackground" value="@color/ic_splash_background" />
<preference name="AndroidWindowSplashScreenAnimatedIcon"
value="res/android/drawable/ic_launcher_foreground.xml" />
<preference name="AndroidPostSplashScreenTheme" value="@style/Theme.App.Activity" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="prerendered-icon" value="false" />
<preference name="androidxEnabled" value="true" />
<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="android-targetSdkVersion" value="36" />
<preference name="android-minSdkVersion" value="26" />


<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
target="/manifest/application">
<application
android:networkSecurityConfig="@xml/network_security_config"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:enableOnBackInvokedCallback="false" />
</edit-config>

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
target="/manifest/application/activity[@android:name='MainActivity']">
<activity android:resizeableActivity="true" />
</edit-config>

<config-file parent="./application/activity" target="AndroidManifest.xml">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="file" android:mimeType="*/*" />
<data android:scheme="content" android:mimeType="*/*" />
</intent-filter>
<!-- Allow app to open using url from browser -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="acode" />
</intent-filter>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
</config-file>

<hook type="before_prepare" src="hooks/restore-cordova-resources.js" />
<hook type="before_prepare" src="hooks/modify-java-files.js" />
<hook type="after_prepare" src="hooks/post-process.js" />
</platform>
<preference name="AndroidBlacklistSecureSocketProtocols" value="SSLv3,TLSv1" />
</widget>
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foxdebug.acode" android-versionCode="1001" version="1.12.6"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Acode</name>
<description>
Light weight code editor and web IDE for android.
</description>
<author email="ajit@foxdebug.com" href="https://foxdebug.com">
Foxdebug
</author>
<content src="index.html" />
<access launch-external="yes" origin="*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="http://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

<platform name="android">
<allow-intent href="market:*" />
<preference name="GradlePluginKotlinVersion" value="2.3.0" />
<preference name="fullscreen" value="false" />
<preference name="SplashScreen" value="none" />
<preference name="ShowTitle" value="true" />
<preference name="DisallowOverscroll" value="true" />
<preference name="BackgroundColor" value="0xFF313131" />
<preference name="AndroidWindowSplashScreenBackground" value="@color/ic_splash_background" />
<preference name="AndroidWindowSplashScreenAnimatedIcon"
value="res/android/drawable/ic_launcher_foreground.xml" />
<preference name="AndroidPostSplashScreenTheme" value="@style/Theme.App.Activity" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="prerendered-icon" value="false" />
<preference name="androidxEnabled" value="true" />
<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="android-targetSdkVersion" value="36" />
<preference name="android-minSdkVersion" value="26" />


<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
target="/manifest/application">
<application
android:networkSecurityConfig="@xml/network_security_config"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:enableOnBackInvokedCallback="false" />
</edit-config>

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
target="/manifest/application/activity[@android:name='MainActivity']">
<activity
android:resizeableActivity="true"
android:windowSoftInputMode="adjustResize" />
</edit-config>

<config-file parent="./application/activity" target="AndroidManifest.xml">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="file" android:mimeType="*/*" />
<data android:scheme="content" android:mimeType="*/*" />
</intent-filter>
<!-- Allow app to open using url from browser -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="acode" />
</intent-filter>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
</config-file>

<hook type="before_prepare" src="hooks/restore-cordova-resources.js" />
<hook type="before_prepare" src="hooks/modify-java-files.js" />
<hook type="after_prepare" src="hooks/post-process.js" />
</platform>
<preference name="AndroidBlacklistSecureSocketProtocols" value="SSLv3,TLSv1" />
</widget>
55 changes: 17 additions & 38 deletions hooks/post-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ fs.copyFileSync(gradleFilePath, androidGradleFilePath);
copyDirRecursively(localResPath, resPath);
enableLegacyJni();
enableStaticContext();
removeLegacyKeyboardWorkaround();
patchTargetSdkVersion();
enableKeyboardWorkaround();

function getPackageName() {
const configPath = path.resolve(__dirname, '../config.xml');
Expand Down Expand Up @@ -210,8 +210,8 @@ function enableStaticContext() {
}
}

function enableKeyboardWorkaround() {
try{
function removeLegacyKeyboardWorkaround() {
try {
const prefix = execSync('npm prefix').toString().trim();
const packageName = getPackageName();
const mainActivityPath = path.join(
Expand All @@ -222,51 +222,30 @@ function enableKeyboardWorkaround() {
);

if (!fs.existsSync(mainActivityPath)) {
console.warn('[Cordova Hook] ⚠️ MainActivity.java not found at', mainActivityPath);
return;
}

let content = fs.readFileSync(mainActivityPath, 'utf-8');

// Skip if already patched
if (content.includes('SoftInputAssist')) {
console.log('[Cordova Hook] ✅ Keyboard workaround already enabled, skipping');
return;
}

// Add import
if (!content.includes('import com.foxdebug.system.SoftInputAssist;')) {
content = content.replace(
/import java.lang.ref.WeakReference;|import org\.apache\.cordova\.\*;/,
match =>
match + '\nimport com.foxdebug.system.SoftInputAssist;'
const content = fs.readFileSync(mainActivityPath, 'utf-8');
const updatedContent = content
.replace(/\r?\nimport com\.foxdebug\.system\.SoftInputAssist;/, '')
.replace(/\r?\n\s*private SoftInputAssist softInputAssist;\r?\n/, '\n')
.replace(
/\r?\n\s*softInputAssist = new SoftInputAssist\(this\);/,
''
);
}

// Declare field
if (!content.includes('private SoftInputAssist softInputAssist;')) {
content = content.replace(
/public class MainActivity extends CordovaActivity\s*\{/,
match =>
match +
`\n\n private SoftInputAssist softInputAssist;\n`
);
if (updatedContent !== content) {
fs.writeFileSync(mainActivityPath, updatedContent, 'utf-8');
console.log('[Cordova Hook] ✅ Removed legacy keyboard workaround');
}

// Initialize in onCreate
content = content.replace(
/loadUrl\(launchUrl\);/,
`loadUrl(launchUrl);\n\n softInputAssist = new SoftInputAssist(this);`
);

fs.writeFileSync(mainActivityPath, content, 'utf-8');
console.log('[Cordova Hook] ✅ Enabled keyboard workaround');
} catch (err) {
console.error('[Cordova Hook] ❌ Failed to enable keyboard workaround:', err.message);
console.error(
'[Cordova Hook] ❌ Failed to remove legacy keyboard workaround:',
err.message
);
}
}


/**
* Copy directory recursively
* @param {string} src Source directory
Expand Down
Loading
Loading