WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Closed
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
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"cordova-plugin-sftp": {},
"cordova-plugin-system": {},
"com.foxdebug.acode.rk.exec.proot": {},
"com.foxdebug.acode.rk.exec.terminal": {}
"com.foxdebug.acode.rk.exec.terminal": {},
"com.foxdebug.acode.rk.customtabs": {}
},
"platforms": [
"android"
Expand All @@ -63,6 +64,7 @@
"@types/url-parse": "^1.4.11",
"autoprefixer": "^10.4.21",
"babel-loader": "^10.0.0",
"com.foxdebug.acode.rk.customtabs": "file:src/plugins/custom-tabs",
"com.foxdebug.acode.rk.exec.proot": "file:src/plugins/proot",
"com.foxdebug.acode.rk.exec.terminal": "file:src/plugins/terminal",
"cordova-android": "^14.0.1",
Expand Down
17 changes: 17 additions & 0 deletions src/plugins/custom-tabs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "com.foxdebug.acode.rk.customtabs",
"version": "1.0.0",
"description": "Custom tabs api",
"cordova": {
"id": "com.foxdebug.acode.rk.customtabs",
"platforms": [
"android"
]
},
"keywords": [
"ecosystem:cordova",
"cordova-android"
],
"author": "@RohitKushvaha01",
"license": "MIT"
}
36 changes: 36 additions & 0 deletions src/plugins/custom-tabs/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="com.foxdebug.acode.rk.customtabs" version="1.0.0">
<name>Custom Tabs</name>


<js-module name="CustomTabs" src="www/customtabs.js">
<clobbers target="CustomTabs"/>
</js-module>


<platform name="android">

<config-file parent="/*" target="res/xml/config.xml">
<feature name="CustomTabs">
<param name="android-package" value="com.foxdebug.acode.rk.customtabs.CustomTabsPlugin" />
</feature>

</config-file>

<config-file parent="/*" target="AndroidManifest.xml">
<queries>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
</config-file>

<framework src="androidx.browser:browser:1.8.0"/>

<source-file
src="src/CustomTabsPlugin.java"
target-dir="src/com/foxdebug/acode/rk/customtabs"/>


</platform>
</plugin>
80 changes: 80 additions & 0 deletions src/plugins/custom-tabs/src/CustomTabsPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.foxdebug.acode.rk.customtabs;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.graphics.Color;

import androidx.browser.customtabs.CustomTabsIntent;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;

public class CustomTabsPlugin extends CordovaPlugin {

@Override
public boolean execute(
String action,
JSONArray args,
CallbackContext callbackContext
) {

if ("open".equals(action)) {
try {
final String url = args.getString(0);
final JSONObject options = args.optJSONObject(1) != null
? args.optJSONObject(1)
: new JSONObject();

cordova.getActivity().runOnUiThread(() -> {
try {
openCustomTab(url, options);
callbackContext.success();
} catch (Exception e) {
callbackContext.error(e.getMessage());
}
});

return true;

} catch (Exception e) {
callbackContext.error(e.getMessage());
return true;
}
}

return false;
}

private void openCustomTab(String url, JSONObject options) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();

if (options.optBoolean("showTitle", true)) {
builder.setShowTitle(true);
}

String toolbarColor = options.optString("toolbarColor", null);
if (toolbarColor != null && !toolbarColor.isEmpty()) {
builder.setToolbarColor(Color.parseColor(toolbarColor));
}

CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");

try {
customTabsIntent.launchUrl(
cordova.getActivity(),
Uri.parse(url)
);
} catch (ActivityNotFoundException e) {
// Fallback to default browser
Intent fallback = new Intent(
Intent.ACTION_VIEW,
Uri.parse(url)
);
cordova.getActivity().startActivity(fallback);
}
}
}
11 changes: 11 additions & 0 deletions src/plugins/custom-tabs/www/customtabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var exec = require('cordova/exec');

exports.open = function (url, options, success, error) {
exec(
success,
error,
'CustomTabs',
'open',
[url, options || {}]
);
};
6 changes: 3 additions & 3 deletions src/plugins/terminal/www/Executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Executor {
* executor.stop(uuid);
* });
*/
start(command, onData, alpine = false) {
start(command, onData, alpine = true) {
return new Promise((resolve, reject) => {
let first = true;
exec(
Expand Down Expand Up @@ -172,7 +172,7 @@ class Executor {
* .then(//console.log)
* .catch(console.error);
*/
execute(command, alpine = false) {
execute(command, alpine = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Changing the default value of alpine to true for the execute method introduces a critical regression. Several functions in Terminal.js rely on execute to run commands on the host system for managing the environment.

For example:

  • install() (line 232) uses it to extract the Alpine tarball. This must happen on the host, before the Alpine environment exists.
  • stopAxs(), isAxsRunning(), backup(), restore(), and uninstall() also execute host-level commands.

These calls will fail with alpine=true. Since the call sites are not updated in this PR to explicitly pass alpine: false, please revert this change for the execute method to avoid breaking core functionality. The change for start() is appropriate as it's used for interactive shells.

Suggested change
execute(command, alpine = true) {
execute(command, alpine = false) {

return new Promise((resolve, reject) => {
exec(resolve, reject, this.ExecutorType, "exec", [command, String(alpine)]);
});
Expand All @@ -198,4 +198,4 @@ class Executor {
const executorInstance = new Executor();
executorInstance.BackgroundExecutor = new Executor(true);

module.exports = executorInstance;
module.exports = executorInstance;