Show a widget only NOT on clock screen?

Posted on
  • Hey All,
    I have the top digital clock widget and it's super useful when messages is full screen or when in settings, or apps etc. Is it possible to have it not show on the clock screen but show everywhere else?

  • I don't think so unless you modify each App. Each App or clock is responsible for calling Bangle. loadWidgets() and Bangle. draw widgets().

    There is a hide widgets app where you swipe to hide / unhide the widgets. I think someone has done a pull request for that, so it will become available in the new year.

  • I don't think so unless you modify each App. Each App or clock is responsible for calling Bangle. loadWidgets() and Bangle. draw widgets().

    Nah, not all apps. Just all widgets and the clock (the widgets are most likely to modify the clock when the clock isn't doing it itself [e.g. the lock widget when the screen times out]. The issue is ofc when a widget redraws the widgets when you are at an app, then you loose the digital clock. The only solution for this would be to know which app is loaded inside the drawWidget function, which I don't know if possible).

    If you load your own library as function into it, it becomes as easy as replacing Bangle.drawWidgets(); with require("helper").drawWidgets(); in all of these files. A bit tideous and updating sucks, but hey, what one wouldn't do to have the watch just like one likes it.

  • Would removing that widget from the global.WIDGETS in your clock app do the trick? Then that would be the only app that needs modifying.

  • hey thats pretty smart. Works well!

  • It looks like the widget already tries not to run for clock apps: https://github.com/espruino/BangleApps/b­lob/d9d5926416566762e59b953c745f989d23c9­b334/apps/widclk/widget.js#L6

    But Bangle.CLOCK is only set if the clock uses Bangle.setUI(), so maybe your clock app doesn't use that?

    If that's the case, I guess we should modify the widget to (also) check using __FILE__:

    (()=>{
      if (Bangle.CLOCK) {return;} // app used setUI('clock') or setUI('clockupdown')
    
      // app didn't call Bangle.setUI('clock...'), but might still be a clock, 
      // look at <appid>.info to make sure
      if (typeof __FILE__ === 'string') { // only exists since 2v09
        const info = require("Storage").readJSON(__FILE__.spl­it(".")[0]+".info",1)||false;
        if (info && info.type==="clock") { // info can have no type (but then it isn't a clock)
          return;
        }
      }
    
      // current app is not a clock:
      WIDGETS["wdclk"]={...};
    })();
    
  • __FILE__ is what exactly? The currently loaded app file?

  • Yes, when load(filename) is used, the global variable __FILE__ is set to filename.
    (I couldn't find it anywhere in the docs except in the changelog: https://github.com/espruino/Espruino/blo­b/53108085800141bec24ba0164c7880678f573a­43/ChangeLog#L172)

  • Thats neat! Yeah maybe in API reference Globals section?

  • The digital clock widget should not show when on a clock. It doesn't for Anton for instance.

    The issue is setUI (or just Bangle.CLOCK=1 if not using setUI) should be set before calling Bangle.loadWidgets().

    If you do that then the widget (or any other similar widget!) will not be displayed.

    Which clock are you having trouble with and I could push some changes?

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

Show a widget only NOT on clock screen?

Posted by Avatar for andiohn @andiohn

Actions