File tree Expand file tree Collapse file tree 7 files changed +16
-15
lines changed 
core/xr/src/main/java/com/android/developers/androidify/xr 
creation/src/main/java/com/android/developers/androidify/creation/xr 
home/src/main/java/com/android/developers/androidify/home/xr 
results/src/main/java/com/android/developers/androidify/results/xr Expand file tree Collapse file tree 7 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 2323        android : name =" android.hardware.camera" 
2424        android : required =" true"   />
2525
26+     <!--  Androidify can use XR features if they're available; they're not required. --> 
27+     <uses-feature  android : name =" android.software.xr.api.spatial"   android : required =" false"   />
28+ 
2629    <uses-permission  android : name =" android.permission.CAMERA"   />
2730    <uses-sdk  tools : overrideLibrary =" com.google.ai.edge.aicore"   />
2831
Original file line number Diff line number Diff line change 1616package  com.android.developers.androidify.xr 
1717
1818import  androidx.compose.runtime.Composable 
19- import  androidx.compose.runtime.LaunchedEffect  
19+ import  androidx.compose.runtime.DisposableEffect  
2020import  androidx.xr.compose.platform.LocalSession 
2121import  androidx.xr.scenecore.scene 
22- import  kotlinx.coroutines.delay 
2322
2423/* 
25-  * A composable that attempts to continually hide the mainPanel. 
24+  * A composable that hides the mainPanel when it is disposed. When placed outside of an (Application)Subspace, 
25+  * this composable will be disposed after the Subspace, hiding the mainPanelEntity again. 
2626 * 
27-  * This is a temporary workaround for b/440325404, that causes the mainPanelEntity when an 
27+  * This is a temporary workaround for b/440325404, that causes the mainPanelEntity to appear  when an 
2828 * ApplicationSubspace transitions out of the composition due to a race condition when transitioning 
2929 * the two hierarchies. 
3030 */  
3131@Composable
3232fun  MainPanelWorkaround () {
33-     val  session =  LocalSession .current
34-     LaunchedEffect (null ) {
35-         while  (true ) {
36-             delay(100L )
37-             session?.scene?.mainPanelEntity?.setEnabled(false )
33+     val  session =  LocalSession .current ? :  return 
34+     DisposableEffect (session) {
35+         onDispose {
36+             session.scene.mainPanelEntity.setEnabled(false )
3837        }
3938    }
4039}
Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ fun EditScreenSpatial(
7575    onDropCallback :  (Uri ) ->  Unit  = {},
7676) {
7777    DisableSharedTransition  {
78+         MainPanelWorkaround ()
7879        SquiggleBackgroundSubspace (minimumHeight =  600 .dp) {
79-             MainPanelWorkaround ()
8080            SpatialColumn (SubspaceModifier .fillMaxWidth()) {
8181                SpatialPanel (
8282                    SubspaceModifier .offset(z =  10 .dp)
Original file line number Diff line number Diff line change @@ -52,12 +52,12 @@ private const val squiggleSafeContentHeight = 0.6f
5252fun  LoadingScreenSpatial (
5353    onCancelPress :  () ->  Unit ,
5454) {
55+     MainPanelWorkaround ()
5556    BackgroundSubspace (
5657        aspectRatio =  1.4f ,
5758        minimumHeight =  500 .dp,
5859        drawable =  CreationR .drawable.squiggle_light,
5960    ) {
60-         MainPanelWorkaround ()
6161        Orbiter (
6262            position =  ContentEdge .Top ,
6363            offsetType =  OrbiterOffsetType .OuterEdge ,
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ import com.android.developers.androidify.xr.SquiggleBackgroundSubspace
3333
3434@Composable
3535fun  AboutScreenSpatial (onBackPressed :  () ->  Unit , bottomButtons :  @Composable () ->  Unit ) {
36+     MainPanelWorkaround ()
3637    SquiggleBackgroundSubspace (500 .dp) {
37-         MainPanelWorkaround ()
3838        SpatialPanel  {
3939            Orbiter (
4040                ContentEdge .Top ,
Original file line number Diff line number Diff line change @@ -69,8 +69,8 @@ fun HomeScreenContentsSpatial(
6969    onAboutClicked :  () ->  Unit ,
7070) {
7171    DisableSharedTransition  {
72+         MainPanelWorkaround ()
7273        SquiggleBackgroundSubspace (minimumHeight =  600 .dp) {
73-             MainPanelWorkaround ()
7474            Orbiter (
7575                position =  ContentEdge .Top ,
7676                offsetType =  OrbiterOffsetType .OuterEdge ,
Original file line number Diff line number Diff line change @@ -59,9 +59,8 @@ fun ResultsScreenSpatial(
5959) {
6060    var  offsetPose by remember { mutableStateOf(Pose ()) }
6161    DisableSharedTransition  {
62+         MainPanelWorkaround ()
6263        Subspace  {
63-             MainPanelWorkaround ()
64- 
6564            SpatialPanel (
6665                SubspaceModifier 
6766                    .offset(z =  5 .dp)
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments