Skip to content

fix(ui): keep Name this location actions above the keyboard - #3992

Open
Devil1716 wants to merge 2 commits into
google:masterfrom
Devil1716:fix/issue-2839-name-location-keyboard
Open

Devil1716 wants to merge 2 commits into
google:masterfrom
Devil1716:fix/issue-2839-name-location-keyboard

Conversation

@Devil1716

Copy link
Copy Markdown

Summary

Keep the “Name this location” Save and Cancel actions visible above the soft keyboard by giving LoiNameDialog a full-screen window with WindowInsets.safeDrawing padding 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

  • Make LoiNameDialog full-screen with decor fitting disabled
  • Pad with WindowInsets.safeDrawing (system bars + IME), matching other bottom-aligned screens
  • Scroll the name field when space is tight; pin Save/Cancel under it

Test plan

  • Ran: ./gradlew :app:ktfmtCheck — passed
  • Ran: ./gradlew detekt — passed
  • Ran: TaskScreenTest (10) and DataCollectionFragmentTest (47) — passed
  • Manual: open “Name this location”, show keyboard, confirm Save/Cancel stay visible (no emulator in CI agent)
  • CI green on this branch

Screenshots

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

  • Diff is minimal; no unrelated refactors
  • Matches project style / CONTRIBUTING
  • No secrets, credentials, or proprietary code
  • Commit messages are clear

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +129 to +137
private fun LoiNameDialogTitle() {
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.headlineSmall) {
Text(
text = stringResource(R.string.loi_name_dialog_title),
color = AlertDialogDefaults.titleContentColor,
fontSize = 5.em,
)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Data collection] Keyboard obscures "Name this location" dialog

1 participant