[Default launcher] Issue with loadWidgets()

Posted on
  • Hello!
    I'm trying to add a fullscreen mode to the default Launcher. The code is in this branch and it works. I'll send a PR to upstream later.

    I noticed that other fullscreen apps load the widgets overriding the draw method using this code:

    for (let wd of WIDGETS) {
    	wd.draw = () => {};
    	wd.area = ""; 
    }
    

    I like the idea so I updated the code:

    Bangle.loadWidgets();
    
    if (settings.fullscreen) {
    	for (let wd of WIDGETS) {
    		wd.draw = () => {};
    		wd.area = ""; 
    	}
    } else {
    	Bangle.drawWidgets();
    }
    

    I did some tests: the fullscreen mode works but I don't receive the notifications. The same approach works in other apps (like the Pebble Clock).

    Am I missing something?

    Thank you :-)

  • Interesting - I think the issue is that when a message arrives in a clock it is handled differently to an app, and the launcher is treated as an app.

    If you don't want widgets in the launcher, don't call Bangle.loadWidgets();/Bangle.drawWidgets­();. I think that's the best bet - hiding the widgets is a bit of a hack that's done so that the clocks can still access them (eg for the pedometer).

    I guess the underlying issue is the messages widget buzzes in the draw handler though, so if you erase the draw handler it won't buzz. Even so just having your watch buzzing with no clue as to why probably isn't ideal.

  • If you don't want widgets in the launcher, don't call Bangle.loadWidgets();/Bangle.drawWidgets­();. I think that's the best bet - hiding the widgets is
    a bit of a hack that's done so that the clocks can still access them (eg for the pedometer).

    Yeah, it makes sense.
    Probably the for (let wd of WIDGETS) { wd.draw = () => {}; wd.area = ""; } hack will die after #1466 (I haven't deepened yet on this issue but I'd like to work on it).

    I guess the underlying issue is the messages widget buzzes in the draw handler though, so if you erase the draw handler it won't buzz.

    Pebble Clock erase the draw handler but it buzzes. Anyway I'm fine with not loading/drawing the widgets in fullscreen mode :-)

    Thank you!

  • Anyway I'm fine with not loading/drawing the widgets in fullscreen mode :-)

    Hi @Alessandro

    If you choose to do that for your app then I think it should be made clear in the README file that the widgets wont be loaded and the Pedometer App will not count steps while your App is running. Otherwise we could start to get people saying the step counter is under counting etc.

    Now that we can use Bangle.getHealthStatus("day").steps in a widget there is no need to count steps using Bangle.on('step'). This is an argument for phasing out use of the old Pedometer widgets in my opinion. As far as I know the Pedometer widget is the only widget that has to be running all the time to produce an accurate result.

  • Hello @HughB

    If you choose to do that for your app then I think it should be made clear in the README file that the widgets wont be loaded and the Pedometer App will not count steps while your App is running. Otherwise we could start to get people saying the step counter is under counting etc.

    This should not be a problem because people usually don't keep the launcher opened while walking but you're right. Soon I'll send a PR about it :-)

    Now that we can use Bangle.getHealthStatus("day").steps in a widget there is no need to count steps using Bangle.on('step'). This is an argument for phasing out use of the old Pedometer widgets in my opinion. As far as I know the Pedometer widget is the only widget that has to be running all the time to produce an accurate result.

    Agree. I made this change on Pebble Clock some days ago.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

[Default launcher] Issue with loadWidgets()

Posted by Avatar for Alessandro @Alessandro

Actions