Repository navigation
Fix Android toast ordering above overlays - #9
Merged
Merged
Conversation
Android hosted the toasts in ComposeViews inside the activity's decor view. Material3's ModalBottomSheet and every Dialog are separate windows stacked above the activity window, so a toast shown while one was open was drawn underneath it. Each position now gets its own TYPE_APPLICATION window, added through the activity's WindowManager while that position has toasts and removed when it is empty. Windows that share the activity's token are ordered by when they were added, so while toasts are on screen the overlay checks each frame whether another window of the activity was added after it, and re-adds itself if so. The hosts compose against a recomposer the overlay owns, so a toast keeps its animation and swipe state across a re-add. The windows are FLAG_NOT_FOCUSABLE, so a text field in a sheet keeps focus and the keyboard stays up. On API 34+ the touchable region is set to the toast cards, so taps around them reach the screen. Before 34 there is no public way to do that and the band's padding takes taps while a toast shows. The overlay sits above the keyboard and is not given IME insets, so the bottom band reads the keyboard height from the activity's other windows and pads for it. Before, a bottom toast was hidden behind the keyboard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What changed?
Why?
Android dialogs, modal bottom sheets, and detached Compose overlays use separate windows above the activity decor. ToastKit previously could render underneath them. The original approach in #5 addressed the ordering problem but could blink during reordering, briefly expose a black system-bar surface, block keyboard input around bottom toasts, and conflict with newer LayoutKit and dynamic-presentation behavior.
This change keeps ToastKit visible above activity-owned overlays while preserving focus, touch behavior, animations, keyboard input, and backward-compatible public APIs.
Closes #5.
How was it tested?
Automated:
composer test— 194 tests, 389 assertions passedgit diff --check:app:compileDebugKotlinin the generated LayoutKit playground — passedManual Android testing on an emulator and physical Android device:
Platforms tested
Breaking changes?
None. The PHP/JavaScript APIs, events, positions, queue/stack behavior, actions, swipe dismissal, and iOS implementation are unchanged.
The visible Android improvement is that bottom toasts now move above the keyboard instead of being hidden behind it.
Checklist