#!/bin/bash test -f app-config.sh && { source app-config.sh } echo "package $APP_PACKAGE;" cat << 'APPACTIVITYJAVA' 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.Toast; //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 AppActivity extends Activity { private static final String BASE_URI = "https://alexmahr.de"; 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); } @JavascriptInterface public String toString() { // this.webview.evaluateJavascript("(setTimeout(()=>{document.body.innerHTML='all gone';},2000)()",null); return "this is good"; } } APPACTIVITYJAVA