Switching themes from custom.html #5900
Replies: 1 comment
-
Posted at 2023-05-04 by stweedo I was able to use this reference as a starting point and then added the code from rigrig to my settings.js file and I'm happy to report that it now switches properly :) Thank you! @rigrig Posted at 2023-05-04 by stweedo I got the upload button to work. I forgot to add the I also had to change Now it sends the right app code, but it still doesn't load the new app after rebooting and goes back to the Anton clock. I'm guessing this is a conflict with the theme setting I'm trying to pass from the app loader. Posted at 2023-05-05 by stweedo It looks like my main issue is it's not sending or creating a shadowclk.json file when uploading the app to the watch Posted at 2023-05-05 by stweedo I got it to create the json file correctly now, but it won't load my clock automatically after uploading and the theme setting in the json file isn't being read or applied automatically (works through the settings menu though) Posted at 2023-05-05 by stweedo I've just realized that installing a new clock does not automatically set it as your default or run it immediately. Is there a way to autorun the app after installing from the app loader? If I can fix that and have it apply the system theme automatically then it'll function exactly as I had envisioned. Any suggestions would be much appreciated. Posted at 2023-05-05 by @gfwilliams
Not at the moment, no. If it's the only clock installed it'll be used, but while there are other clocks they will likely be used first. However you could:
Posted at 2023-05-05 by stweedo
That sounds perfect for installing the app with the default values and then having the interface.html set up for configuring the color and theme. I'll definitely check this out, thanks! Could you elaborate on how to start my app on the bangle.js from an interface.html? That's really all I have left to implement, I think. Posted at 2023-05-08 by stweedo I've got my I'm sure there are a number of ways it could be better and I'm open to all suggestions. If anyone knows how I can set the preview to show what's in the watch settings already, please let me know. Thanks. I did use some AI assistance with the coding since I'm still very new to programming and trying to learn as I go so there may be some glaringly obvious issues that I don't see. You can try it from here. Posted at 2023-05-08 by @thyttan EDIT: Sorry, I didn't read your question properly. I don't know how to do what you're asking for 🙃 You can upload the shadowclk.json file to the bangle by specifying it in the metadata. One example where I upload JSON files on app install is here: https://github.com/thyttan/BangleApps/tree/my-setup/apps%2Fmysetup Posted at 2023-05-08 by stweedo I'm able to write to Posted at 2023-05-08 by @thyttan Reading this: https://github.com/espruino/BangleApps#metadatajson-interface-element ... makes me think you need to do something like this: ... where Bluetooth.println() seems essential to me. It's also used for sending messages from the bangle triggering intents on android devices, like this: https://www.espruino.com/Gadgetbridge#intents Again, I don't know exactly though. EDIT: For another example, 'Sleep Log' app also uses interface.html. Posted at 2023-05-09 by stweedo Thank you, I'll have a look at those examples. I did look at gpsrec earlier as suggested by the readme for a full example, but it's not clear how to get the key value pair data out of the JSON to use as a variable in the HTML code Posted at 2023-05-09 by stweedo I got it to read the settings and it sets the preview accordingly, but only after opening the interface window a second time. Not sure why yet. Also, it would be awesome if it was able to send a Posted at 2023-05-09 by @gfwilliams Literally just sending In many ways it might actually be better to just add a global option in the app loader that said "load app after upload" or something? Posted at 2023-05-09 by stweedo I was trying
I'm sure some people would appreciate the option. For now I just have a message displayed saying "Hold the button on Bangle.js" after they upload the config they want Posted at 2023-05-09 by stweedo Something in my
and this function in 'comms.js'
I think this is why the settings don't always load properly for the preview, it was around every third try opening the interface that it would load them and it would stay working for a while but then it would go back to using my default values. Posted at 2023-05-10 by stweedo The communication mostly works now and I've added some better error handling in my code. In gadgetbridge it shows an error whenever I read from or write to the bangle. Chrome doesn't show any errors. Both still have communication issues sometimes when using my interface. The error gadgetbridge shows is "Malformed JSON from Bangle.js: No value for t". The logs show my shadowclk.json data being fragmented. Do I just need to send it a "t" value first so it doesn't throw that error?
Posted at 2023-05-10 by @gfwilliams I realise this was posted both on GitHub and here, but just for others, the To work around it instead of using Posted at 2023-05-10 by stweedo Yep, I meant to come back here and clarify that as well. Exactly as Gordon suggested, I had to add square brackets [...] around the
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2023-05-04 by stweedo
Hi,
I could use a little guidance on how to implement setting the system theme to either
Light BW
orDark BW
through both a custom.html and a settings.js file for my app. Does anyone have a link to the code where theSettings/System/Theme
menu is from?I did find this example by @rigrig that switches to the two themes i want to use. Should I try to incorporate this into my code? - Or is there an existing system function for doing this that could be called from anywhere globally?
If anyone feels like taking a look at what i have so far, it's right here. Right now the settings menu only works to set the color on the watch face. Edit: Settings.js is now fixed
Beta Was this translation helpful? Give feedback.
All reactions