-
Notifications
You must be signed in to change notification settings - Fork 393
[WIP] Jetpack XR library update for July '26 #978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import androidx.xr.runtime.Config | |
| import androidx.xr.runtime.Session | ||
| import androidx.xr.runtime.SessionConfigureSuccess | ||
| import androidx.xr.runtime.math.Pose | ||
| import androidx.xr.scenecore.AnchorEntity | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm that we are handling this name change properly - is this a breaking change or is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a breaking change. Any code using the old AnchorEntity class will need to be updated to use AnchorSpace. |
||
| import androidx.xr.scenecore.AnchorSpace | ||
| import androidx.xr.scenecore.Entity | ||
| import androidx.xr.scenecore.scene | ||
|
|
||
|
|
@@ -59,7 +59,7 @@ private fun attachEntityToAnchor( | |
| anchor: Anchor | ||
| ) { | ||
| // [START androidxr_arcore_entity_tracks_anchor] | ||
| AnchorEntity.create(session, anchor).apply { | ||
| AnchorSpace.create(session, anchor).apply { | ||
| parent = session.scene.activitySpace | ||
| addChild(entity) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,10 +151,12 @@ class GenerateHandJointData : ComponentActivity() { | |
| @OptIn(FlowPreview::class) | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| val session = (Session.create(context = this) as SessionCreateSuccess).session | ||
| val config = Config.Builder(session.config).setHandTracking(HandTrackingMode.BOTH).build() | ||
| session.configure(config) | ||
|
|
||
| lifecycleScope.launch { | ||
| val session = (Session.create(context = this@GenerateHandJointData) as SessionCreateSuccess).session | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for my own understanding, what does the syntax of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| val config = Config.Builder(session.config).setHandTracking(HandTrackingMode.BOTH).build() | ||
| session.configure(config) | ||
|
|
||
| Hand.right(session).state.sample(500.milliseconds).collect { rightHandState -> | ||
| val bufferString = buildString { | ||
| append("mapOf(") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,8 @@ import androidx.xr.compose.subspace.SpatialRow | |
| import androidx.xr.compose.subspace.layout.SpatialRoundedCornerShape | ||
| import androidx.xr.compose.subspace.layout.SubspaceModifier | ||
| import androidx.xr.compose.subspace.layout.height | ||
| import androidx.xr.compose.subspace.layout.movable | ||
| import androidx.xr.compose.subspace.layout.resizable | ||
| import androidx.xr.compose.subspace.layout.transformingMovable | ||
| import androidx.xr.compose.subspace.layout.transformingResizable | ||
| import androidx.xr.compose.subspace.layout.width | ||
| import androidx.xr.compose.unit.DpVolumeOffset | ||
| import com.example.xr.R | ||
|
|
@@ -59,8 +58,8 @@ private fun OrbiterExampleSubspace() { | |
| SubspaceModifier | ||
| .height(824.dp) | ||
| .width(1400.dp) | ||
| .transformingResizable() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here - how is this deprecation being handled? Do we have enough changes that we should think about doing a migration guide? Or perhaps a few things we should highlight in the Beta Blog post in August?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @amyZepp would be a good person to make that call. What do you think Amy? |
||
| .transformingMovable(), | ||
| .resizable() | ||
| .movable(), | ||
| ) { | ||
| SpatialPanelContent() | ||
| OrbiterExample() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |||||||||||||||||||||
| package com.example.xr.compose | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import androidx.compose.runtime.Composable | ||||||||||||||||||||||
| import androidx.compose.ui.platform.LocalDensity | ||||||||||||||||||||||
| import androidx.compose.ui.unit.dp | ||||||||||||||||||||||
| import androidx.xr.compose.platform.LocalSession | ||||||||||||||||||||||
| import androidx.xr.compose.spatial.Subspace | ||||||||||||||||||||||
|
|
@@ -26,17 +25,17 @@ import androidx.xr.compose.subspace.SceneCoreEntitySizeAdapter | |||||||||||||||||||||
| import androidx.xr.compose.subspace.layout.SubspaceModifier | ||||||||||||||||||||||
| import androidx.xr.compose.subspace.layout.offset | ||||||||||||||||||||||
| import androidx.xr.compose.unit.IntVolumeSize | ||||||||||||||||||||||
| import androidx.xr.compose.unit.Meter | ||||||||||||||||||||||
| import androidx.xr.runtime.math.FloatSize2d | ||||||||||||||||||||||
| import androidx.xr.runtime.math.IntSize2d | ||||||||||||||||||||||
| import androidx.xr.runtime.math.Pose | ||||||||||||||||||||||
| import androidx.xr.scenecore.SurfaceEntity | ||||||||||||||||||||||
| import androidx.xr.scenecore.scene | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Composable | ||||||||||||||||||||||
| fun SceneCoreEntityExample() { | ||||||||||||||||||||||
| val session = LocalSession.current ?: return | ||||||||||||||||||||||
| // [START androidxr_compose_SceneCoreEntity] | ||||||||||||||||||||||
| val density = LocalDensity.current | ||||||||||||||||||||||
| val virtualPixelDensity = session.scene.virtualPixelDensity | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Subspace { | ||||||||||||||||||||||
| SceneCoreEntity( | ||||||||||||||||||||||
| modifier = SubspaceModifier.offset(x = 50.dp), | ||||||||||||||||||||||
|
|
@@ -58,8 +57,8 @@ fun SceneCoreEntityExample() { | |||||||||||||||||||||
| size: IntVolumeSize | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| val extents = FloatSize2d( | ||||||||||||||||||||||
| Meter.fromPixel(size.width.toFloat(), density).toM(), | ||||||||||||||||||||||
| Meter.fromPixel(size.height.toFloat(), density).toM(), | ||||||||||||||||||||||
| size.width.toFloat(), | ||||||||||||||||||||||
| size.height.toFloat() | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the data we are returning from these values fundamentally different now? I am trying to understand if we have a sneaky breaking change that might be hard to detect and leading to bugs. |
||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
Comment on lines
59
to
62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The suggest didn't work due to the unresolved reference |
||||||||||||||||||||||
| entity.shape = SurfaceEntity.Shape.Quad(extents) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,8 +35,8 @@ import androidx.core.content.ContextCompat | |
| import androidx.lifecycle.DefaultLifecycleObserver | ||
| import androidx.lifecycle.LifecycleOwner | ||
| import androidx.lifecycle.lifecycleScope | ||
| import androidx.xr.glimmer.ActionCard | ||
| import androidx.xr.glimmer.Button | ||
| import androidx.xr.glimmer.Card | ||
| import androidx.xr.glimmer.GlimmerTheme | ||
| import androidx.xr.glimmer.Text | ||
| import androidx.xr.glimmer.surface | ||
|
|
@@ -57,6 +57,8 @@ class ProjectedMainActivity : ComponentActivity() { | |
| private var areVisualsOn by mutableStateOf(true) | ||
| private var isPermissionDenied by mutableStateOf(false) | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| // TODO: Remove suppression once Android Emulator supports ProjectedActivityCompat.requestPermissions() | ||
| // [START androidxr_projected_permissions_launcher] | ||
| // Register the permissions launcher using the ProjectedPermissionsResultContract. | ||
| private val requestPermissionLauncher: ActivityResultLauncher<List<ProjectedPermissionsRequestParams>> = | ||
|
|
@@ -158,15 +160,15 @@ fun HomeScreen( | |
| contentAlignment = Alignment.Center | ||
| ) { | ||
| if (isPermissionDenied) { | ||
| Card( | ||
| ActionCard( | ||
| title = { Text("Permission Required") }, | ||
| action = { Button(onClick = onClose) { Text("Exit") } } | ||
| ) { | ||
| Text("Camera access is needed to use AI glasses features.") | ||
| Button(onClick = onRetryPermission) { Text("Retry") } | ||
| } | ||
| } else if (isVisualUiSupported) { | ||
| Card( | ||
| ActionCard( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an interesting API change. Same concerns re depracation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the glimmer Card composable has an action parameter, it is a breaking change (which it is in this case). The glimmer Card composable still exists. |
||
| title = { Text("Android XR") }, | ||
| action = { | ||
| Button(onClick = onClose) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget, if we set a snapshot version, does this have impact on other teams?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If other teams were relying on an older snapshot release and the API changing between the publication of a snippet but that's extremely rare. Once the release is ready, we don't really change it, we upgrade the version number. I would say if we uncomment this line, it should be commented back within 2 weeks (Jetpack release cycle)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention is that the PR author reverts the change to this file - this change is to help XR team members synchronize on the same snapshot version. When Jetpack goes live, we revert the change to
snapshotVersionand merge intomain.