1
0
Fork 0

For #7896: integrate text selection search from AC (#8295)

master
Severin Rudie 2020-02-17 19:20:35 -08:00 committed by GitHub
parent 39db8c9557
commit cc29c5fe84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 5 deletions

View File

@ -30,6 +30,7 @@ import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.state.state.WebExtensionState
import mozilla.components.concept.engine.EngineView
import mozilla.components.feature.contextmenu.ext.DefaultSelectionActionDelegate
import mozilla.components.service.fxa.sync.SyncReason
import mozilla.components.support.base.feature.UserInteractionHandler
import mozilla.components.support.ktx.kotlin.isUrl
@ -208,7 +209,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
context: Context,
attrs: AttributeSet
): View? = when (name) {
EngineView::class.java.name -> components.core.engine.createView(context, attrs).asView()
EngineView::class.java.name -> components.core.engine.createView(context, attrs).apply {
selectionActionDelegate = DefaultSelectionActionDelegate(
store = components.core.store,
context = context,
appName = getString(R.string.app_name)
)
}.asView()
else -> super.onCreateView(parent, name, context, attrs)
}

View File

@ -18,6 +18,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.components.browser.session.Session
import mozilla.components.feature.contextmenu.ContextMenuCandidate
import mozilla.components.feature.readerview.ReaderViewFeature
import mozilla.components.feature.search.SearchFeature
import mozilla.components.feature.session.TrackingProtectionUseCases
import mozilla.components.feature.sitepermissions.SitePermissions
import mozilla.components.feature.tab.collections.TabCollection
@ -44,6 +45,7 @@ import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay
class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
private val searchFeature = ViewBoundFeatureWrapper<SearchFeature>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -68,17 +70,18 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
override fun initializeUI(view: View): Session? {
val context = requireContext()
val sessionManager = context.components.core.sessionManager
val components = context.components
return super.initializeUI(view)?.also {
readerViewFeature.set(
feature = ReaderViewFeature(
context,
context.components.core.engine,
components.core.engine,
sessionManager,
view.readerViewControlsBar
) { available ->
if (available) {
context.components.analytics.metrics.track(Event.ReaderModeAvailable)
components.analytics.metrics.track(Event.ReaderModeAvailable)
}
},
owner = this,
@ -87,12 +90,23 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
windowFeature.set(
feature = WindowFeature(
store = context.components.core.store,
tabsUseCases = context.components.useCases.tabsUseCases
store = components.core.store,
tabsUseCases = components.useCases.tabsUseCases
),
owner = this,
view = view
)
searchFeature.set(
feature = SearchFeature(components.core.store) {
if (it.isPrivate) {
components.useCases.searchUseCases.newPrivateTabSearch.invoke(it.query)
} else {
components.useCases.searchUseCases.newTabSearch.invoke(it.query)
}
},
owner = this,
view = view
)
consumeFrom(browserFragmentStore) {
browserToolbarView.update(it)