Glances and Widgets: User Input?

A user asked for a Watch Widget that takes user input to record particular events throughout the day.

I'm confused since I've never written anything other than data fields, mostly for EDGE devices.

https://developer.garmin.com/connect-iq/core-topics/glances/#glances

1. I understand we can't use the Watch touchscreen to allow users to interact with our CIQ apps, right? We can on EDGE devices.

2. I also read here that we can't even use the buttons, since they are dedicated to device functions. Is that true? FlowState described a sketchy hack that really isn't viable.

So, is there a reasonable way to allow a user to interact with a Widget to submit a selection. Say for example the widget offers 4 choices for the severity of an event. They somehow pick from the 4 and hit select. It records the timestamp and selection. Very basic request. I'm just not sure if we can do that in a CIQ Widget.

The next question is: what can we do with the accumulation of inputs? I'm thinking one or both of these:

  • The widget could show the results. Allowing the user to scroll to an input view -vs- a summary view for the day.
  • Write to a FIT file maybe but I'm not sure widgets have a way to SAVE a FIT file to Garmin Connect?

Top Replies

All Replies

  • Depends on what generation of CIQ you are developing for . Starting with CIQ 3.2 (or maybe 3.1), You can:

    - tap on screen to trigger an input delegate that's the same than for the start/stop button

    - if the input delegate is an menu, it is fully selectable via touch or button

    - You can also have a menu delegate that is also touch enabled.

    Also on the latest CIQ a widget can be run as an app (can't remember when that feature was introduced).

    You can have a look at my insta360 widget https://apps.garmin.com/en-US/apps/bb53f4bb-6c8c-4369-bca9-84cc09b25526

    you don't need an insta360 camera to try out the menus in the widget.

    Messy source code available

  • Oh wow! That is fantastic news! I would love to run the code in my VSC IDE to see how that works. I appreciate the feedback.

  • On older devices without a glance loop, there is the old widget loop.  There, you want to be careful with things like up/down in the main view as those move through the widget loop.  Edge devices and not just watches.

    You may want to start with "Monkey C: New project" and select widget.  On CIQ 4 devices and above, if there is a glance view, they are built as "super apps" and will appear in both the glance loop and under activities. 

    And remember if started from the widget or glance loop, they timeout and close after a minute or two on watches.  You won't see that in the sim.

  • Also on the latest CIQ a widget can be run as an app (can't remember when that feature was introduced).

    To be clear:

    - The feature/behavior is called “super apps” (Garmin doesn’t document this anymore)

    - In CIQ 4, the “widget” app type has actually been removed and its unique functionality merged with device apps.

    - CIQ 4 devices no longer support full-screen widgets (as opposed to glances), unlike some CIQ 3 devices which previously supported both full-screen widgets and glances (the user could change a setting to choose between the two).

    - Any CIQ app with a “widget” app type in manifest actually gets built as a device app, for CIQ 4+ devices

    - What’s actually happening is that any device app can also be launched from the glance list, as long as it has an explicit glance view (i.e. getGlanceView() is implemented). So on the contrary, what’s really happened is that “any app can be run as a widget” (so to speak).

    - If you search the CIQ store mobile app for a CIQ app with a “widget” app type in manifest, when your selected device is CIQ 4+, it will show up as a (device) app (with the A icon). If you search for the same app when your selected device is CIQ < 4, it will show up as a widget, as expected.

    You’ll also see that in CIQ store mobile app, when a CIQ 4+ device is selected, the search page no longer has a widget filter (bc that type of app does not exist anymore). When a CIQ < 4 device is selected, the search page still has the widget filter.

    - One thing to note is all of this actually has a serious consequence for older apps which have the “widget” type in manifest, but no explicit glance view (i.e. getGlanceView() is not implemented). On older CIQ 3 devices which support glances but not super apps, the watch would provide a default glance view consisting of the app name and icon. For one thing, this would’ve allowed really old widgets to be ported from CIQ 2 devices (which didn’t support glances) to CIQ 3 devices with glances without code changes, in some cases. The problem is that CIQ 4 devices *require* getGlanceView() to be implemented if the dev wants a glance view — there’s no way to get the device to provide a default glance view. There’s actually fairly popular widgets in the store in this situation: they’re meant to be used as widgets (e.g. while an activity is running), their dev didn’t provide a glance view, they work fine on CIQ 3 devices, but when the user upgrades to a CIQ 4+ devices, they find that the same “widget” is no longer available in the glance list.

    I don’t think any of this is well understood, especially by the general public. DCR still refers to the GoPro app for new Garmin devices as a “widget”, because it has a glance view. Tbf, calling a device app with a glance view a “widget” is generally harmless.

    TL;DR Garmin actually just got rid of widgets, any existing widget is now a device app (for new devices), and any device app can implement a glance view (via getGlanceView()). As jim_m_58 pointed out, any device app started from the glance loop is subject to the old restrictions of widgets (e.g. it will time out after a certain period of inactivity and it cannot record an activity.)

    There is also an edge case where older widget apps which only had a default glance view on CIQ 3 devices will actually lose their glance view on CIQ 4+ devices (meaning that they turn into regular device apps).

  • (e.g. it will time out after a certain period of inactivity and it cannot record an activity.)

    Note: I said watches.

    On the Edge devices I've used, they don't timeout.  I've never used a Montana, so I'm not sure, but could be like the Edge devices.

  • 1. I understand we can't use the Watch touchscreen to allow users to interact with our CIQ apps, right? We can on EDGE devices.
    2. I also read here that we can't even use the buttons, since they are dedicated to device functions. Is that true? FlowState described a sketchy hack that really isn't viable.

    Incorrect. Some of this isn't applicable to your topic (glances/widgets), but I'm including it for completeness

    - CIQ watchfaces on older watches could not accept user input (excluding on-device settings). Newer devices officially support a long press of the touchscreen (i.e. CIQ 4 devices which support complications)

    - CIQ data fields on older watches could not accept user input (excluding on-device settings). Newer devices (apparently fr955 / fenix 7 and newer) "unofficially" (*) support onTap() for data fields, just like edge (* i.e. it's not documented, but then again, the previous lack of support for onTap was never documented either. Even worse, the new support for onTap is not reflected in the sim, only on real devices.)

    (On-device settings is a CIQ 3+ feature which allows watchfaces and data fields to implement a separate view, typically a menu, to support changing settings on the device, as opposed to in the Connect IQ phone app. For data fields, this view is accessed by holding UP button for the context menu - on five button watches - and navigating to a certain menu item - e.g. "Connect IQ Fields", and selecting the data field from a list. I've found that this view will not update unless user input is received - this fact, along with the number of button presses needed to access the view, means that's it's not really suitable for anything except actual settings.)

    - CIQ device apps support full input, excluding the glance view, when applicable. (See below)

    - CIQ widgets on older devices, as true fullscreen widgets, do not support full user input on the initial view since that is the view which appears in the widget loop (when you press UP and DOWN from the watchface). Because the user has to have the ability to use the buttons to scroll to and from the widget, and to "select"/open the widget, there's no buttons left over to receive user input. Your fullscreen widget's initial view can simply accept the START button / tap as input, at which point it should push a second view (which will be able to accept full input).

    - CIQ widgets as glances on CIQ 3-ish devices, or CIQ device apps with a glance view on CIQ 4+ devices, support full user input on the initial view. This is because the app's glance view is what appears in the glance loop which you navigate by pressing UP and DOWN from the watchface, so it's the glance view which can't accept full input.

    To be clear: All apps which appear the widget/glance loop (accessed by pressing UP or DOWN from the watchface) can accept full user input (buttons and touch), once the user "opens" the app by pressing START (or tapping on the screen)

    - For a full-screen widget, this is accomplished by having the initial mview accept the START button (or tap) as input (this is the only input it's allowed to accept), and pushing a new view when the user presses START (or taps). This new view (and all subsequent views) can accept full input.

    - For a device app with glance, or widget as glance, there's no extra work to do. The glance view won't accept input (other than START/tap which is handled automatically and causes the initial view to be pushed). The initial view can accept full input.

    Keep in mind that different generations of devices have different support for glances and full-screen widgets:

    - CIQ 2 and earlier: full-screen widgets only, app type has to be "widget"

    - CIQ 3-ish: glances or full-screen widgets (user configurable), app type has to be "widget".

    In glance mode, if a widget does not provide a glance view via getGlanceView(), a default glance view will be provided.

    (Some CIQ 3 devices, like 945LTE, may have been updated so they no longer support full-screen widgets)

    - CIQ 4+: glances only. "widget" app type does not exist, all apps with "widget" in the manifest will actually be compiled as device apps.

    If a CIQ 4+ device app explicitly provides a glance view (via getGlanceView()), then it will also be available via the glance list. If a device app does not implement getGlanceView(), no default glance view will be provided, and the app will be unavailable from the glance list.

    [1/x]

  • You will note when you write your "widget", if you need to support full-screen widgets AND glances, you will need to know whether your app supports full input on the initial view or not. The answer depends on whether your app was launched as a glance / from the app/activity-list, or as a full-screen widget:

    - launched as glance / from app/activity list:

    User scrolls to glance view or app in activity/app list => presses start => initial view is automatically pushed and accepts full input

    - launched as full-screen widget:

    User scrolls to initial view => presses start => secondary view is pushed by app and accepts full input

    For an optimal user experience, you may wish to have a different initial view depending on whether your app was launched as a full-screen widget or not. (If you have the same initial view in both cases, then glance users will have to press START twice to "fully open" your app)

    Assuming your app has a type of "widget" in its manifest, you can tell if it was launched as a full-screen widget by checking DeviceSettings.isGlanceModeEnabled. If this field does not exist (you have to do a has check) or it's false, that means your app was launched as a full screen widget and the initial view cannot take input (other than START / tap).

    On the flip side, if isGlanceModeEnabled exists and is true, then your app could've be launched either from the activity/app list, the glance list (assuming it has a glance view), or even from a complication. In most cases there is no need to distinguish between these 3 situations as the initial view can take full input regardless. (It's only on CIQ 4+ devices where an app can be launched from *either* the activity/app list or as a glance.)

    Note: isGlanceModeEnabled will always exist and be true for CIQ 4+ devices.

    If for some reason you do need to tell whether a CIQ 4+ device app was launched from the glance list or the activity/app list, the state dictionary argument to onStart() has a key which will be true if the app was launched from a glance (and not the device list):

    :launchedFromGlance — (Lang.Boolean) —

    If true, indicating the app is started from glance list as opposed to the the app list.

    [2/x]

  • To put that all together:

    https://pastebin.com/ZZLcz2XC

    EDIT: fixed code to account for case when state is null or doesn't support launchedFromGlance

    EDIT: another fix

    [3/3]

  • A simpler version that suits most devs' needs:

    https://pastebin.com/aZqKm7tv

    Obviously 2 vars aren't necessary here as there's a single boolean state - there's 2 vars in the example only for illustrative purposes.

  • Ofc if your app has a type of "watch-app" (device app) in the manifest and/or it's only available on CIQ 4+ devices, then it's not possible for it to launch as a full-screen widget, and the situation is much simpler:

    - As always, the glance view (if available) doesn't support full input, and pressing START at the glance view automatically opens the initial view

    - The initial view supports full input