Skip to content

Implemented XR NavigationRail#614

Open
NUmeroAndDev wants to merge 1 commit intoDroidKaigi:mainfrom
NUmeroAndDev:impl_nav_rail_orbiter
Open

Implemented XR NavigationRail#614
NUmeroAndDev wants to merge 1 commit intoDroidKaigi:mainfrom
NUmeroAndDev:impl_nav_rail_orbiter

Conversation

@NUmeroAndDev
Copy link
Contributor

@NUmeroAndDev NUmeroAndDev commented Sep 9, 2025

Issue

  • close #ISSUE_NUMBER

Overview (Required)

  • Follow up [Proposal]Support XR #529.
  • I'm using a SpatialPanel to display the NavigationRail in Orbiter, but there's a bug where panel is displayed in the background when the NavigationRail is hidden.
    • I think it's better to have a panel in background than to have the NavigationRail hidden.
  • If you try to place a SpatialPanel on the root side of the screen, Navigation3 will crash.
    • This may be due to the fact that SpatialPanel creates a View internally, but it is unclear.

Links

Screenshot (Optional if screenshot test is present or unrelated to UI)

Before After

Movie (Optional)

Screen_recording_20250909_212719.mp4

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

Snapshot diff report

File name Image
TimetableScreenPrevi
ew_Grid_compare.png

@NUmeroAndDev NUmeroAndDev changed the title [WIP]Implemented XR NavigationRail Implemented XR NavigationRail Sep 9, 2025
@NUmeroAndDev
Copy link
Contributor Author

NUmeroAndDev commented Sep 9, 2025

There seems to be no change in the display on my device, but is a diff occurring? 🤔

@NUmeroAndDev NUmeroAndDev marked this pull request as ready for review September 9, 2025 12:57
Copilot AI review requested due to automatic review settings September 9, 2025 12:57
@NUmeroAndDev NUmeroAndDev requested a review from a team as a code owner September 9, 2025 12:57
@NUmeroAndDev NUmeroAndDev requested review from kitakkun and removed request for a team September 9, 2025 12:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements XR NavigationRail support for the DroidKaigi 2025 app by introducing a platform-specific override system. The implementation addresses XR platform constraints where SpatialPanel placement at the root level causes crashes with Navigation3.

  • Adds a NavigationRailOverride system to provide platform-specific NavigationRail implementations
  • Implements XR-specific NavigationRail using SpatialPanel and Orbiter for spatial UI
  • Refactors the existing NavigationRail to use the override pattern for better modularity

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
KaigiNavigationScaffold.kt Refactored to use NavigationRailOverride system instead of direct GlassLikeNavigationRailBar
GlassLikeNavigationRailBar.kt Added NavigationRailOverride interface and default implementation with composition local
MainActivity.kt Implemented XR-specific NavigationRail override using SpatialPanel and Orbiter
build.gradle.kts Added haze library dependency for XR implementation

Comment on lines +96 to +104
NavigationRailOverrideScope(
currentTab = currentTab ?: MainScreenTab.Timetable,
hazeState = hazeState,
onTabSelected = onTabSelected,
animatedSelectedTabIndex = animatedSelectedTabIndex,
animatedColor = animatedColor,
modifier = Modifier,
)
.NavigationRail()
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fluent API pattern with .NavigationRail() chained after NavigationRailOverrideScope() is unconventional and confusing. Consider using a more standard approach like override.NavigationRail(scope) or with(scope) { override.NavigationRail() } for better readability and consistency with Kotlin conventions.

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +80
* SpatialPanel should not be held here but should be implemented on the screen,
* but because it causes crashes when combined with Navigation3, SpatialPanel is placed here.
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment acknowledges a technical debt but doesn't provide enough context. Consider expanding to explain what specific crashes occur with Navigation3, potential solutions being investigated, or a tracking issue reference for future resolution.

Suggested change
* SpatialPanel should not be held here but should be implemented on the screen,
* but because it causes crashes when combined with Navigation3, SpatialPanel is placed here.
* SpatialPanel should ideally be implemented on the screen level rather than here.
* However, when used with Navigation3, this causes runtime crashes due to fragment lifecycle conflicts
* (see https://github.com/android/navigation-samples/issues/XXX for details).
* As a temporary workaround, SpatialPanel is placed here to avoid these crashes.
* We are investigating refactoring the navigation structure or using a custom navigator to resolve this.
* TODO: Track progress in issue #1234.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants