Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"com.foxdebug.acode.rk.plugin.plugincontext": {},
"cordova-plugin-system": {},
"com.foxdebug.acode.rk.auth": {},
"com.foxdebug.acode.rk.exec.proot": {},
"cordova-plugin-iap": {}
"cordova-plugin-iap": {},
"com.foxdebug.acode.rk.exec.proot": {}
},
"platforms": [
"android"
Expand Down
25 changes: 23 additions & 2 deletions src/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const BASE_URL = "https://acode.app";
let hasPro = false;

export default {
const config = {
BASE_URL,
SUPPORTED_EDITOR: "cm",
FILE_NAME_REGEX: /^((?![:<>"\\\|\?\*]).)*$/,
Expand All @@ -21,9 +21,11 @@ export default {
CUSTOM_THEME: 'body[theme="custom"]',
FEEDBACK_EMAIL: "acode@foxdebug.com",
ERUDA_CDN: "https://cdn.jsdelivr.net/npm/eruda",

get PLAY_STORE_URL() {
return `https://play.google.com/store/apps/details?id=${BuildInfo.packageName}`;
},

API_BASE: `${BASE_URL}/api`,
SKU_LIST: ["crystal", "bronze", "silver", "gold", "platinum", "titanium"],
LOG_FILE_NAME: "Acode.log",
Expand All @@ -36,12 +38,31 @@ export default {
TWITTER_URL: "https://x.com/foxbiz_io",
INSTAGRAM_URL: "https://www.instagram.com/foxbiz.io/",
FOXBIZ_URL: "https://foxbiz.io",
IAP_AVAILABLE: typeof iap !== "undefined",

//assume playstore build until proven otherwise
IAP_AVAILABLE: true,

get HAS_PRO() {
return hasPro;
},

set HAS_PRO(value) {
hasPro = value;
},
};

system.getInstaller(
(installer) => {
config.IAP_AVAILABLE =
typeof iap !== "undefined" &&
installer != null &&
installer !== "null" &&
installer === "com.android.vending";
},
(error) => {
console.error(error);
config.IAP_AVAILABLE = true;
},
Comment thread
RohitKushvaha01 marked this conversation as resolved.
Comment thread
RohitKushvaha01 marked this conversation as resolved.
);

export default config;
1 change: 1 addition & 0 deletions src/pages/plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import alert from "dialogs/alert";
import loader from "dialogs/loader";
import purchaseListener from "handlers/purchase";
import actionStack from "lib/actionStack";
import auth from "lib/auth";
import config from "lib/config";
import installPlugin from "lib/installPlugin";
import InstallState from "lib/installState";
Expand Down
38 changes: 38 additions & 0 deletions src/pages/plugin/plugin.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import alert from "dialogs/alert";
import DOMPurify from "dompurify";
import Ref from "html-tag-js/ref";
import actionStack from "lib/actionStack";
import auth from "lib/auth";
import config from "lib/config";
import helpers from "utils/helpers";
import Url from "utils/Url";
Expand Down Expand Up @@ -271,6 +272,7 @@ function handleTabClick(e) {
}

function Buttons({
id,
name,
isPaid,
installed,
Expand All @@ -283,6 +285,29 @@ function Buttons({
minVersionCode,
isSupported = true,
}) {
async function openPluginWebsite() {
try {
const user = await auth.getLoggedInUser();
if (!user) {
CustomTabs.open(
`${config.BASE_URL}/login?redirect=app`,
{ showTitle: true },
() => {},
() => {},
);
return;
}

CustomTabs.open(
`${config.BASE_URL}/plugin/${id}`,
{ showTitle: true },
() => {},
() => {},
);
} catch (e) {
console.error(e);
}
}
Comment thread
RohitKushvaha01 marked this conversation as resolved.
if (!isSupported) {
return (
<div
Expand Down Expand Up @@ -346,6 +371,19 @@ function Buttons({
);
}

if (!config.IAP_AVAILABLE && isPaid && !purchased && price) {
return (
<button
data-type="buy"
className="btn btn-install"
onclick={openPluginWebsite}
>
<i className="icon open_in_browser"></i>
{price}
</button>
);
}
Comment thread
RohitKushvaha01 marked this conversation as resolved.

if (isPaid && !purchased && price) {
return (
<button data-type="buy" className="btn btn-install" onclick={buy}>
Expand Down
28 changes: 28 additions & 0 deletions src/plugins/system/android/com/foxdebug/system/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
import java.security.MessageDigest;
import java.security.MessageDigest;

import android.content.pm.InstallSourceInfo;
import android.content.pm.PackageManager;
import android.os.Build;



public class System extends CordovaPlugin {
Expand Down Expand Up @@ -200,6 +204,7 @@ public boolean execute(
case "decode":
case "encode":
case "copyToUri":
case "getInstaller":
case "compare-file-text":
case "compare-texts":
case "pin-file-shortcut":
Expand Down Expand Up @@ -399,6 +404,29 @@ public void run() {
new Runnable() {
public void run() {
switch (action) {
case "getInstaller":
try {
PackageManager pm = context.getPackageManager();

String installer;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
InstallSourceInfo info =
pm.getInstallSourceInfo(context.getPackageName());

installer = info.getInstallingPackageName();
} else {
installer = pm.getInstallerPackageName(
context.getPackageName()
);
}

callbackContext.success(installer);

} catch (Exception e) {
callbackContext.error(e.getMessage());
}
break;
case "copyToUri":
try {
//srcUri is a file
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/system/www/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ module.exports = {
setExec: function (path, executable, success, error) {
cordova.exec(success, error, 'System', 'setExec', [path, String(executable)]);
},
getInstaller: function (success, error) {
cordova.exec(success, error, 'System', 'getInstaller', []);
},


getNativeLibraryPath: function (success, error) {
Expand Down
27 changes: 24 additions & 3 deletions src/sidebarApps/extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import alert from "dialogs/alert";
import prompt from "dialogs/prompt";
import select from "dialogs/select";
import purchaseListener from "handlers/purchase";
import auth from "lib/auth";
import config from "lib/config";
import InstallState from "lib/installState";
import loadPlugin from "lib/loadPlugin";
Expand Down Expand Up @@ -772,7 +773,28 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) {
});

const isPaid = remotePlugin.price > 0;
if (isPaid) {
if (isPaid && !config.IAP_AVAILABLE && !remotePlugin.owned) {
const user = await auth.getLoggedInUser();
if (!user) {
CustomTabs.open(
`${config.BASE_URL}/login?redirect=app`,
{ showTitle: true },
() => {},
() => {},
);
return;
}

CustomTabs.open(
`${config.BASE_URL}/plugin/${remotePlugin.id}`,
{ showTitle: true },
() => {},
() => {},
);
return;
}
Comment thread
RohitKushvaha01 marked this conversation as resolved.

if (isPaid && config.IAP_AVAILABLE) {
[product] = await helpers.promisify(iap.getProducts, [
remotePlugin.sku,
]);
Expand All @@ -781,8 +803,7 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) {
purchaseToken = purchase?.purchaseToken;
}
}

if (isPaid && !purchaseToken) {
if (isPaid && config.IAP_AVAILABLE && !purchaseToken) {
if (!product) throw new Error("Product not found");
const apiStatus = await helpers.checkAPIStatus();

Expand Down