Merge pull request #3807 from voloved/moon_phase_hide
Added ability to hide moon phase widgetmaster
commit
e34cd3dcda
|
|
@ -7,3 +7,4 @@
|
||||||
0.07: Use default Bangle formatter for booleans
|
0.07: Use default Bangle formatter for booleans
|
||||||
0.08: Better formula for the moon's phase
|
0.08: Better formula for the moon's phase
|
||||||
0.09: Fix variable declaration
|
0.09: Fix variable declaration
|
||||||
|
0.10: Added ability to hide widget
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "widmp",
|
"id": "widmp",
|
||||||
"name": "Moon Phase",
|
"name": "Moon Phase",
|
||||||
"version": "0.09",
|
"version": "0.10",
|
||||||
"description": "Display the current moon phase in blueish (in light mode) or white (in dark mode) for both hemispheres. In the southern hemisphere the 'My Location' app is needed.",
|
"description": "Display the current moon phase in blueish (in light mode) or white (in dark mode) for both hemispheres. In the southern hemisphere the 'My Location' app is needed.",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
var settings = Object.assign({
|
var settings = Object.assign({
|
||||||
default_colour: true,
|
default_colour: true,
|
||||||
|
hide: false,
|
||||||
red: 0,
|
red: 0,
|
||||||
green: 0,
|
green: 0,
|
||||||
blue: 0,
|
blue: 0,
|
||||||
|
|
@ -30,6 +31,13 @@
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Hide Widget": {
|
||||||
|
value: settings.hide,
|
||||||
|
onchange: () => {
|
||||||
|
settings.hide = !settings.hide;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
"Custom...": () => E.showMenu(custommenu)
|
"Custom...": () => E.showMenu(custommenu)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
var lastCalculated = 0; // When we last calculated the phase
|
var lastCalculated = 0; // When we last calculated the phase
|
||||||
var phase = 0; // The last phase we calculated
|
var phase = 0; // The last phase we calculated
|
||||||
var southernHemisphere = false; // when in southern hemisphere -- use the "My Location" App
|
var southernHemisphere = false; // when in southern hemisphere -- use the "My Location" App
|
||||||
|
var settings;
|
||||||
|
|
||||||
// https://github.com/deirdreobyrne/LunarPhase
|
// https://github.com/deirdreobyrne/LunarPhase
|
||||||
function moonPhase(sec) {
|
function moonPhase(sec) {
|
||||||
|
|
@ -39,14 +40,18 @@
|
||||||
g.drawLine(CenterX-leftFactor*y,CenterY+x, CenterX+rightFactor*y,CenterY+x);
|
g.drawLine(CenterX-leftFactor*y,CenterY+x, CenterX+rightFactor*y,CenterY+x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMoonColour(g) {
|
function reloadSettings() {
|
||||||
var settings = Object.assign({
|
settings = Object.assign({
|
||||||
default_colour: true,
|
default_colour: true,
|
||||||
|
hide: false,
|
||||||
red: 0,
|
red: 0,
|
||||||
green: 0,
|
green: 0,
|
||||||
blue: 0,
|
blue: 0,
|
||||||
}, require('Storage').readJSON("widmp.json", true) || {});
|
}, require('Storage').readJSON("widmp.json", true) || {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMoonColour(g) {
|
||||||
if (settings.default_colour) {
|
if (settings.default_colour) {
|
||||||
if (g.theme.dark) {
|
if (g.theme.dark) {
|
||||||
g.setColor(0xffff); // white
|
g.setColor(0xffff); // white
|
||||||
|
|
@ -62,6 +67,7 @@
|
||||||
|
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
|
if (settings.hide) return;
|
||||||
const CenterX = this.x + 12, CenterY = this.y + 12, Radius = 11;
|
const CenterX = this.x + 12, CenterY = this.y + 12, Radius = 11;
|
||||||
let leftFactor, rightFactor;
|
let leftFactor, rightFactor;
|
||||||
|
|
||||||
|
|
@ -90,9 +96,11 @@
|
||||||
drawMoonPhase(CenterX,CenterY, Radius, leftFactor,rightFactor);
|
drawMoonPhase(CenterX,CenterY, Radius, leftFactor,rightFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reloadSettings();
|
||||||
|
var wid = settings.hide ? 0 : 24;
|
||||||
WIDGETS["widmp"] = {
|
WIDGETS["widmp"] = {
|
||||||
area: "tr",
|
area: "tr",
|
||||||
width: 24,
|
width: wid,
|
||||||
draw: draw
|
draw: draw
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue