Skip to content

Commit eb3c776

Browse files
author
DerGoogler
committed
Update
- 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
1 parent 38702cf commit eb3c776

File tree

18 files changed

+249
-112
lines changed

18 files changed

+249
-112
lines changed

Android/app/src/main/cpp/native.cpp

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -74,58 +74,18 @@ string cppExec(const char *cmd) {
7474

7575
extern "C"
7676
JNIEXPORT jstring JNICALL
77-
Java_com_dergoogler_mmrl_Lib_test(JNIEnv *env, jclass clazz) {
78-
string hello = "Hello from C++";
79-
return env->NewStringUTF(hello.c_str());
80-
}
81-
82-
extern "C"
83-
JNIEXPORT jstring JNICALL
84-
Java_com_dergoogler_mmrl_Lib_baseUrl(JNIEnv *env, jclass clazz) {
85-
string result = "file:///android_asset/";
86-
return env->NewStringUTF(result.c_str());
87-
}
88-
89-
extern "C"
90-
JNIEXPORT jstring JNICALL
91-
Java_com_dergoogler_mmrl_Lib_interfaceName(JNIEnv *env, jclass clazz) {
92-
string result = "android";
93-
return env->NewStringUTF(result.c_str());
94-
}
95-
96-
extern "C"
97-
JNIEXPORT jstring JNICALL
98-
Java_com_dergoogler_mmrl_Lib_getStorageKey(JNIEnv *env, jclass clazz) {
99-
string result = "localstorage";
100-
return env->NewStringUTF(result.c_str());
101-
}
102-
103-
extern "C"
104-
JNIEXPORT jstring JNICALL
105-
Java_com_dergoogler_mmrl_Lib_getUserAgent(JNIEnv *env, jclass clazz) {
106-
string result = "MMRL";
107-
return env->NewStringUTF(result.c_str());
108-
}
109-
110-
extern "C"
111-
JNIEXPORT jstring JNICALL
112-
Java_com_dergoogler_mmrl_Lib_pageContent(JNIEnv *env, jclass clazz, jstring cssInject) {
77+
Java_com_dergoogler_components_ModuleView_pageContent(JNIEnv *env, jclass clazz,
78+
jstring cssInject) {
11379
string doctype = R"(<!DOCTYPE html>)";
11480
string htmlStart = R"(<html>)";
11581
string headStart = R"(<head>)";
11682
string styleVendor = R"(<link rel="stylesheet" type="text/css" href="bundle/vendor.bundle.css"/>)";
11783
string styleApp = R"(<link rel="stylesheet" type="text/css" href="bundle/app.bundle.css"/>)";
11884
string meta = R"(<meta charset="utf-8" />)";
119-
string cssInject1 = R"(<script>)";
120-
string cssInject2 = R"(var parent = document.getElementsByTagName('head').item(0);)";
121-
string cssInject3 = R"(var style = document.createElement('style');)";
122-
string cssInject4 = R"(style.type = 'text/css';)";
123-
string cssInject5 = "style.innerHTML = window.atob('" + jstring2string(env, cssInject) + "');";
124-
string cssInject6 = R"(parent.appendChild(style))";
125-
string cssInject7 = R"(</script>)";
126-
string cssInjectResult =
127-
cssInject1 + cssInject2 + cssInject3 + cssInject4 + cssInject5 + cssInject6 +
128-
cssInject7;
85+
string cssInject1 = R"(<style>)";
86+
string cssInject2 = jstring2string(env, cssInject);
87+
string cssInject3 = R"(</style>)";
88+
string cssInjectResult = cssInject1 + cssInject2 + cssInject3;
12989
string headEnd = R"(</head>)";
13090
string bodyStart = R"(<body>)";
13191
string app = R"(<app></app>)";

Android/app/src/main/java/com/dergoogler/components/ModuleView.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ public class ModuleView extends WebView {
2020

2121
private final WebSettings webSettings;
2222

23+
static {
24+
System.loadLibrary("native-lib");
25+
}
26+
/**
27+
* Returns the html page to load. This is to prevent js injection though the html page with <script/> tags
28+
* @return HTML page string
29+
*/
30+
public static native String pageContent(@NonNull String cssInject);
31+
2332
public ModuleView(Context context) {
2433
super(context);
2534
this.webSettings = this.getSettings();

Android/app/src/main/java/com/dergoogler/mmrl/Interface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class retn {
8181
private final SharedPreferences localstorage;
8282

8383
public retn(@NonNull Context context) {
84-
this.localstorage = context.getSharedPreferences(Lib.getStorageKey(), Activity.MODE_PRIVATE);
84+
this.localstorage = context.getSharedPreferences("localstorage", Activity.MODE_PRIVATE);
8585
}
8686

8787
/**

Android/app/src/main/java/com/dergoogler/mmrl/Lib.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

Android/app/src/main/java/com/dergoogler/mmrl/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ protected void onCreate(Bundle savedInstanceState) {
3434

3535
view = findViewById(R.id.mmrl_view);
3636
view.setJavaScriptEnabled(true);
37-
view.setUserAgentString(Lib.getUserAgent());
38-
view.loadHTML(Lib.baseUrl(), Lib.pageContent(this.cssInject()));
39-
view.setJavascriptInterface(new Interface(this), Lib.interfaceName());
37+
view.setUserAgentString("MMRL");
38+
view.loadHTML("file:///android_asset/", ModuleView.pageContent(this.cssInject()));
39+
view.setJavascriptInterface(new Interface(this), "android");
4040
}
4141

4242
@Override

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module = {
3232
}
3333
```
3434

35-
## What MMRL Supports
35+
## What MMRL Supports (Roadmap)
3636

3737
- [x] Custom repo loading
3838
- [ ] Translation
@@ -41,9 +41,9 @@ module = {
4141

4242
- [x] Custom theming
4343
- [x] View installed modules
44-
- [x] Delete installed modules
45-
- [ ] Disable installed modules
46-
- [ ] Enable installed modules
44+
- [x] Remove installed modules
45+
- [x] Disable installed modules
46+
- [x] Enable installed modules
4747
- [ ] Module install
4848

4949
## Meet the Description API (DAPI)

Website/licenseBuild/licenses.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,14 @@
22632263
"version": "1.0.0",
22642264
"description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails"
22652265
},
2266+
"fuchs-template@1.0.0": {
2267+
"licenses": "MIT",
2268+
"repository": "https://github.com/maxhoffmann/fuchs-template",
2269+
"publisher": "Maximilian Hoffmann",
2270+
"name": "fuchs-template",
2271+
"version": "1.0.0",
2272+
"description": "minimum templating engine by thomas fuchs"
2273+
},
22662274
"function-bind@1.1.1": {
22672275
"licenses": "MIT",
22682276
"repository": "https://github.com/Raynos/function-bind",

Website/package-lock.json

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"axios": "^0.26.1",
2525
"bootstrap": "^5.1.3",
2626
"dot-properties": "^1.0.1",
27+
"fuchs-template": "^1.0.0",
2728
"jss": "^10.9.0",
2829
"jss-preset-default": "^10.9.0",
2930
"markdown-to-jsx": "^7.1.7",

Website/src/activitys/MainApplication.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface Props {
2525
}
2626

2727
class MainApplication extends AppCompatActivity<Props> {
28+
t: any;
2829
public constructor(props: Props | Readonly<Props>) {
2930
super(props);
3031
this.state = {};

0 commit comments

Comments
 (0)