Dark mode / light mode on Edge devices?

So the new Edge devices seems to have dark or light mode on their widgets overview with glances.

I'm aware there is a function getBackgroundColor() to do that for DataFields, but it seems not to be working in a GlanceView

But how can I know when to draw a black or a white background on my GlanceView?

  • Been to quick (after hours of searching :D), but I guess it's isNightModeEnabled from deviceSettings.

  • When I got my Edge 1040 in March I was trying to figure out the same thing.  I never got isNightModeEnabled to work in the simulator,, and realized the getBackgroundColor only works in data fields.  I eventually worked out that the day/night is tied into the local sunrise/sunset time.  Since the edge devices with glance views also have access to the sunrise/sunset via the weather API, I worked out a way to check the time and I set the background based on the current time and the last location from when the widget was run.  In my current version of the widget, I assume it is set to auto and display a white background if the current time is greater than sunrise and less than sunset for the current day.  Otherwise I display a black background.

    I guess I need to test it on my actual device to see it it really does work.

  • That's an interesting option indeed. I've tried isNightModeEnabled and a user confirmed it was working correctly.

  • I guess I should have actually tried it on my device.  I will do that this evening.  When it works then it would solve the issue about when a user manually set to light or dark instead of the auto default.  Now I just assumed it is auto and show it light during the day and dark at night.

  • So, if isNightModeEnabled is true, the background for a glance should be black and if false, white?

  • Jim, that is a pretty good summary.  The Edge devices which are CIQ 4, i.e. Edge x40 and explorer 2, have a display setting for auto, day mode, or night mode.  Day mode used a white background for the system where night mode uses a black background.  When you use auto it switches based on the time of day between a light background and a dark background.  The time of the switch appears to be tied to sunrise/sunset for the current position.  To make your glance view match you need to set the background to match the behavior of the system.

    Not sure what problem I had the last time I tried to looking at isNightModeEnabled, but I got it to work in the simulator tonight and on the device.  So now I will simplify my code and make it properly handle what ever setting the user has selected.

  • The only issue I had was the simulator not responding to the NighMode settings from the menu. I mean, my code responds to it, but the general glance view of the device (simulator) kept always black, only my glance responded to that setting. So it was a bit confusing, but on a real device it seems to work as expected.

  • After you change the settings you have to move the glance up or down to force a UI update.  Then it will update as on the device.  I was changing the setting then rerunning the app to see the settings change.  I accidentally swiped down after changing the settings and my screen switched.