Repository navigation
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?
On Android each toast position now gets its own window, added through the activity's WindowManager while that position has toasts and removed once it's empty. Before, the hosts were views inside the activity's decor view.
An activity's windows stack in the order they were added. While a toast is showing, the overlay checks for a newer window belonging to the same activity, like a sheet or dialog opened over the toast, and re-adds itself so it stays on top. It finds those windows with
WindowInspector.getGlobalWindowViews()and window tokens, which are public from API 29, the plugin's minimum. Windows of other activities are left alone.Details:
AttachedSurfaceControl.setTouchableRegion. On 29 to 33 there's no public way to do that, so taps within about 16dp of a showing toast land on the toast's window.The public API, positions, queue and stack behaviour, swipe, actions and events are unchanged. iOS is unchanged. Its host already lives in its own window at
.alert - 1.Why?
A toast shown while a Material3
ModalBottomSheetor any dialog is open was invisible on Android. The sheet is a dialog window above the activity's, so it covered the toast host.ToastShownstill fired, and the toast only appeared once the sheet closed. We hit this in an app that reopens its composer sheet and shows an error toast when a post fails.Over an AlertDialog:
How was it tested?
vendor/bin/pest: 190 passedcomposer validate --strictToastActionPressed;Not tested: API 29 to 34 on a device, the dynamic presentation and the centre position. The window layout for those matches the old one.
If a sheet or dialog opens over a toast that's already showing, the toast can blink for a frame or two while it's re-added.
Platforms tested
Breaking changes?
None. The one visible difference is that bottom toasts now sit above the keyboard instead of behind it.
Checklist
🤖 Generated with Claude Code