forked from FOSS/BangleApps
Merge branch 'master' into no-undef
commit
80354248fa
|
@ -20,9 +20,9 @@ Bangle.js 1
|
|||
- SELECT: BTN2
|
||||
|
||||
Bangle.js 2
|
||||
- Swipes to change visible buttons
|
||||
- Click physical button to exit
|
||||
- Press upper left corner of screen to exit (where the red back button would be)
|
||||
- Swipe up or down to go back to the number input
|
||||
- Swipe to the left for operators, swipe to the right for the special functions
|
||||
- Exit by pressing the physical button or the upper left corner of screen to exit (where the red back button would be)
|
||||
## Creator
|
||||
|
||||
<https://twitter.com/fredericrous>
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
0.05: Reported image for battery is now transparent (2v18+)
|
||||
0.06: When >1 clockinfo, swiping one back tries to ensure they don't display the same thing
|
||||
0.07: Developer tweak: clkinfo load errors are emitted
|
||||
0.08: Pass options to show(), hide() and run(), and add focus() and blur() item methods
|
||||
|
|
|
@ -70,10 +70,12 @@ Note that each item is an object with:
|
|||
}
|
||||
```
|
||||
|
||||
* `item.show` : called when item should be shown. Enables updates. Call BEFORE 'get'
|
||||
* `item.hide` : called when item should be hidden. Disables updates.
|
||||
* `item.show` : called when item should be shown. Enables updates. Call BEFORE 'get'. Passed the clockinfo options (same as what's returned from `addInteractive`).
|
||||
* `item.hide` : called when item should be hidden. Disables updates. Passed the clockinfo options.
|
||||
* `.on('redraw', ...)` : event that is called when 'get' should be called again (only after 'item.show')
|
||||
* `item.run` : (optional) called if the info screen is tapped - can perform some action. Return true if the caller should feedback the user.
|
||||
* `item.focus` : called when the item is focussed (the user has tapped on it). Passed the clockinfo options.
|
||||
* `item.blur` : called when the item is unfocussed (the user has tapped elsewhere, the screen has locked, etc). Passed the clockinfo options.
|
||||
|
||||
See the bottom of `lib.js` for example usage...
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ exports.addInteractive = function(menu, options) {
|
|||
options.redrawHandler = ()=>drawItem(itm);
|
||||
itm.on('redraw', options.redrawHandler);
|
||||
itm.uses = (0|itm.uses)+1;
|
||||
if (itm.uses==1) itm.show();
|
||||
if (itm.uses==1) itm.show(options);
|
||||
itm.emit("redraw");
|
||||
}
|
||||
function menuHideItem(itm) {
|
||||
|
@ -242,7 +242,7 @@ exports.addInteractive = function(menu, options) {
|
|||
delete options.redrawHandler;
|
||||
itm.uses--;
|
||||
if (!itm.uses)
|
||||
itm.hide();
|
||||
itm.hide(options);
|
||||
}
|
||||
// handling for swipe between menu items
|
||||
function swipeHandler(lr,ud){
|
||||
|
@ -284,38 +284,47 @@ exports.addInteractive = function(menu, options) {
|
|||
E.stopEventPropagation&&E.stopEventPropagation();
|
||||
}
|
||||
Bangle.on("swipe",swipeHandler);
|
||||
const blur = () => {
|
||||
options.focus=false;
|
||||
delete Bangle.CLKINFO_FOCUS;
|
||||
const itm = menu[options.menuA].items[options.menuB];
|
||||
let redraw = true;
|
||||
if (itm.blur && itm.blur(options) === false)
|
||||
redraw = false;
|
||||
if (redraw) options.redraw();
|
||||
};
|
||||
const focus = () => {
|
||||
let redraw = true;
|
||||
Bangle.CLKINFO_FOCUS=true;
|
||||
if (!options.focus) {
|
||||
options.focus=true;
|
||||
const itm = menu[options.menuA].items[options.menuB];
|
||||
if (itm.focus && itm.focus(options) === false)
|
||||
redraw = false;
|
||||
}
|
||||
if (redraw) options.redraw();
|
||||
};
|
||||
let touchHandler, lockHandler;
|
||||
if (options.x!==undefined && options.y!==undefined && options.w && options.h) {
|
||||
touchHandler = function(_,e) {
|
||||
if (e.x<options.x || e.y<options.y ||
|
||||
e.x>(options.x+options.w) || e.y>(options.y+options.h)) {
|
||||
if (options.focus) {
|
||||
options.focus=false;
|
||||
delete Bangle.CLKINFO_FOCUS;
|
||||
options.redraw();
|
||||
}
|
||||
if (options.focus)
|
||||
blur();
|
||||
return; // outside area
|
||||
}
|
||||
if (!options.focus) {
|
||||
options.focus=true; // if not focussed, set focus
|
||||
Bangle.CLKINFO_FOCUS=true;
|
||||
options.redraw();
|
||||
focus();
|
||||
} else if (menu[options.menuA].items[options.menuB].run) {
|
||||
Bangle.buzz(100, 0.7);
|
||||
menu[options.menuA].items[options.menuB].run(); // allow tap on an item to run it (eg home assistant)
|
||||
} else {
|
||||
options.focus=true;
|
||||
Bangle.CLKINFO_FOCUS=true;
|
||||
menu[options.menuA].items[options.menuB].run(options); // allow tap on an item to run it (eg home assistant)
|
||||
}
|
||||
};
|
||||
Bangle.on("touch",touchHandler);
|
||||
if (settings.defocusOnLock) {
|
||||
lockHandler = function() {
|
||||
if(options.focus) {
|
||||
options.focus=false;
|
||||
delete Bangle.CLKINFO_FOCUS;
|
||||
options.redraw();
|
||||
}
|
||||
if(options.focus)
|
||||
blur();
|
||||
};
|
||||
Bangle.on("lock", lockHandler);
|
||||
}
|
||||
|
@ -352,6 +361,7 @@ exports.addInteractive = function(menu, options) {
|
|||
|
||||
return true;
|
||||
};
|
||||
if (options.focus) focus();
|
||||
delete settings; // don't keep settings in RAM - save space
|
||||
return options;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "clock_info",
|
||||
"name": "Clock Info Module",
|
||||
"shortName": "Clock Info",
|
||||
"version":"0.07",
|
||||
"version":"0.08",
|
||||
"description": "A library used by clocks to provide extra information on the clock face (Altitude, BPM, etc)",
|
||||
"icon": "app.png",
|
||||
"type": "module",
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
0.05: Updated clkinfo icon.
|
||||
0.06: Ensure Timer supplies an image for clkinfo items
|
||||
0.07: Update clock_info to avoid a redraw
|
||||
0.08: Timer ClockInfo now updates once a minute
|
||||
0.08: Timer ClockInfo now updates once a minute
|
||||
0.09: Timer ClockInfo resets to timer menu when blurred
|
||||
|
|
|
@ -71,13 +71,19 @@
|
|||
]
|
||||
};
|
||||
|
||||
const restoreMainItem = function(clkinfo) {
|
||||
clkinfo.menuB = 0;
|
||||
// clock info redraws after this
|
||||
};
|
||||
|
||||
var offsets = [+5,-5];
|
||||
offsets.forEach((o, i) => {
|
||||
smpltmrItems.items = smpltmrItems.items.concat({
|
||||
name: null,
|
||||
get: () => ({ text: (o > 0 ? "+" : "") + o + " min.", img: smpltmrItems.img }),
|
||||
show: function() { },
|
||||
hide: function () { },
|
||||
hide: function() { },
|
||||
blur: restoreMainItem,
|
||||
run: function() {
|
||||
if(o > 0) increaseAlarm(o);
|
||||
else decreaseAlarm(Math.abs(o));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "smpltmr",
|
||||
"name": "Simple Timer",
|
||||
"shortName": "Simple Timer",
|
||||
"version": "0.08",
|
||||
"version": "0.09",
|
||||
"description": "A very simple app to start a timer.",
|
||||
"icon": "app.png",
|
||||
"tags": "tool,alarm,timer,clkinfo",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
0.01: First release
|
||||
0.02: Fixed settings changes are actually reflected now and old values are strikethrough
|
||||
0.03: Minor code improvements
|
||||
0.04: Minor code improvements
|
||||
0.04: Fix after regression in 0.03
|
2
core
2
core
|
@ -1 +1 @@
|
|||
Subproject commit bd301be3324775a8f464328ba9e34f750d503a2b
|
||||
Subproject commit 0222d3c5ac608a1b842ffc1f1f79e19276d648fe
|
|
@ -11,10 +11,12 @@ declare module ClockInfo {
|
|||
|
||||
type MenuItem = {
|
||||
name: string,
|
||||
show(): void,
|
||||
hide(): void,
|
||||
show(options: InteractiveOptions): void,
|
||||
hide(options: InteractiveOptions): void,
|
||||
on(what: "redraw", cb: () => void): void, // extending from Object
|
||||
run?(): void,
|
||||
run?(options: InteractiveOptions): void,
|
||||
focus?(options: InteractiveOptions): void | false,
|
||||
blur?(options: InteractiveOptions): void | false,
|
||||
} & (
|
||||
{
|
||||
hasRange: true,
|
||||
|
|
2
webtools
2
webtools
|
@ -1 +1 @@
|
|||
Subproject commit af870d7b8386bfa824b07b268bce414e4daf3fbb
|
||||
Subproject commit 8d671ad0dfb1d5a36f4ee9952390f4d79019e61d
|
Loading…
Reference in New Issue