Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Termux integration #997

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
11 changes: 10 additions & 1 deletion config.xml
bajrangCoder marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="prerendered-icon" value="false" />
<preference name="androidxEnabled" value="true" />
<preference name="gradleVersion" value="8.5" />
<preference name="android-buildToolsVersion" value="35.0.0" />

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:networkSecurityConfig="@xml/network_security_config" />
<application android:hardwareAccelerated="true" />
<application android:requestLegacyExternalStorage="true" />
<application android:largeHeap="true" />
<application>
<service android:name="com.foxdebug.system.PluginResultService" />
</application>
</edit-config>

<config-file parent="./application/activity" target="AndroidManifest.xml">
Expand Down Expand Up @@ -68,11 +73,15 @@
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest">
<queries>
<package android:name="com.termux" />
</queries>

<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" />
<!-- <uses-permission android:name="com.termux.permission.RUN_COMMAND" /> -->
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
</config-file>

<hook type="before_prepare" src="hooks/modify-java-files.js" />
Expand Down
1,120 changes: 1,108 additions & 12 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
"cordova-clipboard": {},
"cordova-plugin-buildinfo": {},
"cordova-plugin-device": {},
"cordova-plugin-file": {},
"cordova-plugin-file": {
"ANDROIDX_WEBKIT_VERSION": "1.4.0"
},
"cordova-plugin-sftp": {},
"cordova-plugin-server": {},
"cordova-plugin-ftp": {},
"cordova-plugin-sdcard": {},
"cordova-plugin-browser": {},
"cordova-plugin-system": {},
"cordova-plugin-iap": {}
"cordova-plugin-iap": {},
"@spoonconsulting/cordova-plugin-local-notification": {},
"cordova-plugin-system": {}
},
"platforms": [
"android"
Expand All @@ -49,18 +52,21 @@
"@babel/preset-env": "^7.24.6",
"@babel/runtime": "^7.24.6",
"@babel/runtime-corejs3": "^7.24.6",
"@spoonconsulting/cordova-plugin-local-notification": "^1.0.6",
"@types/ace": "^0.0.52",
"@types/url-parse": "^1.4.11",
"autoprefixer": "^10.4.19",
"babel-loader": "^9.1.3",
"cordova-android": "^13.0.0",
"cordova-clipboard": "^1.3.0",
"cordova-plugin-badge": "^0.8.9",
"cordova-plugin-browser": "file:src/plugins/browser",
"cordova-plugin-buildinfo": "^4.0.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "^8.0.1",
"cordova-plugin-ftp": "file:src/plugins/ftp",
"cordova-plugin-iap": "file:src/plugins/iap",
"cordova-plugin-local-notifications": "^1.0.0",
"cordova-plugin-sdcard": "file:src/plugins/sdcard",
"cordova-plugin-server": "file:src/plugins/server",
"cordova-plugin-sftp": "file:src/plugins/sftp",
Expand Down
5 changes: 5 additions & 0 deletions src/lib/acode.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import formatterSettings from "settings/formatterSettings";
import settingsPage from 'components/settingsPage';
import SideButton from 'components/sideButton';

import ptyModule, { setup } from "lib/pty";

import { addedFolder } from 'lib/openFolder';
import { decode, encode } from 'utils/encodings';
import { addMode, removeMode } from 'ace/modelist';
Expand Down Expand Up @@ -99,6 +101,7 @@ export default class Acode {
this.define('toast', toast);
this.define('alert', alert);
this.define('select', select);
this.define("pty", ptyModule);
this.define('loader', loader);
this.define('dialogBox', box);
this.define('prompt', prompt);
Expand Down Expand Up @@ -134,6 +137,8 @@ export default class Acode {
this.define('toInternalUrl', helpers.toInternalUri);
}

async initialize() { setup() }

/**
* Define a module
* @param {string} name
Expand Down
5 changes: 4 additions & 1 deletion src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ export default {
get PLAY_STORE_URL() { return `https://play.google.com/store/apps/details?id=${BuildInfo.packageName}`; },
API_BASE: 'https://acode.app/api',
// API_BASE: 'https://192.168.0.102:3001/api', // test api
SKU_LIST: ["basic", "bronze", "silver", "gold", "platinum"]
SKU_LIST: ["basic", "bronze", "silver", "gold", "platinum"],

// PTY Executor
EXECUTOR_PACKAGE_NAME: "com.termux"
};
9 changes: 9 additions & 0 deletions src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ async function onDeviceReady() {
})();
window.acode = new Acode();

system.requestPermission("com.termux.permission.RUN_COMMAND");
system.requestPermission('android.permission.READ_EXTERNAL_STORAGE');
system.requestPermission('android.permission.WRITE_EXTERNAL_STORAGE');

Expand Down Expand Up @@ -323,6 +324,14 @@ async function loadApp() {
}
})
.catch(console.error);

try {
acode.setLoadingMessage("Loading pty host");
await acode.initialize();
} catch (error) {
console.error(error);
toast("Error loading pty host!");
}

//load plugins
try {
Expand Down
Loading