diff --git a/.gitignore b/.gitignore
index 2ef0f39..b111566 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,8 @@ apk/ToyKey.keystore
apk/obj
apk/obj/*
apk/bin/*
+apk/result
+apk/result/
+apk/result/*
apk/bin/!.gitkeep
+/example.app.apk
diff --git a/apk/AndroidManifest.xml b/apk/AndroidManifest.xml
deleted file mode 100644
index 5f3d559..0000000
--- a/apk/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apk/bin/.gitkeep b/apk/bin/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apk/example.app.apk b/apk/example.app.apk
deleted file mode 120000
index f907629..0000000
--- a/apk/example.app.apk
+++ /dev/null
@@ -1 +0,0 @@
-./bin/example.app.apk
\ No newline at end of file
diff --git a/apk/src/app/example/ExampleApp.java b/apk/src/app/example/ExampleApp.java
deleted file mode 100644
index 9174a0c..0000000
--- a/apk/src/app/example/ExampleApp.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package app.example;
-
-import android.util.Log;
-import android.widget.TextView;
-import android.app.Activity;
-import android.os.Bundle;
-import android.text.method.ScrollingMovementMethod;
-import android.view.MenuItem;
-import android.view.*;
-import android.widget.*;
-import android.view.ViewGroup.*;
-
-public class ExampleApp extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // creating LinearLayout
- LinearLayout linLayout = new LinearLayout(this);
- // specifying vertical orientation
- linLayout.setOrientation(LinearLayout.VERTICAL);
- // creating LayoutParams
- LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
- // set LinearLayout as a root element of the screen
- setContentView(linLayout, linLayoutParam);
-
- LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
-
- TextView tv = new TextView(this);
- tv.setText("SUPERVIEalexW");
- tv.setLayoutParams(lpView);
- linLayout.addView(tv);
- }
-}
diff --git a/apk/webview/.gitignore b/apk/webview/.gitignore
new file mode 100644
index 0000000..2fe70a3
--- /dev/null
+++ b/apk/webview/.gitignore
@@ -0,0 +1,9 @@
+/ToyKey.keystore
+/obj
+/obj/*
+/bin/*
+/bin/!.gitkeep
+/result
+/result/
+/result/*
+/example.app.apk
diff --git a/apk/webview/AndroidManifest.xml b/apk/webview/AndroidManifest.xml
new file mode 100644
index 0000000..7319c7a
--- /dev/null
+++ b/apk/webview/AndroidManifest.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apk/Makefile b/apk/webview/Makefile
similarity index 68%
rename from apk/Makefile
rename to apk/webview/Makefile
index a143967..d88be3a 100644
--- a/apk/Makefile
+++ b/apk/webview/Makefile
@@ -14,29 +14,34 @@ all: build
.PHONY : deploy
.PHONY : clean
-build : ./bin/example.app.apk
- ln -sf ./bin/example.app.apk ./example.app.apk
+build : ./result/example.app.apk
+ true
-./bin/example.app.apk : ./bin/signed.apk
+env:
+ set > set ; env > env
+./result/example.app.apk : ./result/signed.apk
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/zipalign -v -f 4 $< $@
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/apksigner sign --ks ToyKey.keystore --key-pass pass:armena --ks-pass pass:armena $@
-./bin/signed.apk : ./bin/unsigned.apk ./ToyKey.keystore
+./result/signed.apk : ./result/unsigned.apk ./ToyKey.keystore ./result
jarsigner -verbose -keystore ./ToyKey.keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
-./bin/unsigned.apk : ./bin/classes.dex
+./result:
+ mkdir -p "$@"
+
+./result/unsigned.apk : ./bin/classes.dex ./result
rm -rvf "$@"
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/aapt package -v -u -f -M ./AndroidManifest.xml -S ./res \
- -I $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar -F $@ ./bin
+ -I $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar -A ./assets -F $@ ./bin
-./bin/classes.dex : ./obj/app/example/ExampleApp.class
- $(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/d8 $(shell find obj -name '*.class') --lib $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar --output bin
+./bin/classes.dex : ./obj/app/example/ExampleApp.class ./obj/app/example/ExampleApp$$1.class
+ $(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/d8 ./obj/app/example/*.class --lib $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar --output bin
./src/app/example/R.java : $(shell find ./res -type f)
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/aapt package -v -f -m -S ./res -J ./src -M ./AndroidManifest.xml \
-I $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar
-./obj/app/example/ExampleApp.class : ./src/app/example/ExampleApp.java ./src/app/example/R.java
+./obj/app/example/ExampleApp.class : ./src/app/example/ExampleApp.java ./src/app/example/R.java
javac -d ./obj -classpath $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar -sourcepath ./src $<
./ToyKey.keystore :
@@ -44,4 +49,4 @@ build : ./bin/example.app.apk
-storepass armena -keypass armena -alias helljniKey -keyalg RSA -v
clean:
- rm -f ./bin/* ./lib/arm64-v8a/*
+ rm -f ./bin/* ./lib/arm64-v8a/* ./result/*
diff --git a/apk/webview/assets/index.html b/apk/webview/assets/index.html
new file mode 100644
index 0000000..06c166c
--- /dev/null
+++ b/apk/webview/assets/index.html
@@ -0,0 +1,106 @@
+
+
+
+https://html5test.co/
+
this is html
+ this is a h2
+
+
+
diff --git a/apk/res/drawable-hdpi/ic_launcher.png b/apk/webview/res/drawable-hdpi/ic_launcher.png
similarity index 100%
rename from apk/res/drawable-hdpi/ic_launcher.png
rename to apk/webview/res/drawable-hdpi/ic_launcher.png
diff --git a/apk/res/drawable-ldpi/ic_launcher.png b/apk/webview/res/drawable-ldpi/ic_launcher.png
similarity index 100%
rename from apk/res/drawable-ldpi/ic_launcher.png
rename to apk/webview/res/drawable-ldpi/ic_launcher.png
diff --git a/apk/res/drawable-mdpi/ic_launcher.png b/apk/webview/res/drawable-mdpi/ic_launcher.png
similarity index 100%
rename from apk/res/drawable-mdpi/ic_launcher.png
rename to apk/webview/res/drawable-mdpi/ic_launcher.png
diff --git a/apk/res/drawable-xhdpi/ic_launcher.png b/apk/webview/res/drawable-xhdpi/ic_launcher.png
similarity index 100%
rename from apk/res/drawable-xhdpi/ic_launcher.png
rename to apk/webview/res/drawable-xhdpi/ic_launcher.png
diff --git a/apk/res/values/strings.xml b/apk/webview/res/values/strings.xml
similarity index 100%
rename from apk/res/values/strings.xml
rename to apk/webview/res/values/strings.xml
diff --git a/apk/src/app/example/.gitignore b/apk/webview/src/app/example/.gitignore
similarity index 100%
rename from apk/src/app/example/.gitignore
rename to apk/webview/src/app/example/.gitignore
diff --git a/apk/webview/src/app/example/ExampleApp.java b/apk/webview/src/app/example/ExampleApp.java
new file mode 100644
index 0000000..0d68748
--- /dev/null
+++ b/apk/webview/src/app/example/ExampleApp.java
@@ -0,0 +1,174 @@
+package app.example;
+import android.provider.Settings ;
+import android.content.Intent;
+import android.util.Log;
+import android.util.Base64;
+import java.util.Objects;
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.os.Environment;
+import android.text.method.ScrollingMovementMethod;
+import android.view.*;
+//import android.view.MenuItem;
+import android.view.ViewGroup.*;
+import android.widget.*;
+//import android.widget.TextView;
+import android.webkit.*;
+import android.net.Uri;
+import org.json.JSONObject;
+//import android.webkit.WebView;
+//import android.webkit.WebMessage;
+//import android.webkit.WebMessagePort;
+import java.io.InputStream;
+import java.io.File;
+
+public class ExampleApp extends Activity {
+
+ public JSONObject doLs(JSONObject message){
+ try{
+ JSONObject file;
+ File directory = new File(Environment.getExternalStorageDirectory().toString() + message.getString("path"));
+ File[] files = directory.listFiles();
+ for (int i = 0; i < files.length; i++)
+ {
+ try{
+ //Log.d("ALEXINFO","filename"+files[i].getName());
+ file = new JSONObject();
+ file.put("name",files[i].getName());
+ file.put("isFile",files[i].isFile());
+ file.put("isDirectory",files[i].isDirectory());
+ file.put("size",files[i].length());
+ message.accumulate("result",file);
+ } catch (Exception e) {
+ Log.d("Exception EX1","ex1");
+ }
+ }
+ } catch (Exception e) {
+ Log.d("Exception EX2","ex2");
+ }
+ return message;
+ }
+
+ public JSONObject doCat(JSONObject message){
+ try{
+ File directory = new File(Environment.getExternalStorageDirectory().toString() + message.getString("path"));
+ File[] files = directory.listFiles();
+ for (int i = 0; i < files.length; i++)
+ {
+ try{
+ message.accumulate("result",files[i].getName());
+ } catch (Exception e) {}
+ }
+ } catch (Exception e) {}
+ return message;
+ }
+
+ final static int APP_STORAGE_ACCESS_REQUEST_CODE = 501; // Any value
+ private static final String BASE_URI = "https://alexmahr.de";
+ private WebMessagePort port;
+ private void initPort(WebView myWebView) {
+ final WebMessagePort[] channel=myWebView.createWebMessageChannel();
+ port=channel[0];
+ port.setWebMessageCallback(new WebMessagePort.WebMessageCallback() {
+ @Override
+ public void onMessage(WebMessagePort porte, WebMessage message) {
+ try{
+ JSONObject messageJSON = new JSONObject(message.getData());
+ JSONObject reply;
+ if(Objects.equals(messageJSON.getString("function"),"ls"))
+ {
+ reply = doLs(messageJSON);
+ reply.put("super","man");
+ port.postMessage(new WebMessage(reply.toString()));
+ return;
+ }
+ else if(Objects.equals(messageJSON.getString("function"),"cat"))
+ {
+ reply = doCat(messageJSON);
+ reply.put("super","cat");
+ port.postMessage(new WebMessage(reply.toString()));
+ return;
+ }
+ else {
+ reply=messageJSON;
+ reply.put("super","else");
+ reply.accumulate("result",1);
+ reply.accumulate("result","something");
+ port.postMessage(new WebMessage(reply.toString()));
+ }
+ } catch( Exception e) { }
+ }
+ });
+ myWebView.postWebMessage(new WebMessage("init-from-java", new WebMessagePort[]{channel[1]}),Uri.parse(BASE_URI));
+ }
+
+ public String readFileFromAssets(String filename) {
+ String filecontents = "";
+ try {
+ InputStream stream = getAssets().open(filename);
+ int filesize = stream.available();
+ byte[] filebuffer = new byte[filesize];
+ stream.read(filebuffer);
+ stream.close();
+ filecontents = new String(filebuffer);
+ } catch (Exception e) {
+ // I <3 java exceptions
+ }
+ return filecontents;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // this removes the title bar (a ~1cm big strip at the top of the app showing its name
+ this.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ // we create the webview (at least on the android 14 that is a webview that features avif + websockets etc....)
+ WebView myWebView = new WebView(this);//activityContext);
+// MyJavascriptInterface myJavaScriptInterface = new MyJavascriptInterface(this,myWebView);
+ // we create a webview (there is also setwebviewclient-vs-setwebchromeclient
+ WebViewClient myWebViewClient= new WebViewClient();
+ myWebView.setWebViewClient(myWebViewClient);
+ // to setup settings
+ WebSettings myWebSettings = myWebView.getSettings();
+ myWebSettings.setBuiltInZoomControls(true);
+ myWebSettings.setDisplayZoomControls(false);
+ myWebSettings.setJavaScriptEnabled(true);
+ myWebView.addJavascriptInterface(this, "myJavaScriptInterface");
+ // load the html from assets file
+ String html = readFileFromAssets("index.html");
+ myWebView.loadDataWithBaseURL(BASE_URI,html, "text/html", "UTF-8",null);
+ //myWebView.loadData(encodedHtml, "text/html", "base64");
+ // alternatively this could be to load a website
+ //myWebView.loadUrl("https://alexmahr.de/ru");
+ setContentView(myWebView);
+ new CountDownTimer(500, 100) {
+ public void onTick(long millisUntilFinished) {
+ try{
+ JSONObject MyJSONObject = new JSONObject("{\"json\":[1,2,3],\"something\":\"test\"}");
+ myWebView.postWebMessage(new WebMessage("this is the message"+millisUntilFinished+ " " + MyJSONObject.get("something")),Uri.parse(BASE_URI));
+ } catch( Exception e) { }
+// mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
+// myWebView.evaluateJavascript("document.body.innerHTML='SUP "+millisUntilFinished+" all is lost';",null);
+ }
+
+ public void onFinish() {
+ initPort(myWebView);//myWebView.evaluateJavascript("document.body.innerHTML='all is lost';",null);
+ }
+ }.start();
+// Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package: app.example"));// + BuildConfig.APPLICATION_ID));
+ Intent intent = new Intent();
+ intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
+ //intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
+ Uri uri = Uri.fromParts("package", this.getPackageName(), null);
+ intent.setData(uri);
+ startActivity(intent);
+// startActivityForResult(intent, APP_STORAGE_ACCESS_REQUEST_CODE);
+ }
+ @JavascriptInterface
+ public String toString() {
+// this.webview.evaluateJavascript("(setTimeout(()=>{document.body.innerHTML='all gone';},2000)()",null);
+ return "this is good";
+ }
+}
+