Flavor

A Flavor specifies a set of configuration values, grouped as a preset. Typically, the user can choose from these Flavors in the companion app.

A Flavor can include values for existing configurations, including the following types:

  • BooleanConfiguration
  • ColorConfiguration
  • ListConfiguration
  • ComplicationSlot

Since version 2

Syntax

<Flavor id="string" displayName="string" icon="string"
    screenReaderText="string" defaultValue="">
    <!-- Flavor-specific child elements. -->
    <Configuration ... />
    <ComplicationSlot .../>
<Flavor/>>

You can include Flavor elements within a UserConfigurations element, as shown in the following example:

<UserConfigurations>
  <!-- Configuration definitions go here -->
  <ColorConfiguration id="themeColor" ... />
  <!-- ... -->

  <Flavors>
    <Flavor id="1" displayName="1st flavor" icon="flavor_1_preview" defaultValue="">
        <Configuration id="themeColor" optionId="0"/>
        <ComplicationSlot slotId="0">
            <DefaultProviderPolicy
                defaultSystemProvider="DAY_OF_WEEK"
                defaultSystemProviderType="SHORT_TEXT"/>
        </ComplicationSlot>
    </Flavor>

    <Flavor id="2" displayName="2nd flavor" icon="flavor_2_preview" defaultValue="">
        <Configuration id="themeColor" optionId="1"/>
        <ComplicationSlot slotId="0">
            <DefaultProviderPolicy
                defaultSystemProvider="WATCH_BATTERY"
                defaultSystemProviderType="SHORT_TEXT"/>
        </ComplicationSlot>
    </Flavor>
  </Flavors>
</UserConfigurations>

In order to use Flavors, the following must be added to res/xml/watch_face_info.xml:

<?xml version="1.0" encoding="utf-8"?>
<WatchFaceInfo>
    ...
    <MultipleInstancesAllowed value="true" />
    <FlavorsSupported value="true" />
</WatchFaceInfo>

Attributes

The Flavor element has the following attributes:

Required attributes

The following attributes are required:

id
A unique identifier for the Flavor.
displayName
A resource ID corresponding to the text that is displayed in the companion.
defaultValue
This attribute is not used, and should be set as empty.

Optional attributes

The following attributes are optional:

icon
A resource ID corresponding to the drawable resource which is shown in the companion. This should have a maximum size of 360x360 px.
screenReaderText
A resource ID corresponding to the text which is used if the user has TalkBack enabled.

Inner elements

The Flavor element must contain at least one Configuration element and can optionally include ComplicationSlot elements.

  • The Configuration element references previously defined configuration elements, such as BooleanConfiguration, using the id attribute. The Configuration elements sets the chosen value for this configuration option using the optionId attribute.

  • The ComplicationSlot element can be used to specify the DefaultProviderPolicy for a given Flavor.