No issue: Clean up SearchFragment a bit

fennec/production
Sawyer Blatz 4 years ago
parent 011a9e7d96
commit d33edd8841

@ -33,6 +33,7 @@ import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.runWithSessionIdOrSelected import mozilla.components.browser.session.runWithSessionIdOrSelected
import mozilla.components.concept.engine.prompt.ShareData import mozilla.components.concept.engine.prompt.ShareData
import mozilla.components.feature.accounts.FxaCapability
import mozilla.components.feature.accounts.FxaWebChannelFeature import mozilla.components.feature.accounts.FxaWebChannelFeature
import mozilla.components.feature.app.links.AppLinksFeature import mozilla.components.feature.app.links.AppLinksFeature
import mozilla.components.feature.contextmenu.ContextMenuCandidate import mozilla.components.feature.contextmenu.ContextMenuCandidate
@ -481,8 +482,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
view.swipeRefresh.setOnChildScrollUpCallback { _, _ -> true } view.swipeRefresh.setOnChildScrollUpCallback { _, _ -> true }
} }
// @Suppress("ConstantConditionIf") @Suppress("ConstantConditionIf")
/*
if (!FeatureFlags.asFeatureWebChannelsDisabled) { if (!FeatureFlags.asFeatureWebChannelsDisabled) {
webchannelIntegration.set( webchannelIntegration.set(
feature = FxaWebChannelFeature( feature = FxaWebChannelFeature(
@ -499,8 +499,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
) )
} }
*/
initializeEngineView(toolbarHeight) initializeEngineView(toolbarHeight)
} }
} }

@ -64,6 +64,14 @@ class SearchFragment : Fragment(), UserInteractionHandler {
private lateinit var searchStore: SearchFragmentStore private lateinit var searchStore: SearchFragmentStore
private lateinit var searchInteractor: SearchInteractor private lateinit var searchInteractor: SearchInteractor
private fun shouldShowSearchSuggestions(isPrivate: Boolean): Boolean =
if (isPrivate) {
requireContext().settings().shouldShowSearchSuggestions &&
requireContext().settings().shouldShowSearchSuggestionsInPrivate
} else {
requireContext().settings().shouldShowSearchSuggestions
}
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
@ -85,21 +93,13 @@ class SearchFragment : Fragment(), UserInteractionHandler {
requireComponents.analytics.metrics.track(Event.InteractWithSearchURLArea) requireComponents.analytics.metrics.track(Event.InteractWithSearchURLArea)
val showSearchSuggestions =
if (isPrivate) {
requireContext().settings().shouldShowSearchSuggestions &&
requireContext().settings().shouldShowSearchSuggestionsInPrivate
} else {
requireContext().settings().shouldShowSearchSuggestions
}
searchStore = StoreProvider.get(this) { searchStore = StoreProvider.get(this) {
SearchFragmentStore( SearchFragmentStore(
SearchFragmentState( SearchFragmentState(
query = url, query = url,
searchEngineSource = currentSearchEngine, searchEngineSource = currentSearchEngine,
defaultEngineSource = currentSearchEngine, defaultEngineSource = currentSearchEngine,
showSearchSuggestions = showSearchSuggestions, showSearchSuggestions = shouldShowSearchSuggestions(isPrivate),
showSearchSuggestionsHint = false, showSearchSuggestionsHint = false,
showSearchShortcuts = requireContext().settings().shouldShowSearchShortcuts && url.isEmpty(), showSearchShortcuts = requireContext().settings().shouldShowSearchShortcuts && url.isEmpty(),
showClipboardSuggestions = requireContext().settings().shouldShowClipboardSuggestions, showClipboardSuggestions = requireContext().settings().shouldShowClipboardSuggestions,
@ -142,6 +142,7 @@ class SearchFragment : Fragment(), UserInteractionHandler {
listener = ::launchVoiceSearch listener = ::launchVoiceSearch
) )
) )
val urlView = toolbarView.view val urlView = toolbarView.view
.findViewById<InlineAutocompleteEditText>(R.id.mozac_browser_toolbar_edit_url_view) .findViewById<InlineAutocompleteEditText>(R.id.mozac_browser_toolbar_edit_url_view)
urlView?.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO urlView?.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO

Loading…
Cancel
Save