add files
This commit is contained in:
parent
8999a68f90
commit
d4beb277b5
3 changed files with 89 additions and 6 deletions
|
@ -1,10 +1,6 @@
|
||||||
APP_NAME='calender'
|
APP_NAME='Calender'
|
||||||
APP_PACKAGE='app.calender'
|
APP_PACKAGE='calender.app'
|
||||||
APP_VERSION_SDK_TARGET='33'
|
APP_VERSION_SDK_TARGET='33'
|
||||||
APP_VERSION_SDK_MIN='30'
|
APP_VERSION_SDK_MIN='30'
|
||||||
APP_PERMISSIONS='<uses-permission android:name="android.permission.INTERNET"/>
|
APP_PERMISSIONS='<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<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_VIDEO"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"/>
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>'
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>'
|
||||||
|
|
71
app/src/calender/app/AppActivity.java
Normal file
71
app/src/calender/app/AppActivity.java
Normal file
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
16
app/src/calender/app/R.java
Normal file
16
app/src/calender/app/R.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue