half-assishly tryout notifications
This commit is contained in:
parent
fe77c5477c
commit
6823e67e1a
2 changed files with 85 additions and 10 deletions
|
@ -117,6 +117,14 @@ body,html{
|
||||||
background-color:white;
|
background-color:white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settingsDiv{
|
||||||
|
background-color: #faa;
|
||||||
|
position: absolute;
|
||||||
|
top:0;
|
||||||
|
left:300vw;
|
||||||
|
height:100vh;
|
||||||
|
overflow:scroll;
|
||||||
|
}
|
||||||
#daysDiv{
|
#daysDiv{
|
||||||
/*background: linear-gradient(white,#aaf);*/
|
/*background: linear-gradient(white,#aaf);*/
|
||||||
background-color: #afa;
|
background-color: #afa;
|
||||||
|
@ -133,7 +141,7 @@ body,html{
|
||||||
left:100vw;
|
left:100vw;
|
||||||
|
|
||||||
}
|
}
|
||||||
#daysDiv, #weeksDiv, #monthsDiv{
|
#settingsDiv,#daysDiv, #weeksDiv, #monthsDiv{
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
||||||
margin:0;
|
margin:0;
|
||||||
scroll-snap-align: start;
|
scroll-snap-align: start;
|
||||||
|
@ -164,6 +172,11 @@ box-shadow: 0 0 10px grey;
|
||||||
<div id="monthsDiv" class="infinityScroll"></div>
|
<div id="monthsDiv" class="infinityScroll"></div>
|
||||||
<div id="weeksDiv" class="infinityScroll"></div>
|
<div id="weeksDiv" class="infinityScroll"></div>
|
||||||
<div id="daysDiv" class="infinityScroll"></div>
|
<div id="daysDiv" class="infinityScroll"></div>
|
||||||
|
<div id="settingsDiv">
|
||||||
|
<button style="padding:1cm;font-size:1cm;margin:1cm;" onclick='window.counti=window.counti|| 1; window.counti++;preout.textContent+="\n"+myJavaScriptInterface.androidNotification("message"+Date.now(),"title",window.counti);'>test notification</button>
|
||||||
|
<pre id="preout"></pre>
|
||||||
|
</div>
|
||||||
|
<
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -178,7 +191,9 @@ Date.prototype.getWeekNumber = function(){
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("load",()=>{
|
window.addEventListener("load",()=>{
|
||||||
|
// document.body.innerHTML="fuck";
|
||||||
|
// alert("this is shit");
|
||||||
|
// debugger;
|
||||||
var locale = window.navigator.userLanguage || window.navigator.language || "en";
|
var locale = window.navigator.userLanguage || window.navigator.language || "en";
|
||||||
|
|
||||||
function createMonthView(date = new Date()){
|
function createMonthView(date = new Date()){
|
||||||
|
@ -326,7 +341,6 @@ window.addEventListener("load",()=>{
|
||||||
makeInfinityScroll(document.querySelector("#monthsDiv"),createMonthViewItem);
|
makeInfinityScroll(document.querySelector("#monthsDiv"),createMonthViewItem);
|
||||||
makeInfinityScroll(document.querySelector("#weeksDiv"),createWeekViewItem);
|
makeInfinityScroll(document.querySelector("#weeksDiv"),createWeekViewItem);
|
||||||
makeInfinityScroll(document.querySelector("#daysDiv"),createDayViewItem);
|
makeInfinityScroll(document.querySelector("#daysDiv"),createDayViewItem);
|
||||||
// document.querySelectorAll('.infinityScroll').forEach(makeInfinityScroll);
|
|
||||||
|
|
||||||
},false);
|
},false);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import android.provider.Settings ;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
//import android.view.MenuItem;
|
//import android.view.MenuItem;
|
||||||
|
@ -14,11 +15,18 @@ import org.json.JSONObject;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.Manifest;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Icon;
|
||||||
|
|
||||||
public class AppActivity extends Activity {
|
public class AppActivity extends Activity {
|
||||||
|
|
||||||
|
private Icon icon;
|
||||||
|
private Bitmap bitmap;
|
||||||
|
|
||||||
private static final String BASE_URI = "https://alexmahr.de";
|
private static final String BASE_URI = "https://alexmahr.de";
|
||||||
public String readFileFromAssets(String filename) {
|
public String readFileFromAssets(String filename) {
|
||||||
String filecontents = "";
|
String filecontents = "";
|
||||||
|
@ -41,13 +49,26 @@ public class AppActivity extends Activity {
|
||||||
// this removes the title bar (a ~1cm big strip at the top of the app showing its name
|
// this removes the title bar (a ~1cm big strip at the top of the app showing its name
|
||||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
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....)
|
// we create the webview (at least on the android 14 that is a webview that features avif + websockets etc....)
|
||||||
|
// int PERMISSION_GRANTED=0;
|
||||||
|
// if( checkSelfPermission( Manifest.permission.POST_NOTIFICATIONS) == PERMISSION_GRANTED)
|
||||||
|
// {
|
||||||
|
requestPermissions( new String[] {Manifest.permission.POST_NOTIFICATIONS},1);
|
||||||
|
// }
|
||||||
WebView myWebView = new WebView(this);//activityContext);
|
WebView myWebView = new WebView(this);//activityContext);
|
||||||
// MyJavascriptInterface myJavaScriptInterface = new MyJavascriptInterface(this,myWebView);
|
// MyJavascriptInterface myJavaScriptInterface = new MyJavascriptInterface(this,myWebView);
|
||||||
// we create a webview (there is also setwebviewclient-vs-setwebchromeclient
|
// we create a webview (there is also setwebviewclient-vs-setwebchromeclient
|
||||||
WebViewClient myWebViewClient= new WebViewClient();
|
// WebViewClient myWebViewClient= new WebViewClient();
|
||||||
myWebView.setWebViewClient(myWebViewClient);
|
// myWebView.setWebViewClient(myWebViewClient);
|
||||||
|
WebChromeClient myWebChromeClient= new WebChromeClient();
|
||||||
|
myWebView.setWebChromeClient(myWebChromeClient);
|
||||||
|
|
||||||
|
setupNotificationChannelShit();
|
||||||
|
// bitmap = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
|
|
||||||
// to setup settings
|
// to setup settings
|
||||||
WebSettings myWebSettings = myWebView.getSettings();
|
WebSettings myWebSettings = myWebView.getSettings();
|
||||||
|
myWebView.setWebContentsDebuggingEnabled(true);
|
||||||
myWebSettings.setBuiltInZoomControls(true);
|
myWebSettings.setBuiltInZoomControls(true);
|
||||||
myWebSettings.setDisplayZoomControls(false);
|
myWebSettings.setDisplayZoomControls(false);
|
||||||
myWebSettings.setJavaScriptEnabled(true);
|
myWebSettings.setJavaScriptEnabled(true);
|
||||||
|
@ -63,6 +84,46 @@ public class AppActivity extends Activity {
|
||||||
//myWebView.loadUrl("https://alexmahr.de/ru");
|
//myWebView.loadUrl("https://alexmahr.de/ru");
|
||||||
setContentView(myWebView);
|
setContentView(myWebView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setupNotificationChannelShit(){
|
||||||
|
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
// The id of the channel.
|
||||||
|
String id = "my_channel_01";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int importance = NotificationManager.IMPORTANCE_LOW;
|
||||||
|
|
||||||
|
NotificationChannel mChannel = new NotificationChannel(id, "calender app channel",importance);
|
||||||
|
|
||||||
|
// Configure the notification channel.
|
||||||
|
mChannel.setDescription("description");
|
||||||
|
|
||||||
|
mChannel.enableLights(true);
|
||||||
|
// Sets the notification light color for notifications posted to this
|
||||||
|
// channel, if the device supports this feature.
|
||||||
|
mChannel.setLightColor(Color.RED);
|
||||||
|
|
||||||
|
mChannel.enableVibration(true);
|
||||||
|
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
|
||||||
|
|
||||||
|
mNotificationManager.createNotificationChannel(mChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public String androidNotification(String message,String title,int id) {
|
||||||
|
Notification notif = new Notification.Builder(this)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(message)
|
||||||
|
.setSmallIcon(getResources().getIdentifier("appicon", "drawable", getPackageName()))
|
||||||
|
.setChannelId("my_channel_01")
|
||||||
|
.build();
|
||||||
|
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
|
nm.notify(id, notif);
|
||||||
|
return message+ title+"this is good";
|
||||||
|
}
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// this.webview.evaluateJavascript("(setTimeout(()=>{document.body.innerHTML='all gone';},2000)()",null);
|
// this.webview.evaluateJavascript("(setTimeout(()=>{document.body.innerHTML='all gone';},2000)()",null);
|
||||||
|
|
Loading…
Add table
Reference in a new issue