in WatchFaceAlphaKotlin/app/src/main/java/com/example/android/wearable/alpha/utils/UserStyleSchemaUtils.kt [41:91]
fun createUserStyleSchema(context: Context): UserStyleSchema {
// 1. Allows user to change the color styles of the watch face (if any are available).
val colorStyleSetting =
UserStyleSetting.ListUserStyleSetting(
UserStyleSetting.Id(COLOR_STYLE_SETTING),
context.resources,
R.string.colors_style_setting,
R.string.colors_style_setting_description,
null,
ColorStyleIdAndResourceIds.toOptionList(context),
listOf(
WatchFaceLayer.BASE,
WatchFaceLayer.COMPLICATIONS,
WatchFaceLayer.COMPLICATIONS_OVERLAY
)
)
// 2. Allows user to toggle on/off the hour pips (dashes around the outer edge of the watch
// face).
val drawHourPipsStyleSetting = UserStyleSetting.BooleanUserStyleSetting(
UserStyleSetting.Id(DRAW_HOUR_PIPS_STYLE_SETTING),
context.resources,
R.string.watchface_pips_setting,
R.string.watchface_pips_setting_description,
null,
listOf(WatchFaceLayer.BASE),
DRAW_HOUR_PIPS_DEFAULT
)
// 3. Allows user to change the length of the minute hand.
val watchHandLengthStyleSetting = UserStyleSetting.DoubleRangeUserStyleSetting(
UserStyleSetting.Id(WATCH_HAND_LENGTH_STYLE_SETTING),
context.resources,
R.string.watchface_hand_length_setting,
R.string.watchface_hand_length_setting_description,
null,
MINUTE_HAND_LENGTH_FRACTION_MINIMUM.toDouble(),
MINUTE_HAND_LENGTH_FRACTION_MAXIMUM.toDouble(),
listOf(WatchFaceLayer.COMPLICATIONS_OVERLAY),
MINUTE_HAND_LENGTH_FRACTION_DEFAULT.toDouble()
)
// 4. Create style settings to hold all options.
return UserStyleSchema(
listOf(
colorStyleSetting,
drawHourPipsStyleSetting,
watchHandLengthStyleSetting
)
)
}