diff --git a/app/app-config.sh b/app/app-config.sh index 16fa723..c006b5e 100644 --- a/app/app-config.sh +++ b/app/app-config.sh @@ -1,10 +1,6 @@ -APP_NAME='calender' -APP_PACKAGE='app.calender' +APP_NAME='Calender' +APP_PACKAGE='calender.app' APP_VERSION_SDK_TARGET='33' APP_VERSION_SDK_MIN='30' APP_PERMISSIONS=' - - - - ' diff --git a/app/src/calender/app/AppActivity.java b/app/src/calender/app/AppActivity.java new file mode 100644 index 0000000..bca47a9 --- /dev/null +++ b/app/src/calender/app/AppActivity.java @@ -0,0 +1,71 @@ +package calender.app; +import android.provider.Settings ; +import android.content.Intent; +import android.util.Log; +import android.app.Activity; +import android.os.Bundle; +import android.os.Environment; +//import android.view.MenuItem; +import android.view.*; +// for WebView,WebMessage,WebMessagePort, +import android.webkit.*; +import android.net.Uri; +import org.json.JSONObject; +import java.io.InputStream; +import java.io.File; +import java.util.Objects; + + + +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); + myWebSettings.setDomStorageEnabled(true); + myWebSettings.setDatabaseEnabled(true); + myWebSettings.setDatabasePath("/data/data/" + myWebView.getContext().getPackageName() + "/databases/"); + 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"; + } +} diff --git a/app/src/calender/app/R.java b/app/src/calender/app/R.java new file mode 100644 index 0000000..a204675 --- /dev/null +++ b/app/src/calender/app/R.java @@ -0,0 +1,16 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package calender.app; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int appicon=0x7f020000; + } +}