Help with getDeviceSettings.screenShape if statement

Am I formatting this correct? (because it's not working...)
if (System.getDeviceSettings().screenShape == SCREEN_SHAPE_SEMI_OCTAGON) {...}
I need to change one small section of code to make semi-octagon shaped screens function (not something I can do from resources).
Longer explanation:   I programmatically change the color of my battery status.  Works great on all the color screens.  On the Instinct 2 solar, a black and white semi octagon display, the display matches the background in certain conditions and appears to not display.  I will make the battery display monochromatic for this one watch.
Thanks
  • if (System.getDeviceSettings().screenShape == System.SCREEN_SHAPE_SEMI_OCTAGON) {...}

  • Note that SCREEN_SHAPE_SEMI_OCTAGON was first available with CIQ 3.3, which means you will need some additional code if you intend to:

    - build with optimization disabled

    and

    - support older devices (e.g. fr935, which supports CIQ 3.1.6)

    You can see the issue if you build and run the following code in the simulator for fr935 with optimization disabled:

    if (System.getDeviceSettings().screenShape == System.SCREEN_SHAPE_SEMI_OCTAGON) {
    }

    The app will crash with the following message in the debug console:

    Error: Symbol Not Found Error
    Details: Could not find symbol 'SCREEN_SHAPE_SEMI_OCTAGON'

    The additional code you'd need is a "has check", to ensure that the System module has the SCREEN_SHAPE_SEMI_OCTAGON symbol.

    e.g.

    if (
        System has :SCREEN_SHAPE_SEMI_OCTAGON &&
        System.getDeviceSettings().screenShape == System.SCREEN_SHAPE_SEMI_OCTAGON
    ) {
    }

    Although optimization does avoid this problem (by resolving enum values at compile time instead of run time), it's probably good practice to write this sort of defensive code anyway.

  • Thanks for the info.  That's the kind of error that drives me nuts!

  • Instead of using screen share, with the instinct2/2s/2x and something like a watch face,device app or widget, you can also check for the subscreen as you probably want to do something with it - avoid it, use it for something special, etc

    bb=(WatchUi has :getSubscreen) ? WatchUi.getSubscreen() : null;
    if bb is null, you aren't on a instinct2
    Update: for the crossover, you can use
     hands=(Toybox.WatchUi.View has :setClockHandPosition);
    That's something an app would need to know to use/lock/avoid the hands/  On that device for a watchface, I don't display the time - I just use the HW hands.