Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
- Option to disable and enable module
- Modules don't get fully deleted anymore (It now creates an "remove" file)
- Recover modules (only when includes "remove" file)
-  Update README
  • Loading branch information
DerGoogler committed May 28, 2022
1 parent 38702cf commit eb3c776
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 112 deletions.
52 changes: 6 additions & 46 deletions Android/app/src/main/cpp/native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,58 +74,18 @@ string cppExec(const char *cmd) {

extern "C"
JNIEXPORT jstring JNICALL
Java_com_dergoogler_mmrl_Lib_test(JNIEnv *env, jclass clazz) {
string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}

extern "C"
JNIEXPORT jstring JNICALL
Java_com_dergoogler_mmrl_Lib_baseUrl(JNIEnv *env, jclass clazz) {
string result = "file:///android_asset/";
return env->NewStringUTF(result.c_str());
}

extern "C"
JNIEXPORT jstring JNICALL
Java_com_dergoogler_mmrl_Lib_interfaceName(JNIEnv *env, jclass clazz) {
string result = "android";
return env->NewStringUTF(result.c_str());
}

extern "C"
JNIEXPORT jstring JNICALL
Java_com_dergoogler_mmrl_Lib_getStorageKey(JNIEnv *env, jclass clazz) {
string result = "localstorage";
return env->NewStringUTF(result.c_str());
}

extern "C"
JNIEXPORT jstring JNICALL
Java_com_dergoogler_mmrl_Lib_getUserAgent(JNIEnv *env, jclass clazz) {
string result = "MMRL";
return env->NewStringUTF(result.c_str());
}

extern "C"
JNIEXPORT jstring JNICALL
Java_com_dergoogler_mmrl_Lib_pageContent(JNIEnv *env, jclass clazz, jstring cssInject) {
Java_com_dergoogler_components_ModuleView_pageContent(JNIEnv *env, jclass clazz,
jstring cssInject) {
string doctype = R"(<!DOCTYPE html>)";
string htmlStart = R"(<html>)";
string headStart = R"(<head>)";
string styleVendor = R"(<link rel="stylesheet" type="text/css" href="bundle/vendor.bundle.css"/>)";
string styleApp = R"(<link rel="stylesheet" type="text/css" href="bundle/app.bundle.css"/>)";
string meta = R"(<meta charset="utf-8" />)";
string cssInject1 = R"(<script>)";
string cssInject2 = R"(var parent = document.getElementsByTagName('head').item(0);)";
string cssInject3 = R"(var style = document.createElement('style');)";
string cssInject4 = R"(style.type = 'text/css';)";
string cssInject5 = "style.innerHTML = window.atob('" + jstring2string(env, cssInject) + "');";
string cssInject6 = R"(parent.appendChild(style))";
string cssInject7 = R"(</script>)";
string cssInjectResult =
cssInject1 + cssInject2 + cssInject3 + cssInject4 + cssInject5 + cssInject6 +
cssInject7;
string cssInject1 = R"(<style>)";
string cssInject2 = jstring2string(env, cssInject);
string cssInject3 = R"(</style>)";
string cssInjectResult = cssInject1 + cssInject2 + cssInject3;
string headEnd = R"(</head>)";
string bodyStart = R"(<body>)";
string app = R"(<app></app>)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ public class ModuleView extends WebView {

private final WebSettings webSettings;

static {
System.loadLibrary("native-lib");
}
/**
* Returns the html page to load. This is to prevent js injection though the html page with <script/> tags
* @return HTML page string
*/
public static native String pageContent(@NonNull String cssInject);

public ModuleView(Context context) {
super(context);
this.webSettings = this.getSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class retn {
private final SharedPreferences localstorage;

public retn(@NonNull Context context) {
this.localstorage = context.getSharedPreferences(Lib.getStorageKey(), Activity.MODE_PRIVATE);
this.localstorage = context.getSharedPreferences("localstorage", Activity.MODE_PRIVATE);
}

/**
Expand Down
28 changes: 0 additions & 28 deletions Android/app/src/main/java/com/dergoogler/mmrl/Lib.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ protected void onCreate(Bundle savedInstanceState) {

view = findViewById(R.id.mmrl_view);
view.setJavaScriptEnabled(true);
view.setUserAgentString(Lib.getUserAgent());
view.loadHTML(Lib.baseUrl(), Lib.pageContent(this.cssInject()));
view.setJavascriptInterface(new Interface(this), Lib.interfaceName());
view.setUserAgentString("MMRL");
view.loadHTML("file:///android_asset/", ModuleView.pageContent(this.cssInject()));
view.setJavascriptInterface(new Interface(this), "android");
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module = {
}
```

## What MMRL Supports
## What MMRL Supports (Roadmap)

- [x] Custom repo loading
- [ ] Translation
Expand All @@ -41,9 +41,9 @@ module = {

- [x] Custom theming
- [x] View installed modules
- [x] Delete installed modules
- [ ] Disable installed modules
- [ ] Enable installed modules
- [x] Remove installed modules
- [x] Disable installed modules
- [x] Enable installed modules
- [ ] Module install

## Meet the Description API (DAPI)
Expand Down
8 changes: 8 additions & 0 deletions Website/licenseBuild/licenses.json
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,14 @@
"version": "1.0.0",
"description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails"
},
"[email protected]": {
"licenses": "MIT",
"repository": "https://github.com/maxhoffmann/fuchs-template",
"publisher": "Maximilian Hoffmann",
"name": "fuchs-template",
"version": "1.0.0",
"description": "minimum templating engine by thomas fuchs"
},
"[email protected]": {
"licenses": "MIT",
"repository": "https://github.com/Raynos/function-bind",
Expand Down
15 changes: 13 additions & 2 deletions Website/package-lock.json

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

1 change: 1 addition & 0 deletions Website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"dot-properties": "^1.0.1",
"fuchs-template": "^1.0.0",
"jss": "^10.9.0",
"jss-preset-default": "^10.9.0",
"markdown-to-jsx": "^7.1.7",
Expand Down
1 change: 1 addition & 0 deletions Website/src/activitys/MainApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface Props {
}

class MainApplication extends AppCompatActivity<Props> {
t: any;
public constructor(props: Props | Readonly<Props>) {
super(props);
this.state = {};
Expand Down
Loading

0 comments on commit eb3c776

Please sign in to comment.