Widget Visibility

Posted on
  • I have quite a few widgets running such as battery, bluetooth, gpsrec, ANCS etc and although they are incredibly useful, they do clutter up the screen and take away from the design simplicity of some of the clock faces I use. In an attempt to have the best of both worlds, I have added the following code to the clock apps I use. Touching the left side of the screen hides all widgets and touching the right side re-displays them.

    var widgetVis = {
          if (!Bangle.isLCDOn() || this.saved) return;
          this.saved = [];
          for (var wd of WIDGETS) {
          if (!Bangle.isLCDOn() || !this.saved) return;
          for (var wd of WIDGETS) wd.draw = this.saved.shift();
          setWatch(this.hide, BTN4, {repeat:true,edge:"rising"});
          setWatch(this.reveal, BTN5, {repeat:true,edge:"rising"});

    It is not enough to simply blank out the widget area and then avoid calling drawWidget() since many widgets redraw based on timer events etc. The methods above replace widget draw functions with null functions and then restore the old draw functions when widgets are not hidden.

    If others feel this is a useful facility, it might be sensible to have a standard way to hiding widgets while leaving them running. There may well be a better way of doing this than the one I have outlined.

  • I think this is a very very useful feature.

    I general challenge I see with the user of the buttons and touch areas. I'd put them in a larger context and have some 'prefix' for the various Bangle platform / non-application related functions, such as an introductory longer press. I know it is a challenge to come up general specs with new features popping up and no / not many apps have used them yet.

    I had initially the thoughts for being able to define the sequence / sort order of the widgets (by some user configurable priority) and of scrolling thru the widgets... after all, there is only very limited space... Widgets would then become like mini (display) app.

    Combining it with your great feature, I could alternative think of widget set that can be cycled thru, and one of this widget set is the empty set: no widgets displayed.

    The matter wether the widget is displayed / drawn or not would be widget id controlled instead of absolutely.

  • Thanks - that's a good solution! I guess this could itself be made a widget which would allow them to be shown/hidden.

    Looking at the draw code, you could probably set area="none",x=0,y=-24 to have a similar effect, but actually that would still cause the widget draw code to be run - it just wouldn't display anything

  • Thanks, that’s a great idea, I will try it as a widget, although, I will have to work out some way of restoring the button handlers after the screen is grabbed for an alert.

    ** That works well. Will submit pull request for widviz widget.

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

Widget Visibility

Posted by Avatar for jeffmer @jeffmer