Added short field and general clkinfo improvements

pull/2314/head
Gabriele Monaco 2022-11-25 18:28:20 +01:00
parent 4ff8e9a52c
commit 18d91bf5f9
8 changed files with 35 additions and 18 deletions

View File

@ -7,3 +7,4 @@
0.07: Clkinfo improvements.
0.08: Fix error in clkinfo (didn't require Storage & locale)
Fix clkinfo icon
0.09: Clkinfo new fields and filter past events.

View File

@ -1,25 +1,34 @@
(function() {
var agendaItems = {
name: "Agenda",
img: atob("GBiBAAAAAAAAAADGMA///w///wf//wAAAA///w///w///w///x///h///h///j///D///X//+f//8wAABwAADw///w///wf//gAAAA=="),
items: []
};
name: "Agenda",
img: atob("GBiBAAAAAAAAAADGMA///w///wf//wAAAA///w///w///w///x///h///h///j///D///X//+f//8wAABwAADw///w///wf//gAAAA=="),
dynamic: true,
items: []
};
var storage = require("Storage");
var locale = require("locale");
var now = new Date();
var agenda = require("Storage").readJSON("android.calendar.json")
.filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000)
.sort((a,b)=>a.timestamp - b.timestamp);
var agenda = (storage.readJSON("android.calendar.json",true)||[])
.filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000)
.sort((a,b)=>a.timestamp - b.timestamp);
var settings = storage.readJSON("agenda.settings.json",true)||{};
agenda.forEach((entry, i) => {
var title = entry.title.slice(0,12);
var date = new Date(entry.timestamp*1000);
var dateStr = locale.date(date).replace(/\d\d\d\d/,"");
var dateStrToday = locale.date(new Date()).replace(/\d\d\d\d/,"");
var timeStr = locale.time(date);
//maybe not the most efficient..
var shortTxt = (dateStrToday == dateStr) ? timeStr : dateStr;
dateStr += entry.durationInSeconds < 86400 ? "/ " + locale.time(date,1) : "";
if(!settings.pastEvents && entry.timestamp + entry.durationInSeconds < (new Date())/1000)
return;
agendaItems.items.push({
name: "Agenda "+i,
get: () => ({ text: title + "\n" + dateStr, img: null}),
name: null,
get: () => ({ text: title + "\n" + dateStr, short: shortTxt, img: null}),
show: function() { agendaItems.items[i].emit("redraw"); },
hide: function () {}
});

View File

@ -14,4 +14,4 @@
Improve timer message using formatDuration
Fix wrong fallback for buzz pattern
0.13: Ask to delete a timer after stopping it
0.14: Added clkinfo here
0.14: Added clkinfo for alarms and timers

View File

@ -54,13 +54,15 @@
var alarmItems = {
name: "Alarms",
img: img,
dynamic: true,
items: alarm.getAlarms().filter(a=>!a.appid)
//.sort((a,b)=>alarm.getTimeToAlarm(a)-alarm.getTimeToAlarm(b))
.sort((a,b)=>getAlarmOrder(a)-getAlarmOrder(b))
.map((a, i)=>({
name: null,
hasRange: true,
get: () => ({ text: getAlarmText(a), img: getAlarmIcon(a),
hasRange: true, v: getAlarmValue(a), min:0, max:getAlarmMax(a)}),
v: getAlarmValue(a), min:0, max:getAlarmMax(a)}),
show: function() { alarmItems.items[i].emit("redraw"); },
hide: function () {},
run: function() { }

View File

@ -14,3 +14,4 @@
0.15: Fix widget icon
0.16: Don't mark app as clock
0.17: Added clkinfo for clocks.
0.18: Added hasRange to clkinfo.

View File

@ -21,22 +21,25 @@
items: [
{
name: "temperature",
hasRange : true,
get: () => ({ text: weather.temp, img: atob("GBiBAAA8AAB+AADnAADDAADDAADDAADDAADDAADbAADbAADbAADbAADbAADbAAHbgAGZgAM8wAN+wAN+wAM8wAGZgAHDgAD/AAA8AA=="),
hasRange: true, v: parseInt(weather.temp), min: -30, max: 55}),
v: parseInt(weather.temp), min: -30, max: 55}),
show: function() { weatherItems.items[0].emit("redraw"); },
hide: function () {}
},
{
name: "humidity",
hasRange : true,
get: () => ({ text: weather.hum, img: atob("GBiBAAAEAAAMAAAOAAAfAAAfAAA/gAA/gAI/gAY/AAcfAA+AQA+A4B/A4D/B8D/h+D/j+H/n/D/n/D/n/B/H/A+H/AAH/AAD+AAA8A=="),
hasRange: true, v: parseInt(weather.hum), min: 0, max: 100}),
v: parseInt(weather.hum), min: 0, max: 100}),
show: function() { weatherItems.items[1].emit("redraw"); },
hide: function () {}
},
{
name: "wind",
hasRange : true,
get: () => ({ text: weather.wind, img: atob("GBiBAAHgAAPwAAYYAAwYAAwMfAAY/gAZh3/xg//hgwAAAwAABg///g//+AAAAAAAAP//wH//4AAAMAAAMAAYMAAYMAAMcAAP4AADwA=="),
hasRange: true, v: parseInt(weather.wind), min: 0, max: 118}),
v: parseInt(weather.wind), min: 0, max: 118}),
show: function() { weatherItems.items[2].emit("redraw"); },
hide: function () {}
},

View File

@ -1,7 +1,7 @@
{
"id": "weather",
"name": "Weather",
"version": "0.17",
"version": "0.18",
"description": "Show Gadgetbridge weather report",
"icon": "icon.png",
"screenshots": [{"url":"screenshot.png"}],

View File

@ -2,9 +2,9 @@
that can be scrolled through on the clock face.
`load()` returns an array of menu objects, where each object contains a list of menu items:
* `name` : text to display and identify menu object (e.g. weather)
* `img` : a 24x24px image
* `dynamic` : if `true`, items are not constant but are sorted (e.g. calendar events sorted by date)
* `items` : menu items such as temperature, humidity, wind etc.
Note that each item is an object with:
@ -15,6 +15,7 @@ Note that each item is an object with:
{
'text' // the text to display for this item
'short' : (optional) a shorter text to display for this item (at most 6 characters)
'img' // optional: a 24x24px image to display for this item
'v' // (if hasRange==true) a numerical value
'min','max' // (if hasRange==true) a minimum and maximum numerical value (if this were to be displayed as a guage)