Drawing complications separately using WatchFaceKotlin Wear OS sample

Viewed 110

First off, I am using the Google Wear OS sample called WatchFaceKotlin.

The sample provided draws all of the complications at once. I have added a background complication so that users can customize the background with perhaps a weather image or something more personal. Problem is that the background complication is drawn so bright that the complications in front of the image can no longer be seen. I want to use drawARGB() in front of the background complication and let the user decide on the background brightness with a slider in the settings. I cant seem to find a place to do this since all complications are drawn at once and adding the drawARGB() after that darkens all complications. Is there a way to split the complications using the new API's so that I can draw the background, then the drawARGB(), and then the smaller complications? Here is where I am thinking that something could possibly be done but there is something that I am missing since this way does not work correctly

In the AnalogWatchCanvasRenderer.kt

    // ----- All drawing functions -----
private fun drawComplications(canvas: Canvas, zonedDateTime: ZonedDateTime) {
    for ((_, complication) in complicationSlotsManager.complicationSlots) {
        if (complication.enabled) {
            complication.render(canvas, zonedDateTime, renderParameters)
            canvas.drawARGB(watchFaceData.brightnessFractionDefault.brightnessFraction.toInt(),0,0,0)
        }
    }
}

There must be a way to only draw a specific complication instead of using complication.render and drawing them all at once. Any thoughts? Thanks for any attempt to help.

1 Answers

You can add a condition when calling render, where you check the id or the type of the slot, and draw a darkening color just after drawing the slot.

Related