Introduce wear-tooling-preview library
... to list valid wear devices that can be used for UI previews.
Bug: 227474520
Relnote: Introduce wear-tooling-preview library to list valid wear devices that can be used for UI previews
Test: N/A
Change-Id: Ib036edb1823884c5f9e312d6733e7c3db22f9a0a
diff --git a/compose/ui/ui-tooling-preview/api/current.txt b/compose/ui/ui-tooling-preview/api/current.txt
index 80f655a..80d0e53 100644
--- a/compose/ui/ui-tooling-preview/api/current.txt
+++ b/compose/ui/ui-tooling-preview/api/current.txt
@@ -30,10 +30,10 @@
field public static final String TABLET = "spec:id=reference_tablet,shape=Normal,width=1280,height=800,unit=dp,dpi=240";
field public static final String TV_1080p = "spec:shape=Normal,width=1920,height=1080,unit=dp,dpi=420";
field public static final String TV_720p = "spec:shape=Normal,width=1280,height=720,unit=dp,dpi=420";
- field public static final String WEAR_OS_LARGE_ROUND = "id:wearos_large_round";
- field public static final String WEAR_OS_RECT = "id:wearos_rect";
- field public static final String WEAR_OS_SMALL_ROUND = "id:wearos_small_round";
- field public static final String WEAR_OS_SQUARE = "id:wearos_square";
+ field @Deprecated public static final String WEAR_OS_LARGE_ROUND = "id:wearos_large_round";
+ field @Deprecated public static final String WEAR_OS_RECT = "id:wearos_rect";
+ field @Deprecated public static final String WEAR_OS_SMALL_ROUND = "id:wearos_small_round";
+ field @Deprecated public static final String WEAR_OS_SQUARE = "id:wearos_square";
}
@kotlin.annotation.MustBeDocumented @kotlin.annotation.Repeatable @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.ANNOTATION_CLASS, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Preview {
diff --git a/compose/ui/ui-tooling-preview/api/restricted_current.txt b/compose/ui/ui-tooling-preview/api/restricted_current.txt
index 80f655a..80d0e53 100644
--- a/compose/ui/ui-tooling-preview/api/restricted_current.txt
+++ b/compose/ui/ui-tooling-preview/api/restricted_current.txt
@@ -30,10 +30,10 @@
field public static final String TABLET = "spec:id=reference_tablet,shape=Normal,width=1280,height=800,unit=dp,dpi=240";
field public static final String TV_1080p = "spec:shape=Normal,width=1920,height=1080,unit=dp,dpi=420";
field public static final String TV_720p = "spec:shape=Normal,width=1280,height=720,unit=dp,dpi=420";
- field public static final String WEAR_OS_LARGE_ROUND = "id:wearos_large_round";
- field public static final String WEAR_OS_RECT = "id:wearos_rect";
- field public static final String WEAR_OS_SMALL_ROUND = "id:wearos_small_round";
- field public static final String WEAR_OS_SQUARE = "id:wearos_square";
+ field @Deprecated public static final String WEAR_OS_LARGE_ROUND = "id:wearos_large_round";
+ field @Deprecated public static final String WEAR_OS_RECT = "id:wearos_rect";
+ field @Deprecated public static final String WEAR_OS_SMALL_ROUND = "id:wearos_small_round";
+ field @Deprecated public static final String WEAR_OS_SQUARE = "id:wearos_square";
}
@kotlin.annotation.MustBeDocumented @kotlin.annotation.Repeatable @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.ANNOTATION_CLASS, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Preview {
diff --git a/compose/ui/ui-tooling-preview/src/androidMain/kotlin/androidx/compose/ui/tooling/preview/Device.kt b/compose/ui/ui-tooling-preview/src/androidMain/kotlin/androidx/compose/ui/tooling/preview/Device.kt
index 57fa29b..3ac0473 100644
--- a/compose/ui/ui-tooling-preview/src/androidMain/kotlin/androidx/compose/ui/tooling/preview/Device.kt
+++ b/compose/ui/ui-tooling-preview/src/androidMain/kotlin/androidx/compose/ui/tooling/preview/Device.kt
@@ -46,9 +46,17 @@
const val AUTOMOTIVE_1024p = "id:automotive_1024p_landscape"
+ @Deprecated("Use [androidx.wear.tooling.preview.devices.WearDevices.LARGE_ROUND] from the " +
+ "wear:wear-tooling-preview library instead")
const val WEAR_OS_LARGE_ROUND = "id:wearos_large_round"
+ @Deprecated("Use [androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND] from the " +
+ "wear:wear-tooling-preview library instead")
const val WEAR_OS_SMALL_ROUND = "id:wearos_small_round"
+ @Deprecated("Use [androidx.wear.tooling.preview.devices.WearDevices.SQUARE] from the " +
+ "wear:wear-tooling-preview library instead")
const val WEAR_OS_SQUARE = "id:wearos_square"
+ @Deprecated("Use [androidx.wear.tooling.preview.devices.WearDevices.RECT] from the " +
+ "wear:wear-tooling-preview library instead")
const val WEAR_OS_RECT = "id:wearos_rect"
// Reference devices
@@ -69,6 +77,7 @@
* @suppress
*/
@Retention(AnnotationRetention.SOURCE)
+@Suppress("DEPRECATION")
@StringDef(
open = true,
value = [
diff --git a/libraryversions.toml b/libraryversions.toml
index d23b8fe..3e427ce 100644
--- a/libraryversions.toml
+++ b/libraryversions.toml
@@ -153,6 +153,7 @@
WEAR_PHONE_INTERACTIONS = "1.1.0-alpha04"
WEAR_PROTOLAYOUT = "1.1.0-alpha01"
WEAR_REMOTE_INTERACTIONS = "1.1.0-alpha01"
+WEAR_TOOLING_PREVIEW = "1.0.0-alpha01"
WEAR_TILES = "1.3.0-alpha01"
WEAR_WATCHFACE = "1.2.0-beta01"
WEBKIT = "1.9.0-alpha01"
diff --git a/settings.gradle b/settings.gradle
index 60be383..5056b69 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1066,6 +1066,7 @@
includeProject(":wear:wear-phone-interactions", [BuildType.MAIN, BuildType.WEAR])
includeProject(":wear:wear-remote-interactions", [BuildType.MAIN, BuildType.WEAR])
includeProject(":wear:wear-samples-ambient", [BuildType.MAIN, BuildType.WEAR])
+includeProject(":wear:wear-tooling-preview", [BuildType.MAIN, BuildType.WEAR])
includeProject(":wear:tiles:tiles", [BuildType.MAIN, BuildType.WEAR])
includeProject(":wear:tiles:tiles-material", [BuildType.MAIN, BuildType.WEAR])
includeProject(":wear:tiles:tiles-proto", [BuildType.MAIN, BuildType.WEAR])
diff --git a/wear/compose/compose-ui-tooling/api/current.txt b/wear/compose/compose-ui-tooling/api/current.txt
index 00f94c1..f725a3b 100644
--- a/wear/compose/compose-ui-tooling/api/current.txt
+++ b/wear/compose/compose-ui-tooling/api/current.txt
@@ -1,19 +1,19 @@
// Signature format: 4.0
package androidx.wear.compose.ui.tooling.preview {
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewDevices {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewDevices {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Small", fontScale=0.94f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Normal", fontScale=1.0f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Medium", fontScale=1.06f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Large", fontScale=1.12f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Larger", fontScale=1.18f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Largest", fontScale=1.24f) public @interface WearPreviewFontScales {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Small", fontScale=0.94f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Normal", fontScale=1.0f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Medium", fontScale=1.06f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Large", fontScale=1.12f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Larger", fontScale=1.18f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Largest", fontScale=1.24f) public @interface WearPreviewFontScales {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) public @interface WearPreviewLargeRound {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) public @interface WearPreviewLargeRound {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewSmallRound {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewSmallRound {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) public @interface WearPreviewSquare {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) public @interface WearPreviewSquare {
}
}
diff --git a/wear/compose/compose-ui-tooling/api/restricted_current.txt b/wear/compose/compose-ui-tooling/api/restricted_current.txt
index 00f94c1..f725a3b 100644
--- a/wear/compose/compose-ui-tooling/api/restricted_current.txt
+++ b/wear/compose/compose-ui-tooling/api/restricted_current.txt
@@ -1,19 +1,19 @@
// Signature format: 4.0
package androidx.wear.compose.ui.tooling.preview {
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewDevices {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewDevices {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Small", fontScale=0.94f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Normal", fontScale=1.0f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Medium", fontScale=1.06f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Large", fontScale=1.12f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Larger", fontScale=1.18f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Largest", fontScale=1.24f) public @interface WearPreviewFontScales {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Small", fontScale=0.94f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Normal", fontScale=1.0f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Medium", fontScale=1.06f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Large", fontScale=1.12f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Larger", fontScale=1.18f) @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, showSystemUi=true, backgroundColor=4278190080L, showBackground=true, group="Fonts - Largest", fontScale=1.24f) public @interface WearPreviewFontScales {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) public @interface WearPreviewLargeRound {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.LARGE_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Large Round", showSystemUi=true) public @interface WearPreviewLargeRound {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewSmallRound {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SMALL_ROUND, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Round", showSystemUi=true) public @interface WearPreviewSmallRound {
}
- @androidx.compose.ui.tooling.preview.Preview(device=androidx.compose.ui.tooling.preview.Devices.WEAR_OS_SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) public @interface WearPreviewSquare {
+ @androidx.compose.ui.tooling.preview.Preview(device=androidx.wear.tooling.preview.devices.WearDevices.SQUARE, backgroundColor=4278190080L, showBackground=true, group="Devices - Small Square", showSystemUi=true) public @interface WearPreviewSquare {
}
}
diff --git a/wear/compose/compose-ui-tooling/build.gradle b/wear/compose/compose-ui-tooling/build.gradle
index a88ea8d..12128d7 100644
--- a/wear/compose/compose-ui-tooling/build.gradle
+++ b/wear/compose/compose-ui-tooling/build.gradle
@@ -28,6 +28,7 @@
implementation(libs.kotlinStdlibCommon)
implementation(project(":compose:ui:ui-tooling-preview"))
+ implementation(project(":wear:wear-tooling-preview"))
samples(project(":wear:compose:compose-material-samples"))
}
diff --git a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewDevices.kt b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewDevices.kt
index 5ff9952..762ee43 100644
--- a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewDevices.kt
+++ b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewDevices.kt
@@ -16,35 +16,35 @@
package androidx.wear.compose.ui.tooling.preview
-import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
+import androidx.wear.tooling.preview.devices.WearDevices
/**
* [WearPreviewDevices] is a multi-preview annotation for composables with different Wear device
- * shapes and sizes. It supports [Devices.WEAR_OS_SMALL_ROUND], [Devices.WEAR_OS_LARGE_ROUND] and
- * [Devices.WEAR_OS_SQUARE].
+ * shapes and sizes. It supports [WearDevices.SMALL_ROUND], [WearDevices.LARGE_ROUND] and
+ * [WearDevices.SQUARE].
*
* @sample androidx.wear.compose.material.samples.ToggleButtonWithIconPreview
- * @see Devices.WEAR_OS_SMALL_ROUND
- * @see Devices.WEAR_OS_LARGE_ROUND
- * @see Devices.WEAR_OS_SQUARE
+ * @see WearDevices.SMALL_ROUND
+ * @see WearDevices.LARGE_ROUND
+ * @see WearDevices.SQUARE
*/
@Preview(
- device = Devices.WEAR_OS_SQUARE,
+ device = WearDevices.SQUARE,
backgroundColor = 0xff000000,
showBackground = true,
group = "Devices - Small Square",
showSystemUi = true
)
@Preview(
- device = Devices.WEAR_OS_LARGE_ROUND,
+ device = WearDevices.LARGE_ROUND,
backgroundColor = 0xff000000,
showBackground = true,
group = "Devices - Large Round",
showSystemUi = true
)
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
backgroundColor = 0xff000000,
showBackground = true,
group = "Devices - Small Round",
diff --git a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewFontScales.kt b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewFontScales.kt
index 4df6b45..7981cf2 100644
--- a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewFontScales.kt
+++ b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewFontScales.kt
@@ -16,8 +16,8 @@
package androidx.wear.compose.ui.tooling.preview
-import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
+import androidx.wear.tooling.preview.devices.WearDevices
/**
* [WearPreviewFontScales] is a multi-preview annotation for the Wear devices of following font
@@ -37,7 +37,7 @@
* @see [Preview.fontScale]
*/
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true,
@@ -45,7 +45,7 @@
fontScale = 0.94f
)
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true,
@@ -53,7 +53,7 @@
fontScale = 1f
)
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true,
@@ -61,7 +61,7 @@
fontScale = 1.06f
)
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true,
@@ -69,7 +69,7 @@
fontScale = 1.12f
)
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true,
@@ -77,7 +77,7 @@
fontScale = 1.18f
)
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true,
diff --git a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewLargeRound.kt b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewLargeRound.kt
index b2d8367..2718138 100644
--- a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewLargeRound.kt
+++ b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewLargeRound.kt
@@ -16,18 +16,18 @@
package androidx.wear.compose.ui.tooling.preview
-import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
+import androidx.wear.tooling.preview.devices.WearDevices
/**
* [WearPreviewLargeRound] is a custom preview annotation for displaying Wear composables on large
- * round Wear device ([Devices.WEAR_OS_LARGE_ROUND]).
+ * round Wear device ([WearDevices.LARGE_ROUND]).
*
* @sample androidx.wear.compose.material.samples.ButtonWithIconPreview
- * @see [Devices.WEAR_OS_LARGE_ROUND]
+ * @see [WearDevices.LARGE_ROUND]
*/
@Preview(
- device = Devices.WEAR_OS_LARGE_ROUND,
+ device = WearDevices.LARGE_ROUND,
backgroundColor = 0xff000000,
showBackground = true,
group = "Devices - Large Round",
diff --git a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSmallRound.kt b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSmallRound.kt
index 70dcc79..a390175 100644
--- a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSmallRound.kt
+++ b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSmallRound.kt
@@ -16,18 +16,18 @@
package androidx.wear.compose.ui.tooling.preview
-import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
+import androidx.wear.tooling.preview.devices.WearDevices
/**
* [WearPreviewSmallRound] is a custom preview annotation for displaying Wear composables on small
- * round Wear device ([Devices.WEAR_OS_SMALL_ROUND]).
+ * round Wear device ([WearDevices.SMALL_ROUND]).
*
* @sample androidx.wear.compose.material.samples.ButtonWithIconPreview
- * @see [Devices.WEAR_OS_SMALL_ROUND]
+ * @see [WearDevices.SMALL_ROUND]
*/
@Preview(
- device = Devices.WEAR_OS_SMALL_ROUND,
+ device = WearDevices.SMALL_ROUND,
backgroundColor = 0xff000000,
showBackground = true,
group = "Devices - Small Round",
diff --git a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSquare.kt b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSquare.kt
index 4c41bd1..1e96371 100644
--- a/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSquare.kt
+++ b/wear/compose/compose-ui-tooling/src/main/java/androidx/wear/compose/ui/tooling/preview/WearPreviewSquare.kt
@@ -16,18 +16,18 @@
package androidx.wear.compose.ui.tooling.preview
-import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
+import androidx.wear.tooling.preview.devices.WearDevices
/**
* [WearPreviewSquare] is a custom preview annotation for displaying Wear composables on a square
- * Wear screen ([Devices.WEAR_OS_SQUARE]).
+ * Wear screen ([WearDevices.SQUARE]).
*
* @sample androidx.wear.compose.material.samples.ButtonWithIconPreview
- * @see [Devices.WEAR_OS_SQUARE]
+ * @see [WearDevices.SQUARE]
*/
@Preview(
- device = Devices.WEAR_OS_SQUARE,
+ device = WearDevices.SQUARE,
backgroundColor = 0xff000000,
showBackground = true,
group = "Devices - Small Square",
diff --git a/wear/wear-tooling-preview/api/current.txt b/wear/wear-tooling-preview/api/current.txt
new file mode 100644
index 0000000..49964db
--- /dev/null
+++ b/wear/wear-tooling-preview/api/current.txt
@@ -0,0 +1,13 @@
+// Signature format: 4.0
+package androidx.wear.tooling.preview.devices {
+
+ public final class WearDevices {
+ field public static final androidx.wear.tooling.preview.devices.WearDevices INSTANCE;
+ field public static final String LARGE_ROUND = "id:wearos_large_round";
+ field public static final String RECT = "id:wearos_rect";
+ field public static final String SMALL_ROUND = "id:wearos_small_round";
+ field public static final String SQUARE = "id:wearos_square";
+ }
+
+}
+
diff --git a/wear/wear-tooling-preview/api/res-current.txt b/wear/wear-tooling-preview/api/res-current.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wear/wear-tooling-preview/api/res-current.txt
diff --git a/wear/wear-tooling-preview/api/restricted_current.txt b/wear/wear-tooling-preview/api/restricted_current.txt
new file mode 100644
index 0000000..49964db
--- /dev/null
+++ b/wear/wear-tooling-preview/api/restricted_current.txt
@@ -0,0 +1,13 @@
+// Signature format: 4.0
+package androidx.wear.tooling.preview.devices {
+
+ public final class WearDevices {
+ field public static final androidx.wear.tooling.preview.devices.WearDevices INSTANCE;
+ field public static final String LARGE_ROUND = "id:wearos_large_round";
+ field public static final String RECT = "id:wearos_rect";
+ field public static final String SMALL_ROUND = "id:wearos_small_round";
+ field public static final String SQUARE = "id:wearos_square";
+ }
+
+}
+
diff --git a/wear/wear-tooling-preview/build.gradle b/wear/wear-tooling-preview/build.gradle
new file mode 100644
index 0000000..462b567
--- /dev/null
+++ b/wear/wear-tooling-preview/build.gradle
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import androidx.build.Publish
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("kotlin-android")
+}
+
+dependencies {
+ api("androidx.annotation:annotation:1.6.0")
+ api(libs.kotlinStdlib)
+}
+
+android {
+ defaultConfig {
+ minSdkVersion 21
+ }
+ namespace "androidx.wear.tooling.preview"
+}
+
+androidx {
+ name = "Android Wear Preview Tools"
+ inceptionYear = "2023"
+ description = "Tools for Wear UI Previews"
+ publish = Publish.SNAPSHOT_AND_RELEASE
+ mavenVersion = LibraryVersions.WEAR_TOOLING_PREVIEW
+}
diff --git a/wear/wear-tooling-preview/src/main/java/androidx/wear/tooling/preview/devices/WearDevice.kt b/wear/wear-tooling-preview/src/main/java/androidx/wear/tooling/preview/devices/WearDevice.kt
new file mode 100644
index 0000000..8d77838
--- /dev/null
+++ b/wear/wear-tooling-preview/src/main/java/androidx/wear/tooling/preview/devices/WearDevice.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.wear.tooling.preview.devices
+
+import androidx.annotation.RestrictTo
+import androidx.annotation.StringDef
+
+/**
+ * List with the pre-defined devices available to be used in previews.
+ */
+object WearDevices {
+ // Make sure to update any @StringDefs that reference this object.
+ /** Round device with 454px x 454px dimensions, 1.39" size and xhdpi density. */
+ const val LARGE_ROUND = "id:wearos_large_round"
+ /** Round device with 384px x 384px dimensions, 1.2" size and xhdpi density. */
+ const val SMALL_ROUND = "id:wearos_small_round"
+ /** Square device with 360px x 360px dimensions, 1.2" size and xhdpi density. */
+ const val SQUARE = "id:wearos_square"
+ /** Rectangular device with 402px x 476px dimensions, 1.2" size and xhdpi density. */
+ const val RECT = "id:wearos_rect"
+}
+
+/**
+ * Annotation for defining the device to use.
+ */
+@Retention(AnnotationRetention.SOURCE)
+@StringDef(
+ open = true,
+ value = [
+ WearDevices.LARGE_ROUND,
+ WearDevices.SMALL_ROUND,
+ ]
+)
+@RestrictTo(RestrictTo.Scope.LIBRARY)
+annotation class WearDevice