Skip to content

Commit 6fe66c6

Browse files
committed
d
0 parents  commit 6fe66c6

File tree

14 files changed

+538
-0
lines changed

14 files changed

+538
-0
lines changed

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Gradle
2+
.gradle/
3+
build/
4+
5+
# Kotlin
6+
.kotlin
7+
8+
# Local configuration
9+
local.properties
10+
signing.properties
11+
12+
# Android Studio
13+
captures/
14+
release/
15+
.externalNativeBuild/
16+
.cxx/
17+
18+
# IntelliJ
19+
*.iml
20+
.idea/
21+
22+
# Keystore
23+
*.jks
24+
*.keystore
25+
26+
# MacOS
27+
.DS_Store
28+
29+
.externalNativeBuild
30+
.cxx
31+
local.properties
32+
*.dex
33+
*.apk
34+
*.so
35+
*.zip
36+
out

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# WebUI Dex Plugin
2+
3+
This repository serves as a template to demonstrate the integration of WebUI plugins, providing a framework to enhance the WebUI experience with custom functionality.
4+
5+
## Building the Plugin
6+
7+
To build the plugin, simply run the following command:
8+
9+
```shell
10+
gradlew build-dex
11+
```
12+
13+
This will compile the necessary code and generate the required `.dex` files for use within your WebUI project.
14+
15+
## Setting Up the Plugins
16+
17+
To get started with the plugin integration, create a file named `plugins.json` within the `/data/adb/modules/<MODID>/webroot` directory. This file will specify the plugins to be loaded. The `.dex`, `.jar`, or `.apk` files associated with these plugins should be placed in the `/data/adb/modules/<MODID>/webroot/plugins` directory for them to be properly loaded and utilized by the WebUI.
18+
19+
Here's an example of what your `plugins.json` file should look like:
20+
21+
```json
22+
[
23+
"com.dergoogler.mmrl.webui.customInterface.WebUIPluginKt",
24+
"com.dergoogler.mmrl.webui.dialog.DialogPluginKt"
25+
]
26+
```
27+
28+
Make sure to replace `<MODID>` with your module's actual identifier.
29+
30+
## Using the Plugins in WebUI
31+
32+
Once the plugin setup is complete, you can start utilizing the custom functionalities within your WebUI interface.
33+
34+
### Example: Building a Custom Dialog with a Callback
35+
36+
You can create a custom dialog in JavaScript that reacts to user input by using the provided `dialog` plugin. Here's how to set up a basic dialog with a positive button that triggers a callback when clicked:
37+
38+
```js
39+
const builder = window.dialog;
40+
41+
window.dialog.positive = () => {
42+
console.log("Pressed the dialog button!");
43+
};
44+
45+
builder.setTitle("Test");
46+
builder.setMessage("This is a custom dialog");
47+
builder.setPositiveButton("Log me!", "positive");
48+
builder.show();
49+
```
50+
51+
In this example, when the user clicks on the positive button labeled "Log me!", the callback function logs a message to the console.
52+
53+
### Example: Loading a New URL
54+
55+
You can also load URLs directly into the WebUI with the `customInterface` plugin. Here's a simple example of loading an external URL:
56+
57+
```js
58+
customInterface.loadUrl("https://google.com");
59+
```
60+
61+
### Example: Showing a Toast Notification
62+
63+
To provide feedback to the user, you can display a toast notification using the `customInterface` plugin:
64+
65+
```js
66+
customInterface.showToast("Hello from a Plugin!");
67+
```
68+
69+
This will show a simple toast message on the screen.

build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
alias(libs.plugins.android.application) apply false
3+
}
4+
5+
buildscript {
6+
repositories {
7+
google()
8+
mavenCentral()
9+
maven("https://jitpack.io")
10+
}
11+
dependencies {
12+
classpath(libs.gradle)
13+
classpath(kotlin("gradle-plugin", version = "1.9.25"))
14+
}
15+
}

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
2+
android.useAndroidX=true
3+
android.nonTransitiveRClass=true
4+
android.enableJetifier=true

gradle/libs.versions.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[versions]
2+
agp = "8.5.1"
3+
gradle = "8.1.4"
4+
5+
[libraries]
6+
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
7+
8+
[plugins]
9+
android-application = { id = "com.android.application", version.ref = "agp" }

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Sep 26 20:23:51 CEST 2024
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

gradlew

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

0 commit comments

Comments
 (0)