Skip to content

Commit e103601

Browse files
committed
fix: Keep traffic pattern and runway active when collapsing navigation panel
- Changed collapse behavior: only collapses UI details, not pattern display - Pattern and runway selection now persist when user collapses panel - Differentiates between collapse (hide details) and cancel (deactivate route) - Improves user workflow by maintaining pattern visibility during compact mode
1 parent bf6d52b commit e103601

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

app/src/main/java/com/example/checklist_interactive/ui/common/ImmersiveModeHelper.kt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ fun ApplyImmersiveModeToDialog(isVisible: Boolean) {
6666
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
6767
)
6868

69+
// Ensure dialog window also does not fit system windows so bars stay hidden
70+
dialogWindow?.let { WindowCompat.setDecorFitsSystemWindows(it, false) }
71+
6972
val preDrawListener = object : android.view.ViewTreeObserver.OnPreDrawListener {
7073
override fun onPreDraw(): Boolean {
7174
controller?.hide(WindowInsetsCompat.Type.systemBars())
72-
controller?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
75+
try {
76+
controller?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
77+
} catch (_: Throwable) {
78+
}
7379
dialogView.viewTreeObserver.removeOnPreDrawListener(this)
7480
return true
7581
}
@@ -79,10 +85,15 @@ fun ApplyImmersiveModeToDialog(isVisible: Boolean) {
7985
val attachListener = object : View.OnAttachStateChangeListener {
8086
override fun onViewAttachedToWindow(v: View) {
8187
val vWindow = (v.context as? android.app.Activity)?.window
88+
// Make sure the attached window also opts out of fitting system windows
89+
vWindow?.let { WindowCompat.setDecorFitsSystemWindows(it, false) }
8290
val c = vWindow?.let { WindowCompat.getInsetsController(it, v) }
8391
c?.hide(WindowInsetsCompat.Type.systemBars())
84-
c?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
85-
92+
try {
93+
c?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
94+
} catch (_: Throwable) {
95+
}
96+
8697
@Suppress("DEPRECATION")
8798
v.systemUiVisibility = (
8899
View.SYSTEM_UI_FLAG_FULLSCREEN
@@ -114,8 +125,26 @@ fun ApplyImmersiveModeToDialog(isVisible: Boolean) {
114125

115126
while (isActive && isVisible) {
116127
try {
128+
// Ensure both dialog window and root view window do not fit system windows
129+
dialogWindow?.let { WindowCompat.setDecorFitsSystemWindows(it, false) }
117130
dialogController?.hide(WindowInsetsCompat.Type.systemBars())
118-
dialogController?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
131+
try {
132+
dialogController?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
133+
} catch (_: Throwable) {
134+
}
135+
136+
// Also attempt to hide on the root view's window in case the modal uses a different attach point
137+
try {
138+
val rootWindow = (dialogView.rootView.context as? android.app.Activity)?.window
139+
rootWindow?.let { WindowCompat.setDecorFitsSystemWindows(it, false) }
140+
val rootController = rootWindow?.let { WindowCompat.getInsetsController(it, dialogView.rootView) }
141+
rootController?.hide(WindowInsetsCompat.Type.systemBars())
142+
try {
143+
rootController?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
144+
} catch (_: Throwable) {
145+
}
146+
} catch (_: Throwable) {
147+
}
119148
} catch (_: Throwable) {
120149
// Ignore errors
121150
}

app/src/main/java/com/example/checklist_interactive/ui/maps/ui/MapNavigationDisplay.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ fun MapNavigationDisplay(
139139
// Sync manual landing collapse with the navigation panel collapse/expand
140140
LaunchedEffect(showNavigationDetails) {
141141
if (!showNavigationDetails) {
142-
// When the navigation panel collapses, collapse all expandable sub-sections
142+
// When the navigation panel collapses, only collapse UI details - keep pattern active!
143143
showManualLandingDetails = false
144-
onShowTrafficPatternChange(false)
145144
onShowPatternDetailsChange(false)
146-
Log.d("MapNavigationDisplay", "Navigation collapsed -> collapsing manual/pattern details")
145+
Log.d("MapNavigationDisplay", "Navigation collapsed -> collapsing UI details only, keeping pattern active")
147146
} else if (showNavigationDetails && showRunwayApproach) {
148147
// If the panel expands while landing is active, expand manual landing details
149148
showManualLandingDetails = true

0 commit comments

Comments
 (0)