Skip to content

Commit de5ab50

Browse files
committed
Migrate to snapshot 13623196 (alpha05)
1 parent 7f4c676 commit de5ab50

24 files changed

+111
-53
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ playServicesWearable = "19.0.0"
6363
protolayout = "1.3.0-beta02"
6464
recyclerview = "1.4.0"
6565
# @keep
66-
androidx-xr-arcore = "1.0.0-alpha04"
67-
androidx-xr-scenecore = "1.0.0-alpha04"
68-
androidx-xr-compose = "1.0.0-alpha04"
66+
androidx-xr-arcore = "1.0.0-SNAPSHOT"
67+
androidx-xr-scenecore = "1.0.0-SNAPSHOT"
68+
androidx-xr-compose = "1.0.0-SNAPSHOT"
6969
targetSdk = "34"
7070
tiles = "1.5.0-beta01"
7171
version-catalog-update = "1.0.0"

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val snapshotVersion : String? = System.getenv("COMPOSE_SNAPSHOT_ID")
1+
val snapshotVersion : String? = "13623196"
22

33
pluginManagement {
44
repositories {

xr/build.gradle.kts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ android {
2828
}
2929

3030
dependencies {
31-
implementation(libs.androidx.xr.arcore)
32-
implementation(libs.androidx.xr.scenecore)
33-
implementation(libs.androidx.xr.compose)
31+
implementation(libs.androidx.xr.arcore) {
32+
exclude(module = "impress")
33+
}
34+
implementation(libs.androidx.xr.scenecore) {
35+
exclude(module = "impress")
36+
}
37+
implementation(libs.androidx.xr.compose) {
38+
exclude(module = "impress")
39+
}
40+
41+
implementation("com.google.ar:impress:0.0.3")
3442

3543
implementation(libs.androidx.activity.ktx)
3644
implementation(libs.guava)

xr/src/main/java/com/example/xr/arcore/Anchors.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ import androidx.xr.scenecore.AnchorEntity
2929
import androidx.xr.scenecore.Entity
3030
import androidx.xr.scenecore.scene
3131

32-
@Suppress("RestrictedApi") // b/416288516 - session.config and session.configure() are incorrectly restricted
3332
fun configureAnchoring(session: Session) {
3433
// [START androidxr_arcore_anchoring_configure]
3534
val newConfig = session.config.copy(
36-
anchorPersistence = Config.AnchorPersistenceMode.Enabled,
35+
anchorPersistence = Config.AnchorPersistenceMode.LOCAL,
3736
)
3837
when (val result = session.configure(newConfig)) {
3938
is SessionConfigureConfigurationNotSupported ->
4039
TODO(/* Some combinations of configurations are not valid. Handle this failure case. */)
4140
is SessionConfigurePermissionsNotGranted ->
4241
TODO(/* The required permissions in result.permissions have not been granted. */)
4342
is SessionConfigureSuccess -> TODO(/* Success! */)
43+
else ->
44+
TODO(/* A different unhandled exception was thrown. */)
4445
}
4546
// [END androidxr_arcore_anchoring_configure]
4647
}
@@ -65,14 +66,15 @@ private fun createAnchorAtTrackable(trackable: Trackable<*>) {
6566
// [END androidxr_arcore_anchor_create_trackable]
6667
}
6768

69+
@Suppress("RestrictedApi") // b/422174724
6870
private fun attachEntityToAnchor(
6971
session: Session,
7072
entity: Entity,
7173
anchor: Anchor
7274
) {
7375
// [START androidxr_arcore_entity_tracks_anchor]
7476
AnchorEntity.create(session, anchor).apply {
75-
setParent(session.scene.activitySpace)
77+
parent = session.scene.activitySpace
7678
addChild(entity)
7779
}
7880
// [END androidxr_arcore_entity_tracks_anchor]

xr/src/main/java/com/example/xr/arcore/Hands.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ import androidx.xr.scenecore.scene
3535
import kotlinx.coroutines.flow.Flow
3636
import kotlinx.coroutines.launch
3737

38-
@Suppress("RestrictedApi") // b/416288516 - session.config and session.configure() are incorrectly restricted
3938
fun ComponentActivity.configureSession(session: Session) {
4039
// [START androidxr_arcore_hand_configure]
4140
val newConfig = session.config.copy(
42-
handTracking = Config.HandTrackingMode.Enabled
41+
handTracking = Config.HandTrackingMode.BOTH
4342
)
4443
when (val result = session.configure(newConfig)) {
4544
is SessionConfigureConfigurationNotSupported ->
4645
TODO(/* Some combinations of configurations are not valid. Handle this failure case. */)
4746
is SessionConfigurePermissionsNotGranted ->
4847
TODO(/* The required permissions in result.permissions have not been granted. */)
4948
is SessionConfigureSuccess -> TODO(/* Success! */)
49+
else ->
50+
TODO(/* A different unhandled exception was thrown. */)
5051
}
5152
// [END androidxr_arcore_hand_configure]
5253
}
@@ -71,13 +72,14 @@ fun ComponentActivity.collectHands(session: Session) {
7172
fun secondaryHandDetection(activity: Activity, session: Session) {
7273
fun detectGesture(handState: Flow<Hand.State>) {}
7374
// [START androidxr_arcore_hand_handedness]
74-
val handedness = Hand.getHandedness(activity.contentResolver)
75-
val secondaryHand = if (handedness == Hand.Handedness.LEFT) Hand.right(session) else Hand.left(session)
75+
val handedness = Hand.getPrimaryHandSide(activity.contentResolver)
76+
val secondaryHand = if (handedness == Hand.HandSide.LEFT) Hand.right(session) else Hand.left(session)
7677
val handState = secondaryHand?.state ?: return
7778
detectGesture(handState)
7879
// [END androidxr_arcore_hand_handedness]
7980
}
8081

82+
@Suppress("RestrictedApi") // b/416066566
8183
fun ComponentActivity.renderPlanetAtHandPalm(leftHandState: Hand.State) {
8284
val session: Session = null!!
8385
val palmEntity: GltfModelEntity = null!!
@@ -86,7 +88,7 @@ fun ComponentActivity.renderPlanetAtHandPalm(leftHandState: Hand.State) {
8688

8789
// the down direction points in the same direction as the palm
8890
val angle = Vector3.angleBetween(palmPose.rotation * Vector3.Down, Vector3.Up)
89-
palmEntity.setHidden(angle > Math.toRadians(40.0))
91+
palmEntity.setEnabled(angle > Math.toRadians(40.0))
9092

9193
val transformedPose =
9294
session.scene.perceptionSpace.transformPoseTo(
@@ -98,6 +100,7 @@ fun ComponentActivity.renderPlanetAtHandPalm(leftHandState: Hand.State) {
98100
// [END androidxr_arcore_hand_entityAtHandPalm]
99101
}
100102

103+
@Suppress("RestrictedApi") // b/416066566
101104
fun ComponentActivity.renderPlanetAtFingerTip(rightHandState: Hand.State) {
102105
val session: Session = null!!
103106
val indexFingerEntity: GltfModelEntity = null!!
@@ -107,7 +110,7 @@ fun ComponentActivity.renderPlanetAtFingerTip(rightHandState: Hand.State) {
107110

108111
// the forward direction points towards the finger tip.
109112
val angle = Vector3.angleBetween(tipPose.rotation * Vector3.Forward, Vector3.Up)
110-
indexFingerEntity.setHidden(angle > Math.toRadians(40.0))
113+
indexFingerEntity.setEnabled(angle > Math.toRadians(40.0))
111114

112115
val transformedPose =
113116
session.scene.perceptionSpace.transformPoseTo(
@@ -120,6 +123,7 @@ fun ComponentActivity.renderPlanetAtFingerTip(rightHandState: Hand.State) {
120123
// [END androidxr_arcore_hand_entityAtIndexFingerTip]
121124
}
122125

126+
@Suppress("RestrictedApi") // b/416066566
123127
private fun detectPinch(session: Session, handState: Hand.State): Boolean {
124128
// [START androidxr_arcore_hand_pinch_gesture]
125129
val thumbTip = handState.handJoints[HandJointType.THUMB_TIP] ?: return false

xr/src/main/java/com/example/xr/arcore/Planes.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ import androidx.xr.runtime.math.Pose
2626
import androidx.xr.runtime.math.Ray
2727
import androidx.xr.scenecore.scene
2828

29-
@Suppress("RestrictedApi") // b/416288516 - session.config and session.configure() are incorrectly restricted
3029
fun configurePlaneTracking(session: Session) {
3130
// [START androidxr_arcore_planetracking_configure]
3231
val newConfig = session.config.copy(
33-
planeTracking = Config.PlaneTrackingMode.HorizontalAndVertical,
32+
planeTracking = Config.PlaneTrackingMode.HORIZONTAL_AND_VERTICAL,
3433
)
3534
when (val result = session.configure(newConfig)) {
3635
is SessionConfigureConfigurationNotSupported ->
3736
TODO(/* Some combinations of configurations are not valid. Handle this failure case. */)
3837
is SessionConfigurePermissionsNotGranted ->
3938
TODO(/* The required permissions in result.permissions have not been granted. */)
4039
is SessionConfigureSuccess -> TODO(/* Success! */)
40+
else ->
41+
TODO(/* A different unhandled exception was thrown. */)
4142
}
4243
// [END androidxr_arcore_planetracking_configure]
4344
}
@@ -50,6 +51,7 @@ private suspend fun subscribePlanes(session: Session) {
5051
// [END androidxr_arcore_planes_subscribe]
5152
}
5253

54+
@Suppress("RestrictedApi") // b/416066566
5355
private fun hitTestTable(session: Session) {
5456
val pose = session.scene.spatialUser.head?.transformPoseTo(Pose(), session.scene.perceptionSpace) ?: return
5557
val ray = Ray(pose.translation, pose.forward)
@@ -58,7 +60,7 @@ private fun hitTestTable(session: Session) {
5860
// When interested in the first Table hit:
5961
val tableHit = results.firstOrNull {
6062
val trackable = it.trackable
61-
trackable is Plane && trackable.state.value.label == Plane.Label.Table
63+
trackable is Plane && trackable.state.value.label == Plane.Label.TABLE
6264
}
6365
// [END androidxr_arcore_hitTest]
6466
}

xr/src/main/java/com/example/xr/compose/Orbiter.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import androidx.compose.foundation.layout.padding
2525
import androidx.compose.foundation.layout.width
2626
import androidx.compose.foundation.shape.CircleShape
2727
import androidx.compose.foundation.shape.CornerSize
28-
import androidx.compose.material.MaterialTheme
29-
import androidx.compose.material.Surface
28+
import androidx.compose.material3.MaterialTheme
29+
import androidx.compose.material3.Surface
3030
import androidx.compose.material3.Text
3131
import androidx.compose.runtime.Composable
3232
import androidx.compose.ui.Alignment
@@ -36,9 +36,9 @@ import androidx.compose.ui.graphics.Color
3636
import androidx.compose.ui.res.dimensionResource
3737
import androidx.compose.ui.unit.dp
3838
import androidx.compose.ui.unit.sp
39-
import androidx.xr.compose.spatial.EdgeOffset
39+
import androidx.xr.compose.spatial.ContentEdge
4040
import androidx.xr.compose.spatial.Orbiter
41-
import androidx.xr.compose.spatial.OrbiterEdge
41+
import androidx.xr.compose.spatial.OrbiterOffsetType
4242
import androidx.xr.compose.spatial.Subspace
4343
import androidx.xr.compose.subspace.SpatialPanel
4444
import androidx.xr.compose.subspace.SpatialRow
@@ -50,6 +50,7 @@ import androidx.xr.compose.subspace.layout.resizable
5050
import androidx.xr.compose.subspace.layout.width
5151
import com.example.xr.R
5252

53+
@Suppress("RestrictedApi") // b/416066566
5354
@Composable
5455
private fun OrbiterExampleSubspace() {
5556
// [START androidxr_compose_OrbiterExampleSubspace]
@@ -72,7 +73,7 @@ private fun OrbiterExampleSubspace() {
7273
@Composable
7374
fun OrbiterExample() {
7475
Orbiter(
75-
position = OrbiterEdge.Bottom,
76+
position = ContentEdge.Bottom,
7677
offset = 96.dp,
7778
alignment = Alignment.CenterHorizontally
7879
) {
@@ -97,18 +98,20 @@ fun OrbiterExample() {
9798
// [END androidxr_compose_OrbiterExample]
9899

99100
@Composable
101+
@Suppress("RestrictedApi") // b/416066566
100102
fun OrbiterAnchoringExample() {
101103
// [START androidxr_compose_OrbiterAnchoringExample]
102104
Subspace {
103105
SpatialRow {
104106
Orbiter(
105-
position = OrbiterEdge.Top,
106-
offset = EdgeOffset.inner(8.dp),
107+
position = ContentEdge.Top,
108+
offset = 8.dp,
109+
offsetType = OrbiterOffsetType.InnerEdge,
107110
shape = SpatialRoundedCornerShape(size = CornerSize(50))
108111
) {
109112
Text(
110113
"Hello World!",
111-
style = MaterialTheme.typography.h2,
114+
style = MaterialTheme.typography.titleMedium,
112115
modifier = Modifier
113116
.background(Color.White)
114117
.padding(16.dp)
@@ -150,7 +153,7 @@ private fun Ui2DToOribiter() {
150153

151154
// New XR differentiated approach
152155
Orbiter(
153-
position = OrbiterEdge.Start,
156+
position = ContentEdge.Start,
154157
offset = dimensionResource(R.dimen.start_orbiter_padding),
155158
alignment = Alignment.Top
156159
) {

xr/src/main/java/com/example/xr/compose/SpatialCapabilities.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private fun SpatialCapabilitiesCheck() {
4545
// [END androidxr_compose_checkSpatialCapabilities]
4646
}
4747

48+
@Suppress("RestrictedApi") // b/416066566
4849
@Composable
4950
private fun checkSpatialUiEnabled() {
5051
// [START androidxr_compose_checkSpatialUiEnabled]

xr/src/main/java/com/example/xr/compose/SpatialElevation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private fun ComposableThatShouldElevateInXr() {}
2727
private fun SpatialElevationExample() {
2828
// [START androidxr_compose_spatialelevation]
2929
// Elevate an otherwise 2D Composable (signified here by ComposableThatShouldElevateInXr).
30-
SpatialElevation(spatialElevationLevel = SpatialElevationLevel.Level4) {
30+
SpatialElevation(elevation = SpatialElevationLevel.Level4) {
3131
ComposableThatShouldElevateInXr()
3232
}
3333
// [END androidxr_compose_spatialelevation]

xr/src/main/java/com/example/xr/compose/SpatialExternalSurface.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.example.xr.compose
1919
import android.content.ContentResolver
2020
import android.net.Uri
2121
import androidx.compose.runtime.Composable
22+
import androidx.compose.runtime.ExperimentalComposeApi
2223
import androidx.compose.runtime.remember
2324
import androidx.compose.ui.platform.LocalContext
2425
import androidx.compose.ui.unit.dp
@@ -32,6 +33,8 @@ import androidx.xr.compose.subspace.layout.height
3233
import androidx.xr.compose.subspace.layout.width
3334

3435
// [START androidxr_compose_SpatialExternalSurfaceStereo]
36+
@OptIn(ExperimentalComposeApi::class)
37+
@Suppress("RestrictedApi") // b/416066566
3538
@Composable
3639
fun SpatialExternalSurfaceContent() {
3740
val context = LocalContext.current

xr/src/main/java/com/example/xr/compose/SpatialLayout.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import androidx.xr.compose.subspace.layout.SubspaceModifier
3636
import androidx.xr.compose.subspace.layout.height
3737
import androidx.xr.compose.subspace.layout.width
3838

39+
@Suppress("RestrictedApi") // b/416066566
3940
@Composable
4041
private fun SpatialLayoutExampleSubspace() {
4142
// [START androidxr_compose_SpatialLayoutExampleSubspace]

xr/src/main/java/com/example/xr/compose/SpatialPanel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import androidx.xr.compose.subspace.layout.movable
3636
import androidx.xr.compose.subspace.layout.resizable
3737
import androidx.xr.compose.subspace.layout.width
3838

39+
@Suppress("RestrictedApi") // b/416066566
3940
@Composable
4041
private fun SpatialPanelExample() {
4142
// [START androidxr_compose_SpatialPanel]
@@ -75,6 +76,7 @@ fun SpatialPanelContent() {
7576
@Composable
7677
private fun AppContent() {}
7778

79+
@Suppress("RestrictedApi") // b/416066566
7880
@Composable
7981
private fun ContentInSpatialPanel() {
8082
// [START androidxr_compose_SpatialPanelAppContent]

xr/src/main/java/com/example/xr/compose/SpatialRow.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.xr.compose.subspace.layout.SubspaceModifier
2424
import androidx.xr.compose.subspace.layout.height
2525
import androidx.xr.compose.subspace.layout.width
2626

27+
@Suppress("RestrictedApi") // b/416066566
2728
@Composable
2829
private fun SpatialRowExample() {
2930
// [START androidxr_compose_SpatialRowExample]

xr/src/main/java/com/example/xr/compose/Subspace.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import androidx.xr.compose.spatial.ApplicationSubspace
2626
import androidx.xr.compose.spatial.Subspace
2727
import androidx.xr.compose.subspace.SpatialPanel
2828

29+
@Suppress("RestrictedApi") // b/416066566
2930
private class SubspaceActivity : ComponentActivity() {
3031
override fun onCreate(savedInstanceState: Bundle?) {
3132
super.onCreate(savedInstanceState)

xr/src/main/java/com/example/xr/compose/Views.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,42 @@ import android.view.LayoutInflater
2222
import android.view.View
2323
import android.view.ViewGroup
2424
import androidx.activity.ComponentActivity
25+
import androidx.activity.compose.setContent
2526
import androidx.compose.material3.Text
2627
import androidx.compose.ui.platform.ComposeView
2728
import androidx.compose.ui.platform.ViewCompositionStrategy
2829
import androidx.compose.ui.unit.dp
2930
import androidx.fragment.app.Fragment
30-
import androidx.xr.compose.platform.setSubspaceContent
31+
import androidx.xr.compose.spatial.Subspace
3132
import androidx.xr.compose.subspace.SpatialPanel
3233
import androidx.xr.compose.subspace.layout.SubspaceModifier
3334
import androidx.xr.compose.subspace.layout.depth
3435
import androidx.xr.compose.subspace.layout.height
3536
import androidx.xr.compose.subspace.layout.width
3637
import androidx.xr.runtime.Session
38+
import androidx.xr.runtime.math.IntSize2d
3739
import androidx.xr.scenecore.PanelEntity
38-
import androidx.xr.scenecore.PixelDimensions
3940
import com.example.xr.R
4041

4142
private class MyCustomView(context: Context) : View(context)
4243

4344
private class ActivityWithSubspaceContent : ComponentActivity() {
45+
@Suppress("RestrictedApi") // b/416066566
4446
override fun onCreate(savedInstanceState: Bundle?) {
4547
super.onCreate(savedInstanceState)
4648
// [START androidxr_compose_ActivityWithSubspaceContent]
47-
setSubspaceContent {
48-
SpatialPanel(
49-
modifier = SubspaceModifier.height(500.dp).width(500.dp).depth(25.dp)
50-
) { MyCustomView(this) }
49+
setContent {
50+
Subspace {
51+
SpatialPanel(
52+
modifier = SubspaceModifier.height(500.dp).width(500.dp).depth(25.dp)
53+
) { MyCustomView(this@ActivityWithSubspaceContent) }
54+
}
5155
}
5256
// [END androidxr_compose_ActivityWithSubspaceContent]
5357
}
5458
}
5559

60+
@Suppress("RestrictedApi") // b/416066566
5661
private class FragmentWithComposeView() : Fragment() {
5762
// [START androidxr_compose_FragmentWithComposeView]
5863
override fun onCreateView(
@@ -83,7 +88,7 @@ fun ComponentActivity.PanelEntityWithView(xrSession: Session) {
8388
val panelEntity = PanelEntity.create(
8489
session = xrSession,
8590
view = panelContent,
86-
pixelDimensions = PixelDimensions(500, 500),
91+
pixelDimensions = IntSize2d(500, 500),
8792
name = "panel entity"
8893
)
8994
// [END androidxr_compose_PanelEntityWithView]

0 commit comments

Comments
 (0)