2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-02 03:40:16 +00:00

For #17377 - Fix for empty awesomeBar on searchFragment open (#17435)

The awesomeBar was set to stay hidden for the first consumeFrom(store) if the SearchDialogFragment.kt. However, recent changes send an additional store update when the view is created. To work around it we can take a look at AwesomeBarView.update(), we see that the awesomeBar suggestions get provided only if the query != url. So we can use the same method to keep the awesomeBar hidden until the user changes anything in the url.
This commit is contained in:
Codrut Topliceanu 2021-01-20 14:18:59 +02:00 committed by GitHub
parent 959dcd2854
commit 20f2135578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -313,23 +313,26 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
}
consumeFrom(store) {
val shouldShowAwesomebar =
!firstUpdate &&
it.query.isNotBlank() ||
it.showSearchShortcuts
awesome_bar?.visibility = if (shouldShowAwesomebar) View.VISIBLE else View.INVISIBLE
/*
* firstUpdate is used to make sure we keep the awesomebar hidden on the first run
* of the searchFragmentDialog. We only turn it false after the user has changed the
* query as consumeFrom may run several times on fragment start due to state updates.
* */
if (it.url != it.query) firstUpdate = false
awesome_bar?.visibility = if (shouldShowAwesomebar(it)) View.VISIBLE else View.INVISIBLE
updateSearchSuggestionsHintVisibility(it)
updateClipboardSuggestion(it, requireContext().components.clipboardHandler.url)
updateToolbarContentDescription(it)
updateSearchShortcutsIcon(it)
toolbarView.update(it)
awesomeBarView.update(it)
firstUpdate = false
addVoiceSearchButton(it)
}
}
private fun shouldShowAwesomebar(searchFragmentState: SearchFragmentState) =
!firstUpdate && searchFragmentState.query.isNotBlank() || searchFragmentState.showSearchShortcuts
private fun updateAccessibilityTraversalOrder() {
val searchWrapperId = search_wrapper.id
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {