Skip to content

Commit

Permalink
For mozilla-mobile#13323 - Navigates to new search experience from th…
Browse files Browse the repository at this point in the history
…e browser when enabled
  • Loading branch information
boek committed Aug 5, 2020
1 parent 53962fe commit 4daadc9
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class DefaultBrowserToolbarController(
private val onCloseTab: (Session) -> Unit
) : BrowserToolbarController {

private val useNewSearchExperience
get() = activity.settings().useNewSearchExperience

private val currentSession
get() = customTabSession ?: activity.components.core.sessionManager.selectedSession

Expand All @@ -91,10 +94,17 @@ class DefaultBrowserToolbarController(
internal var ioScope: CoroutineScope = CoroutineScope(Dispatchers.IO)

override fun handleToolbarPaste(text: String) {
val directions = BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
sessionId = currentSession?.id,
pastedText = text
)
val directions = if (useNewSearchExperience) {
BrowserFragmentDirections.actionGlobalSearchDialog(
sessionId = currentSession?.id,
pastedText = text
)
} else {
BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
sessionId = currentSession?.id,
pastedText = text
)
}
navController.nav(R.id.browserFragment, directions, getToolbarNavOptions(activity))
}

Expand All @@ -117,9 +127,15 @@ class DefaultBrowserToolbarController(
Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER)
)

val directions = BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
currentSession?.id
)
val directions = if (useNewSearchExperience) {
BrowserFragmentDirections.actionGlobalSearchDialog(
currentSession?.id
)
} else {
BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
currentSession?.id
)
}

navController.nav(R.id.browserFragment, directions, getToolbarNavOptions(activity))
}
Expand Down

0 comments on commit 4daadc9

Please sign in to comment.