Compare commits
No commits in common. "2386b29233cd82a15af200cf4a4ebfc3ff70f7bc" and "a2c5d60e17a2414e2426414ed40edfd3e8651682" have entirely different histories.
2386b29233
...
a2c5d60e17
6 changed files with 21 additions and 198 deletions
|
@ -23,7 +23,6 @@ RUN test "$YESACCEPT" = "y" || { printf "\033[31;1;4m%s\n%s\033[0m " "FAILED TO
|
||||||
RUN echo you selected to accept the licenses/TOS
|
RUN echo you selected to accept the licenses/TOS
|
||||||
RUN echo "$YESACCEPT" | sdkmanager --install "build-tools;33.0.2"
|
RUN echo "$YESACCEPT" | sdkmanager --install "build-tools;33.0.2"
|
||||||
RUN echo "$YESACCEPT" | sdkmanager --install "platforms;android-33"
|
RUN echo "$YESACCEPT" | sdkmanager --install "platforms;android-33"
|
||||||
RUN echo "$YESACCEPT" | sdkmanager --install "ndk;28.0.12433566"
|
|
||||||
#RUN apk add setpriv
|
#RUN apk add setpriv
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
RUN chown 0:0 /entrypoint.sh
|
RUN chown 0:0 /entrypoint.sh
|
||||||
|
|
20
README.md
20
README.md
|
@ -1,27 +1,15 @@
|
||||||
# Repo allowing -in a KISS way- to create a containered way to build an Android App APK
|
# Repo allowing -in a KISS way- to create a containered way to build an Android App APK
|
||||||
|
|
||||||
|
|
||||||
## branchs
|
|
||||||
|
|
||||||
### branch `native`
|
|
||||||
|
|
||||||
this branch should allow to use the Native Developer Kit to build an app without much java
|
|
||||||
the content below apk/native are LICENSE MIT
|
|
||||||
|
|
||||||
### branch `no-res.xml`
|
|
||||||
|
|
||||||
this branch features the exmaple.app to not require the compoletely bogus unneeded requirement
|
|
||||||
to setup a `./apk/res/layouts/res.xml` file to setup the layout to be used.
|
|
||||||
Instead a layout is created inline
|
|
||||||
|
|
||||||
### branch `webview`
|
|
||||||
|
|
||||||
a bra
|
|
||||||
## changelog
|
## changelog
|
||||||
|
|
||||||
* using https://android.googlesource.com/platform/cts/+/android-7.1.1_r13/tests/tests/webkit/src/android/webkit/cts/PostMessageTest.java derived
|
* using https://android.googlesource.com/platform/cts/+/android-7.1.1_r13/tests/tests/webkit/src/android/webkit/cts/PostMessageTest.java derived
|
||||||
webmessage to send data to Javascript/Webview from Java (using a timer)
|
webmessage to send data to Javascript/Webview from Java (using a timer)
|
||||||
|
## brach `no-res.xml`
|
||||||
|
|
||||||
|
this branch features the exmaple.app to not require the compoletely bogus unneeded requirement
|
||||||
|
to setup a `./apk/res/layouts/res.xml` file to setup the layout to be used.
|
||||||
|
Instead a layout is created inline
|
||||||
|
|
||||||
|
|
||||||
## tl;dr
|
## tl;dr
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
|
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
|
||||||
<uses-permission android:name="android.permission.MANAGE_MEDIA"/>
|
<uses-permission android:name="android.permission.MANAGE_MEDIA"/>
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
|
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
|
||||||
|
|
|
@ -1,106 +1,21 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<script>
|
<script>
|
||||||
|
window.addEventListener('message',(e)=>{
|
||||||
function sleepit(ms) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
resolve(1);
|
|
||||||
}, ms);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function divMessage(html){
|
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.innerHTML=html;
|
div.innerHTML='message'+e.data;
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
div.scrollIntoView({ behavior: 'smooth'});
|
div.scrollIntoView({ behavior: 'smooth'});
|
||||||
}
|
|
||||||
|
|
||||||
(async function webviewprogram(){
|
|
||||||
var port;
|
|
||||||
var resolves = [];
|
|
||||||
function setupMessage(){
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
window.addEventListener('message',(e)=>{
|
|
||||||
if(e.data=="init-from-java" && ! port){
|
|
||||||
divMessage('INIT');
|
|
||||||
port = e.ports[0];
|
|
||||||
port.onmessage = function (ee) {
|
|
||||||
divMessage('AAport.onmessage='+ee.data);
|
|
||||||
var response = JSON.parse(ee.data);
|
|
||||||
divMessage('response.resolveIndex'+response.resolveIndex);//AAport.onmessage='+ee.data);
|
|
||||||
var localresolve = resolves[response.resolveIndex];
|
|
||||||
divMessage(typeof localresolve)
|
|
||||||
|
|
||||||
localresolve(response);
|
|
||||||
}
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
divMessage('message='+e.data);
|
|
||||||
},true);
|
},true);
|
||||||
});
|
|
||||||
}
|
|
||||||
function doLs(path){
|
|
||||||
divMessage('doLs');
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
divMessage('resolves.length'+resolves.length);
|
|
||||||
resolves.push(resolve);
|
|
||||||
divMessage('after push resolves.length'+resolves.length);
|
|
||||||
port.postMessage('{"function":"ls","path":"'+path+'","resolveIndex":"'+(resolves.length-1)+'"}');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function doCat(file){
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
resolves.push(resolve);
|
|
||||||
port.postMessage('{"function":"cat","resolveIndex":"'+resolves.length+'"}');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
window.addEventListener('load',()=>{
|
window.addEventListener('load',()=>{
|
||||||
divMessage('JAVASCRIPT WORKS');
|
var div = document.createElement('div');
|
||||||
|
div.innerHTML='JAVASCRIPT works'
|
||||||
|
document.body.appendChild(div);
|
||||||
|
div.scrollIntoView({ behavior: 'smooth'});
|
||||||
},false);
|
},false);
|
||||||
// await sleepit(2000);
|
|
||||||
// divMessage('awaited 2000');
|
|
||||||
// await sleepit(2000);
|
|
||||||
// divMessage('awaited again 2000');
|
|
||||||
await setupMessage();
|
|
||||||
divMessage('setup');
|
|
||||||
async function mapDoLs(path){
|
|
||||||
var reply = await doLs(path);
|
|
||||||
divMessage("reply.result.length"+reply.result.length);
|
|
||||||
reply.result.forEach((file)=>{
|
|
||||||
divMessage(file.name);//reply.result.length"+reply.result.length);
|
|
||||||
//var button
|
|
||||||
button = document.createElement("button");
|
|
||||||
button.addEventListener("click",()=>{
|
|
||||||
if(file.isDirectory)
|
|
||||||
mapDoLs(path+"/"+file.name);
|
|
||||||
},false);
|
|
||||||
//if(file.isDirectory){
|
|
||||||
//{
|
|
||||||
// button = document.createElement("button");
|
|
||||||
// button.addEventListener("click",()=>{
|
|
||||||
// mapDoLs(path+"/"+file.name);
|
|
||||||
// },false);
|
|
||||||
//} else {
|
|
||||||
// button = document.createElement("div");
|
|
||||||
//}
|
|
||||||
////a.href="#";
|
|
||||||
//////a.textContent="asdasdada"
|
|
||||||
button.textContent=file.name+ " " + file.size;
|
|
||||||
document.body.appendChild(button);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await mapDoLs("/DCIM");
|
|
||||||
divMessage("done");
|
|
||||||
// for(let file of DCIM.result){
|
|
||||||
// divMessage("filename");
|
|
||||||
|
|
||||||
//});
|
|
||||||
})();
|
|
||||||
</script>
|
</script>
|
||||||
<a href='https://html5test.co/'>https://html5test.co/</a>
|
<a href='https://html5test.co/'>https://html5test.co/</a>
|
||||||
<h1> this is html <h1>
|
<h1> this is html <h1>
|
||||||
<h2> this is a h2</h2>
|
<h2> this is a h2</h2>
|
||||||
<img src='https://wald.alexmahr.de/images/bear.avif'>
|
<img src='https://wald.alexmahr.de/images/bear.avif'>
|
||||||
<img src='https://wald.alexmahr.de/images/delphin.avif'>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package app.example;
|
package app.example;
|
||||||
import android.provider.Settings ;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import java.util.Objects;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Environment;
|
|
||||||
import android.text.method.ScrollingMovementMethod;
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
//import android.view.MenuItem;
|
//import android.view.MenuItem;
|
||||||
|
@ -21,50 +18,9 @@ import org.json.JSONObject;
|
||||||
//import android.webkit.WebMessage;
|
//import android.webkit.WebMessage;
|
||||||
//import android.webkit.WebMessagePort;
|
//import android.webkit.WebMessagePort;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class ExampleApp extends Activity {
|
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 static final String BASE_URI = "https://alexmahr.de";
|
||||||
private WebMessagePort port;
|
private WebMessagePort port;
|
||||||
private void initPort(WebView myWebView) {
|
private void initPort(WebView myWebView) {
|
||||||
|
@ -72,35 +28,10 @@ public class ExampleApp extends Activity {
|
||||||
port=channel[0];
|
port=channel[0];
|
||||||
port.setWebMessageCallback(new WebMessagePort.WebMessageCallback() {
|
port.setWebMessageCallback(new WebMessagePort.WebMessageCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(WebMessagePort porte, WebMessage message) {
|
public void onMessage(WebMessagePort port, 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));
|
myWebView.postWebMessage(new WebMessage("", new WebMessagePort[]{channel[1]}),Uri.parse(BASE_URI));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readFileFromAssets(String filename) {
|
public String readFileFromAssets(String filename) {
|
||||||
|
@ -142,7 +73,7 @@ public class ExampleApp extends Activity {
|
||||||
// alternatively this could be to load a website
|
// alternatively this could be to load a website
|
||||||
//myWebView.loadUrl("https://alexmahr.de/ru");
|
//myWebView.loadUrl("https://alexmahr.de/ru");
|
||||||
setContentView(myWebView);
|
setContentView(myWebView);
|
||||||
new CountDownTimer(500, 100) {
|
new CountDownTimer(5000, 1000) {
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
try{
|
try{
|
||||||
JSONObject MyJSONObject = new JSONObject("{\"json\":[1,2,3],\"something\":\"test\"}");
|
JSONObject MyJSONObject = new JSONObject("{\"json\":[1,2,3],\"something\":\"test\"}");
|
||||||
|
@ -153,17 +84,9 @@ public class ExampleApp extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
initPort(myWebView);//myWebView.evaluateJavascript("document.body.innerHTML='all is lost';",null);
|
myWebView.evaluateJavascript("document.body.innerHTML='all is lost';",null);
|
||||||
}
|
}
|
||||||
}.start();
|
}.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
|
@JavascriptInterface
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
services:
|
services:
|
||||||
compile:
|
compile:
|
||||||
hostname: android-app-builder
|
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
|
|
Loading…
Add table
Reference in a new issue