2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/1205: Adds search term to EditToolbar

This commit is contained in:
Sawyer Blatz 2019-04-23 08:15:07 -07:00 committed by Emily Kager
parent aff56b9e38
commit e04a7b05a7
3 changed files with 7 additions and 8 deletions

View File

@ -117,7 +117,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
view.browserLayout, view.browserLayout,
ActionBusFactory.get(this), sessionId, ActionBusFactory.get(this), sessionId,
(activity as HomeActivity).browsingModeManager.isPrivate, (activity as HomeActivity).browsingModeManager.isPrivate,
SearchState("", isEditing = false), SearchState("", getSessionByIdOrUseSelectedSession().searchTerms, isEditing = false),
search_engine_icon search_engine_icon
) )

View File

@ -24,7 +24,7 @@ class ToolbarComponent(
bus: ActionBusFactory, bus: ActionBusFactory,
private val sessionId: String?, private val sessionId: String?,
private val isPrivate: Boolean, private val isPrivate: Boolean,
override var initialState: SearchState = SearchState("", false), override var initialState: SearchState = SearchState("", "", false),
private val engineIconView: ImageView? = null private val engineIconView: ImageView? = null
) : ) :
UIComponent<SearchState, SearchAction, SearchChange>( UIComponent<SearchState, SearchAction, SearchChange>(
@ -73,6 +73,7 @@ class ToolbarComponent(
data class SearchState( data class SearchState(
val query: String, val query: String,
val searchTerm: String,
val isEditing: Boolean, val isEditing: Boolean,
val engine: SearchEngine? = null val engine: SearchEngine? = null
) : ViewState ) : ViewState

View File

@ -52,19 +52,17 @@ class SearchFragment : Fragment() {
): View? { ): View? {
sessionId = SearchFragmentArgs.fromBundle(arguments!!).sessionId sessionId = SearchFragmentArgs.fromBundle(arguments!!).sessionId
isPrivate = (activity as HomeActivity).browsingModeManager.isPrivate isPrivate = (activity as HomeActivity).browsingModeManager.isPrivate
val session = sessionId?.let { requireComponents.core.sessionManager.findSessionById(it) }
val view = inflater.inflate(R.layout.fragment_search, container, false) val view = inflater.inflate(R.layout.fragment_search, container, false)
val url = sessionId?.let { val url = session?.url ?: ""
requireComponents.core.sessionManager.findSessionById(it)?.let { session ->
session.url
}
} ?: ""
toolbarComponent = ToolbarComponent( toolbarComponent = ToolbarComponent(
view.toolbar_component_wrapper, view.toolbar_component_wrapper,
ActionBusFactory.get(this), ActionBusFactory.get(this),
sessionId, sessionId,
isPrivate, isPrivate,
SearchState(url, isEditing = true), SearchState(url, session?.searchTerms ?: "", isEditing = true),
view.search_engine_icon view.search_engine_icon
) )