How can I find the current background/foreground color?

It seems strange that there is not a specific get function to determine the current background color of a device.  How can this be accomplished when creating a widget and widget glance.  Specifically I have multiple devices with different glance backgrounds.  If I want to stay consistent with the overall look and feel I need to know what current is.  I'm not talking about night mode, I'm asking about simple standard displays.  Fenix 6 glances are black background with white lettering not to mention title in caps, Edge 1050 is white background with black lettering in lower case.  This really seems fundamental to me!  I am not able to find where I could find the current background color or for that matter even the device the widget is running on. Thanks for your help in advance.

  • Maybe System.DeviceSettings.PartNumber can help you?

    The architecture also enables you to create specific code for each supported device.

  • Yeah I looked at that.  I was thinking I could at least determine the standard background color based on part number.  The problem is there is no distinction of device type based on part number.  There are no qualifying patterns.  So other than having a table of part numbers that I check against, which may or may not be accurate since I only have a few devices, it does not work.  I'm really at a loss here since I have just started working on developing in this platform and the gaps in capability in determining what you would think are the most fundamental capabilities just don't existing.  Not to mention the developer forum from a search perspective is one of the worst I have ever encountered.  It appears I can't even determine the device I am running on, other than by part number and a large table which of course is not possible given the storage constraints, but maybe this is possible and I just am not aware.  

  • I asked somewhat similar questions in the past in the forum. I have not received any useful information. Of course except for datafields, where you have getBackgroundColor().

    I used 2 tactics for the launcher widget (because you see it in the glance). Either I used a "middle gray" color with transparent background or I include a background (a rounded rectangle). So for example either I decide to have a white background and the actual drawing is black, or the other way around (example: https://apps.garmin.com/apps/33cbe5de-5b7c-4d11-9763-063be517e11c ). Or you can try something like this: https://apps.garmin.com/apps/3430778e-6fee-4eb6-b799-21d9d59a41eb where it looks great on white background but it's also OK on black, because there's a black outline. 

  • I know this question is about widgets and glances, but for completeness I will point out that the background of the activity/app list isn't necessarily constant for a given device.

    For example, Forerunner 935's app/activity list uses a white background for the favorites at the top, but a black background for everything else.

    And I think that super old Fenix watches (Fenix 3?) had a "system theme" option which allowed you to choose between black and white backgrounds for most things (I think this applied to system menus, and possibly the top-level view of widgets?)

    So not only is information about background colour not available as a comprehensive list for all devices, it isn't necessarily even constant for some devices.

    I agree it's too bad that this information isn't available at runtime in general.

    What you can probably bet on is that any AMOLED device will have a black background for most or all screens, to conserve battery life and avoid burn-in. For example, MIP devices allow you to select a black or white background for native watchfaces and activity data pages, while AMOLED devices lack the white background option.

  • Thanks for the response.  I had heard using a gray background may be the best all round approach.  It just seems very strange to me that what seems like such an obvious capability it not available.  I guess the focus is on sports activity functionality and not so much on user experience and I'm not developing apps/widgets for sports focused capabilities.  

  • You don't really need to know the current background color on newer devices. You should dive into the SDK info on Styles and Personalities and Personality Library. On the more recent devices (like edge1050) the system colors are defined in styles/personalities and you can refer to them as specified in the style guides and personalities. Edge 1050 colour setting depend on daytime/nighttime, depending on the user's setting. In your app you should do a check on 'nightModeEnabled' (developer.garmin.com/.../DeviceSettings.html and set the appropriate colors, which are defined in Rez.Styles. Glances have their own styles, given in constants like GLANCE_THEME_DEFAULT. There is also a GLANCE_FONT. You still have to code the check on nightMode and set the appropriate colours but these are available in Rez.Styles. Again, take some time to study the docs, and do some experimenting. Sorry for a not-so-structured reply, I just want to give you some cues.

  • You still have the same question for at least about the launcher icon, which is used in different contexts depending on the app type, the device

  • I am not sure I understand your question correctly - first I don't develop for watches only for Edge. On Edge if you set the GLANCE_THEME_XXX by implementing getGlanceTheme() in your AppBase subclass then the system takes care of everything, for day mode as well as for night mode, including the launcher Icon you see in the left of the glance 'window'. What you must do yourself is, in your GlanceView's onUpdate(), check whether the device is in 'night mode' or 'day mode'. Then for drawing your own text, you can use system provided colours as given in Rez.Styles. For Edge 1050 these are found in personality classes system_color_dark__text and system_color_light__text. Both personality classes provide constants .color and .background, which are the foreground and background color respectively. Hope this helps.