android: keep the chat composer above the keyboard (ime insets) #67
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/chat-ime-insets"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Typing a message in the chat hid both the Send button and the typed body: the keyboard was drawn over them, and the only way to send was to dismiss the keyboard first.
Root cause.
MainActivitycallsenableEdgeToEdge()(setDecorFitsSystemWindows(window, false)). On API 30+ that stops the framework from resizing the window for the soft keyboard, so the manifest'sandroid:windowSoftInputMode="adjustResize"has nothing left to resize and the IME arrives purely as a window inset.Scaffold'scontentWindowInsetscoverssystemBarsonly, neverime— nothing consumed it, so the composer row, its Send button and the draft under it were painted behind the keyboard.Changes
ui/Insets.kt(new)screenContentInsets():systemBars ∪ ime, applied once at the content root.unionis a per-side max, so the keyboard inset (which already covers the navigation bar) and the nav bar are never summed into a double gap.Topis excluded becauseScaffold'spad.topis already the app bar's measured height. Marked@Composable—WindowInsets.imeis a composable read.ui/ChatScreen.ktScaffold(contentWindowInsets = WindowInsets(0,0,0,0))+ the root consumes the inset; the body region holdsweight(1f)in every branch (loading and empty included) so the composer can never be squeezed off the bottom;Sendis always drawn instead of being swapped for a spinner (no layout jump under the thumb);ImeAction.Sendon the field so the keyboard's own action key sends; focus returns to the field after a send;testTagon composer/input/send.ui/InviteScreens.ktVerify/Approve & addunder the invite field stay reachable by scrolling.ui/RotateScreen.ktui/UnlockScreen.ktsafeDrawingPadding(). This screen has noScaffoldand previously had no inset handling at all — the title drew under the status bar, andOpensat under the keyboard while a passphrase was being typed.Evidence
Built and exercised on
emulator-5554(AVDow35, x86_64, API 35) with a debug APK whose sources are byte-identical to this commit (sha256 of all five files compared against the tree that was built):The chat was reached by pasting this install's own invite back in as a friend (that roster entry's onion is the running node, so a real send completes):
The draft text was visible and unobstructed; the message sent both via the
Sendbutton and via the keyboard's action key (paper-plane icon =ImeAction.Send), each landing with the✓✓delivery marker. Those Y values come fromuiautomatordumps — that is the assertion; a screenshot only corroborates it.Not covered by CI
ci.yml's path allowlist issrc/**,crates/**,tests/**,Cargo.*, so an android-only change triggers no job, andandroid-release.ymlruns onv*.*.*tags only. This PR has no green check to look at — the emulator run above is the verification.Follow-ups (separate cards, deliberately not in this PR)
WalletScreen/RosterScreenroot columns are not scrollable — insets alone cannot rescue a confirm button there; they needverticalScroll(or a weightedLazyColumn) first.RosterScreen:137—LazyColumn(Modifier.fillMaxSize())inside aColumnclaims all remaining height and clips anything after it (the wipe-confirm card). Wantsweight(1f).LaunchedEffect; one ViewModel-scoped flow would end the wakeup loop.maxLines = 4is now decorative —ImeAction.Sendmeans Enter sends, so there are no manual newlines. Keep Send (chat convention) or drop to a single line: a decision, not an accident.