1

I am learning android development and trying to develop a simple android watchface with kotlin. For now I am stucked with complications. I found a way how to make it work with default system data like how to show a step counter or a current date:

val leftComplication = ComplicationSlot.createRoundRectComplicationSlotBuilder( 
    id = ComplicationConfig.Left.id,
    canvasComplicationFactory = defaultCanvasComplicationFactory,
    supportedTypes = ComplicationConfig.Left.supportedTypes,
    defaultDataSourcePolicy = DefaultComplicationDataSourcePolicy( SystemDataSources.DATA_SOURCE_DAY_OF_WEEK ),
    bounds = ComplicationSlotBounds( RectF(
ComplicationBounds.LEFT_COMPLICATION_BOUNDS.left,
ComplicationBounds.LEFT_COMPLICATION_BOUNDS.top,
ComplicationBounds.LEFT_COMPLICATION_BOUNDS.right,
ComplicationBounds.LEFT_COMPLICATION_BOUNDS.bottom 
        ) 
    ) ).setDefaultDataSourceType(ComplicationType.SHORT_TEXT) 
    .build()

(Full source code is available by https://github.com/SI7-Agent/AndroidXComplicatedDigitalNeon)

So that is working but it is returning a complication with somewhere generated complicationData. So the question is: Can I use this complication data generated with system data and modify it according to my preferences: for example, change icon if it's supported and don't modify other data?

I know about creating a custom Broadcast receiver and ComplicationDataSourceService. But in this case I must to provide all of the data I need to show including sensors' value if I want to use step counter, for example.

I appreciate any help. Thanks

  • I presume you could change the complication renderer https://developer.android.com/reference/androidx/wear/watchface/CanvasComplicationFactory, but I haven't tried. There are examples in github for watchfaces to have custom complication renderers. https://github.com/muzei/muzei/blob/4fd69752e5221bee81d59fe1d9ddf217bbf686ef/example-watchface/src/main/java/com/example/muzei/watchface/MuzeiExampleWatchface.kt Let me know if this solves your problem. – Yuri Schimke Feb 21 '22 at 09:01
  • Thank you for comment. I haven't seen exactly this repo. It's very valuable. But CanvasComplicationFactory doesn't define what data will be drawn but how it will be. In other words, this class helps to make a style (background image/color, text size/color and so on) – Kirill Rudnev Feb 21 '22 at 16:13

0 Answers0