feat: keep Focus mode immersive and screen awake - #3
Merged
Merged
Conversation
Actively hold the system bars hidden by re-applying hide() on every window-focus regain (the notification shade, toasts, permission prompts, and returning from other apps otherwise revert it). Also keep the screen on for the whole focus session so the clock stays readable; both are scoped to the focus surface and released on exit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens Focus mode so it stays a true distraction-free surface:
WindowInsetsControllerCompat.hide()is silently reverted whenever the window loses then regains focus (notification shade, toasts, permission prompts, returning from another app). We now re-apply the hide on every window-focus regain via aViewTreeObserver.OnWindowFocusChangeListener, so the bar no longer creeps back.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPEstill lets a deliberate swipe peek the bars, then they auto-hide.view.keepScreenOn = truefor the whole focus session so the clock is always readable. Scoped to the focus surface (not a raw window flag) and released on dispose.Both are torn down in the existing
onDisposealongside the orientation restore, so leaving Focus (Back or HOME) returns everything to normal.Why this approach
Modifier.keepScreenOn()needs Compose Foundation 1.9; this project is on BOM2025.01.00(~1.7), soview.keepScreenOnis the version-appropriate equivalent with automatic cleanup.hide()on entry is not durable across focus changes — the focus-regain re-hide is the documented fix.Verification
./gradlew assembleDebug lintDebug— green locally (mirrors CI).## [0.0.8]section for the release notes.