ComplicationTapFilter


Note: As of July 10, 2024, watch faces must use the Watch Face Format in order to be installed on new watches that launch with Wear OS 5 pre-installed. Learn more about the user-facing changes in this Help Center article.

Additionally, starting in early 2025 (specific date to be announced during Q4 2024), all new watch faces published on Google Play must use the Watch Face Format.

interface ComplicationTapFilter


Interface for determining whether a tap hits a complication.

Summary

Public functions

open Boolean
hitTest(
    complicationSlot: ComplicationSlot,
    screenBounds: Rect,
    x: @Px Int,
    y: @Px Int
)

This function is deprecated. hitTest without specifying includeMargins is deprecated

open Boolean
hitTest(
    complicationSlot: ComplicationSlot,
    screenBounds: Rect,
    x: @Px Int,
    y: @Px Int,
    includeMargins: Boolean
)

Performs a hit test, returning true if the supplied coordinates in pixels are within the the provided complicationSlot scaled to screenBounds.

Public functions

hitTest

Added in 1.0.0
Deprecated in 1.2.0
open fun hitTest(
    complicationSlot: ComplicationSlot,
    screenBounds: Rect,
    x: @Px Int,
    y: @Px Int
): Boolean

Performs a hit test, returning true if the supplied coordinates in pixels are within the the provided complicationSlot scaled to screenBounds.

Parameters
complicationSlot: ComplicationSlot

The ComplicationSlot to perform a hit test for.

screenBounds: Rect

A Rect describing the bounds of the display.

x: @Px Int

The screen space X coordinate in pixels.

y: @Px Int

The screen space Y coordinate in pixels.

hitTest

Added in 1.2.0
open fun hitTest(
    complicationSlot: ComplicationSlot,
    screenBounds: Rect,
    x: @Px Int,
    y: @Px Int,
    includeMargins: Boolean
): Boolean

Performs a hit test, returning true if the supplied coordinates in pixels are within the the provided complicationSlot scaled to screenBounds.

Parameters
complicationSlot: ComplicationSlot

The ComplicationSlot to perform a hit test for.

screenBounds: Rect

A Rect describing the bounds of the display.

x: @Px Int

The screen space X coordinate in pixels.

y: @Px Int

The screen space Y coordinate in pixels.

includeMargins: Boolean

Whether or not the margins should be included