-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix keyboard crashes in BrowserFragment #5033
Conversation
This is the new recommended way to show and hide the keyboard according to the documentation: https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility#ShowReliably Quote: - (Recommended) Use WindowInsetsControllerCompat. This object displays the soft keyboard during Activity.onCreate() as shown in the following code snippet. The call is guaranteed to be scheduled after the window is focused. We decided to enforce the view passed as an EditText as we couldn't imagine a reason for any other type as of now.
We're only changing the functions we saw break right now. We'll follow up with a task to look into other places where we show/hide the keyboard
We should discourage the use of the the extension functions that probably are not reliable in favour of our new extension functions
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @mikescamell and the rest of your teammates on Graphite |
common/common-utils/src/main/java/com/duckduckgo/common/utils/extensions/FragmentExtensions.kt
Outdated
Show resolved
Hide resolved
common/common-utils/src/main/java/com/duckduckgo/common/utils/extensions/FragmentExtensions.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this it’s removing the outline of the Omnibar.
app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I let you agree with @joshliebe in the outstanding question, but I don’t consider that a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m gonna have to disagree with @malmstein on this one, blocking on: #5033 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current issues seem to be unrelated to this PR, thanks for fixing this 👍🙂
Task/Issue URL: https://app.asana.com/0/1202552961248957/1208407851630430/f ### Description After we did #5033 the omnibar is taking focus more than usual, triggering onFocus changes in some unexpected scenarios (e.g: if we send the app to background, etc.) After taking a look, the logic to show/hide keyboard was changed, and we now, for both methods, execute `editText.requestFocus()`. That seems correct for showing, but unsure for hiding. ### Steps to test this PR _Feature 1_ - just smoke test ### UI changes | Before | After | | ------ | ----- | !(Upload before screenshot)|(Upload after screenshot)|
Task/Issue URL: https://app.asana.com/0/414730916066338/1208339084893367/f
Description
We saw some keyboard crashes due to some recent refactoring of the Omnibar.
The Omnibar was previously solely bound in onActivityCreated.
It was never nulled out in
onDestroyView
so the Fragment held on to it, and when the delay concluded it would happily try to call show/hideKeyboard using the Omnibar without issue.Now, we’re using the FragmentViewBindingDelegate for the Omnibar, which gets nulled out in onDestroy, so when the delay concluded we tried calling show/hideKeyboard on a null object.
To fix this we’re introducing new extension functions that follow the recommended way to show and hide the keyboard.
Steps to test this PR
Run the following tests locally they should all pass
whenProtectionsAreDisabledRequestAreNotBlocked
whenProtectionsAreDisabledSurrogatesAreNotLoaded
whenProtectionsAreEnabledHttpsUpgradedCorrectly
whenProtectionsAreEnabledRequestBlockedCorrectly
whenProtectionsAreEnabledSurrogatesAreLoaded
whenProtectionsAreFingerprintProtected
Omnibar Keyboard
UI changes
N/A