fix(android): stop dialog flashing when changing download options#138
Merged
Conversation
Clicking the Speed/Priority/Schedule icons triggered repeated UI flashing on Android. The URL field auto-focuses on dialog open, keeping the soft keyboard up. Tapping an icon expands a new panel and grows the dialog; the IME inset adjustment briefly resizes the dialog, but the URL field still holds focus so the keyboard re-shows, which adjusts the inset again - an IME/dialog feedback loop visible as flashing. Clear focus via LocalFocusManager.clearFocus() at the top of each icon's onClick handler so the keyboard dismisses cleanly before the panel animation starts.
Contributor
The earlier clear-focus attempt didn't address #135. clearFocus() does not actually dismiss the soft keyboard on Android, and the real flash was AlertDialog re-centering itself: every frame of the AnimatedContent size lerp changed the dialog's content height, so the dialog window recalculated its position above the IME, producing multiple visible jumps. Switch to a bottom-anchored surface on mobile. A new AdaptiveModal composable picks ModalBottomSheet on Android/iOS and keeps AlertDialog on Desktop/Web. Bottom sheets grow upward when content resizes, so there is no position recalc and no jumps. - Add expect val isMobilePlatform (Android/iOS = true, JVM/Wasm = false) - Add AdaptiveModal wrapping ModalBottomSheet or AlertDialog - Refactor AddDownloadDialog to use AdaptiveModal; drop the focus/ keyboard plumbing now that the sheet handles layout interplay
Match the existing SpeedLimitSelector pattern so chips wrap to the next line on narrow widths instead of overflowing.
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.
Fixes #135
Summary
Clicking the Speed / Priority / Schedule icons at the bottom of the Add Download dialog on Android caused the UI to flash repeatedly. Reported on S24 Ultra (Android 16, OneUI 8.5) in #135.
Root cause
The flash is the
AlertDialogre-centering itself: every frame of theAnimatedContentsize lerp changes the dialog's content height, and the dialog window has to recalculate its position above the IME, producing multiple visible jumps.The earlier
LocalFocusManager.clearFocus()attempt did not help because (a)clearFocus()doesn't actually dismiss the soft keyboard on Android (you needLocalSoftwareKeyboardController.hide()for that — confirmed during testing the keyboard stayed up), and (b) the underlying problem is the centered-dialog positioning, not the keyboard itself.Fix
Switch to a bottom-anchored surface on mobile. A new
AdaptiveModalcomposable picksModalBottomSheeton Android/iOS and keepsAlertDialogon Desktop/Web. Bottom sheets grow upward when content resizes, so there is no position recalc and no jumps.Also:
PrioritySelectorandScheduleSelectornow useFlowRowso chips wrap to the next line on narrow widths instead of overflowing.Changes
expect val isMobilePlatform: Boolean— Android/iOS =true, JVM/Wasm =false.AdaptiveModal— wrapsModalBottomSheet(mobile) orAlertDialog(desktop/web) behind a single API so feature code doesn't need to branch on platform.AddDownloadDialog— now callsAdaptiveModal; dropped theLocalFocusManager/LocalSoftwareKeyboardControllerplumbing now that the modal surface is bottom-anchored.PrioritySelector,ScheduleSelector—FlowRowinstead ofRow.Test plan
AlertDialogand behaves normally.