Avatar for rigrig

rigrig

Member since Apr 2020 • Last active Oct 2022
  • 10 conversations
  • 169 comments

Most recent activity

  • in Bangle.js
    Avatar for rigrig

    This seems to work (in the emulator at least):

    function removeListeners(events) {
          saved = {};
          events.forEach(event=>{
              let listeners = Bangle['#on'+event];
              if (!listeners) return;
              saved[event] = listeners;
              Bangle.removeAllListeners(event);
          });
          return saved;
    }
    function restoreListeners(saved) {
          for (const event in saved) {
              let listeners = saved[event];
              if (typeof listeners !== 'object') listeners = [listeners];
              listeners.forEach(listener => Bangle.on(event, listener));
              delete saved[event];
          }
    }
    
    
    // disable event listeners
    const eventsToRemove = ['touch','swipe','drag','stroke','tap','­gesture','aiGesture'];
    let saved = removeListeners(eventsToRemove);
    
    // do Stuff
    
    // when done:
    restoreListeners(saved);
    
    
  • in Bangle.js
    Avatar for rigrig

    @Sir_Indy Oh, it isn't solely for your benefit ;-) It would also allow me to remove duplicate code from smessages, and just use the default messages library.
    I made a PR for message events. With those changes you could do something like this:

    // aanotifi.boot.js
    Bangle.on("message", (type, message)=> {
          if (type !== "text") return; // let default app handle e.g. "music" or "call"
          require("notify").show(message);
          require("messages").buzz(message.src);
          message.handled = true; // prevent default app from launching    
    });
    
  • in Bangle.js
    Avatar for rigrig

    it's trivial to change this to "dependencies": {"messages":"type"},
    It looks like I'll end up having to do this anyway for @rigrig's.

    I tried that and reverted it, as it turned out to be a bit tricky: if you change messages to "type":"messages" it won't show up in app launchers anymore...

    And hopefully you won't have to anyway, my Plan now is:

    • PR for master messages/lib.js so it does the emit+custom app stuff
      (I thought about it some more, and think this wouldn't be that big a change after all, so wouldn't really cause merge problems)
    • modify my smessages to work with that, so It won't need a duplicate messages library :-)
    • @Sir_Indy could just add a boot.js to aanotifi to listen for message events, show them with a SetLCDOverlay and prevent the default app from launching.
  • in Bangle.js
    Avatar for rigrig

    the idea to put a switch in the Android app (and match it in the iOS app)

    The point is that the Android and iOS apps both call require("messages").pushMessage(...), which launches the default messages app.
    So if you edit messages/lib.js, you only need to change that instead of two apps.

  • in Bangle.js
    Avatar for rigrig

    That's the basic idea, except we don't want to do it in the android app, but in the messages library, so it also works with ios.

    So it becomes

    1. A message is sent from Gadgetbridge to the Bangle.
    2. The Android app receives the Gadgetbridge message.
    3. The Android app tells the messages library it has a new message.
    4. The messages library emits a signal saying it has a new message.
      THEN
    5. A custom app acts on the signal, doing whatever it does.
    6. The messages library sees that something acted on the signal, and does nothing else.
      OR
    7. Nothing receives the signal
    8. The messages app sees that nothing acted on the signal, and launches the default app.

    I've pretty much already done this here, except that is written as a replacement messages app, so it needs to be adapted into messages/lib.js changes instead. (And then the replacement app won't need its own library anymore, yay)

    And as @Gordon noted above, there is a PR waiting which also makes some drastic changes to the library. Also rewriting it into an event driven system might complicate merging "a bit" ;-)

  • in Bangle.js
    Avatar for rigrig

    I like the idea of just keeping the default messages app/widget with the library and deferring to custom apps if installed.

    Maybe we could even do something like this:

    // in message library:
    Bangle.emit("message", event);
    setTimeout(()=>{if (!event.handled) load("messages.app.js");});
    
    // some music widget
    Bangle.on("message", event=> {
            if (event.handled || event.id != 'music') return;
            event.handled = true;
            /* display music info */
    });
    
    // custom messages boot.js
    Bangle.on("message", event => {
            if (event.handled) return;
            event.handled = true; // probably not even needed?
            load('custommessages.app.js');
    });
    
  • in Bangle.js
    Avatar for rigrig

    Calling this.layout.update(); every minute might be expensive?

    You could try removing lazy rendering, and do something like this:

    if (changed.d) { // check days first: may need to update layout
          this.layout.update(); // dayStr could be a different size now
          this.layout.render(this.layout.date);
          this.layout.render(this.layout.dayStr);
    }
    if (changed.h) this.layout.render(this.layout.hour);
    if (changed.m) {
          this.layout.render(this.layout.minutes);­
          this.layout.render(this.layout.steps);
    }
    
  • in Bangle.js
    Avatar for rigrig

    Try making it white-on-transparent

  • in Bangle.js
    Avatar for rigrig

    Using SetLCDOverlay seems pretty awesome :-)

    I'm working on my own messages app (also WIP), some thoughts:

    I took the route of changing the messages library to emit events, that way the Android and iOS app both keep working.

    In general, what I think would be the thing to aim for:

    • Keep the separate android and ios apps, to handle the different events phones can send, and pass on message events with require("messages").pushMessage()
    • Convert the messages app to a library-only "app", which handles storing/retrieving messages, emits a "message" event for every new message, and knows how to do something like require("messages").openApp()
    • Separate widgets/apps which handle "message" events, so users can combine/pick their favourites

    Especially hoping we can get "fast app switching" to work, so we could have e.g. different music players/message viewing apps working smoothly together.

  • in Bangle.js
    Avatar for rigrig

    Weird, maybe comparing your settings.json before and after running the app might provide a clue?

Actions