Repository navigation
Conversation
The dialog window ignored IME insets, so Save and Cancel sat under the keyboard. Lay the dialog out in the safe drawing area (system bars and IME) and scroll the name field when that space is short. Fixes google#2839 Co-authored-by: Sharan S <Devil1716@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the LoiNameDialog to use a custom Dialog instead of AlertDialog to support proper IME inset handling and keyboard-aware layouts. It breaks down the dialog into smaller, reusable composables: LoiNameDialogCard, LoiNameDialogTitle, and LoiNameDialogButtons. Feedback was provided regarding LoiNameDialogTitle, where using CompositionLocalProvider to set LocalTextStyle combined with a relative 5.em font size is redundant and potentially bug-prone; it is recommended to directly apply the headlineSmall style to the Text component.
| private fun LoiNameDialogTitle() { | ||
| CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.headlineSmall) { | ||
| Text( | ||
| text = stringResource(R.string.loi_name_dialog_title), | ||
| color = AlertDialogDefaults.titleContentColor, | ||
| fontSize = 5.em, | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
Using CompositionLocalProvider to set LocalTextStyle and then overriding it with fontSize = 5.em is unnecessary and potentially bug-prone. 5.em is a relative font size that scales the base font size by 500%, which makes the title excessively large (e.g., 120sp if the base is 24sp). Instead, you can directly apply style = MaterialTheme.typography.headlineSmall to the Text component, which is cleaner, more idiomatic, and avoids the weird scaling issue.
private fun LoiNameDialogTitle() {
Text(
text = stringResource(R.string.loi_name_dialog_title),
color = AlertDialogDefaults.titleContentColor,
style = MaterialTheme.typography.headlineSmall,
)
}CompositionLocalProvider plus fontSize = 5.em scaled headlineSmall by 500%. Set the style on the Text, matching other Material3 dialog titles. Co-authored-by: Sharan S <Devil1716@users.noreply.github.com>
Summary
Keep the “Name this location” Save and Cancel actions visible above the soft keyboard by giving
LoiNameDialoga full-screen window withWindowInsets.safeDrawingpadding and a scrollable name field.Motivation
Fixes #2839 — the Material3 dialog was wrap-content and never received IME insets, so the keyboard covered the action buttons.
Changes
LoiNameDialogfull-screen with decor fitting disabledWindowInsets.safeDrawing(system bars + IME), matching other bottom-aligned screensTest plan
./gradlew :app:ktfmtCheck— passed./gradlew detekt— passedTaskScreenTest(10) andDataCollectionFragmentTest(47) — passedScreenshots
Not captured here — please verify on device/emulator with IME open.
Notes for reviewers
UI-only change in
LoiNameDialog.kt. Tip author is Sharan S with the Google CLA Gmail.Checklist