Wear OS Watch Face, Part 3: Watch Face Complications
This part of the series was the most difficult for me. The concepts behind complications are incredibly tied to the Android ecosystem, and specifically the Wear OS framework. I have done my best at all times to separate the rendering elements from the watch specific components.
A Watch Face complication, as mentioned in Part 2, is a horological term that refers to a part of a watch face that is not concerned with hours, minutes and seconds. These elements are more complex in the information age, because they could be anything. This last article is not concerned with the data that is provided to the complication, but rather the element that uses existing complication data providers to render information on the watch face.
The ComplicationDataSource.kt
class associates the data that should be rendered with the element that is drawn on the screen. Data to be rendered is collected by the ComplicatedWatchFaceService.kt
and updates the rendering element. However the positioning of the elements on the screen are handled separately by the implementation of the ComplicationsRenderer
, the example can be found in ExampleWatchComplicationRenderer.kt
:
The advantage of separation of rendering from specific data proves vital for the harness
so that a dummy data source (DrawableComplicationDataSource.kt
) can be provided in order to render the complications on the WatchFaceView.kt
. Once again, this abstraction in the Wear OS Watch Face itself means that the ComplicatedWatchFaceService.kt
only concerns itself with the specific lifecycle attributed with complications.
I strongly recommend going through Google’s CodeLab on Wear OS watch face complications and start making watch faces. It’s also advisable to go through the activity code to see the manner in which a user can select which complication gets rendered on the screen.
Comments
No comments found for this article.
Join the discussion for this article on github. Comments appear on this page instantly.