parent
39db8c9557
commit
cc29c5fe84
|
@ -30,6 +30,7 @@ import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.state.state.WebExtensionState
|
import mozilla.components.browser.state.state.WebExtensionState
|
||||||
import mozilla.components.concept.engine.EngineView
|
import mozilla.components.concept.engine.EngineView
|
||||||
|
import mozilla.components.feature.contextmenu.ext.DefaultSelectionActionDelegate
|
||||||
import mozilla.components.service.fxa.sync.SyncReason
|
import mozilla.components.service.fxa.sync.SyncReason
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import mozilla.components.support.ktx.kotlin.isUrl
|
import mozilla.components.support.ktx.kotlin.isUrl
|
||||||
|
@ -208,7 +209,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet
|
attrs: AttributeSet
|
||||||
): View? = when (name) {
|
): 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)
|
else -> super.onCreateView(parent, name, context, attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.feature.contextmenu.ContextMenuCandidate
|
import mozilla.components.feature.contextmenu.ContextMenuCandidate
|
||||||
import mozilla.components.feature.readerview.ReaderViewFeature
|
import mozilla.components.feature.readerview.ReaderViewFeature
|
||||||
|
import mozilla.components.feature.search.SearchFeature
|
||||||
import mozilla.components.feature.session.TrackingProtectionUseCases
|
import mozilla.components.feature.session.TrackingProtectionUseCases
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
import mozilla.components.feature.sitepermissions.SitePermissions
|
||||||
import mozilla.components.feature.tab.collections.TabCollection
|
import mozilla.components.feature.tab.collections.TabCollection
|
||||||
|
@ -44,6 +45,7 @@ import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay
|
||||||
class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||||
|
|
||||||
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
|
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
|
||||||
|
private val searchFeature = ViewBoundFeatureWrapper<SearchFeature>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -68,17 +70,18 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||||
override fun initializeUI(view: View): Session? {
|
override fun initializeUI(view: View): Session? {
|
||||||
val context = requireContext()
|
val context = requireContext()
|
||||||
val sessionManager = context.components.core.sessionManager
|
val sessionManager = context.components.core.sessionManager
|
||||||
|
val components = context.components
|
||||||
|
|
||||||
return super.initializeUI(view)?.also {
|
return super.initializeUI(view)?.also {
|
||||||
readerViewFeature.set(
|
readerViewFeature.set(
|
||||||
feature = ReaderViewFeature(
|
feature = ReaderViewFeature(
|
||||||
context,
|
context,
|
||||||
context.components.core.engine,
|
components.core.engine,
|
||||||
sessionManager,
|
sessionManager,
|
||||||
view.readerViewControlsBar
|
view.readerViewControlsBar
|
||||||
) { available ->
|
) { available ->
|
||||||
if (available) {
|
if (available) {
|
||||||
context.components.analytics.metrics.track(Event.ReaderModeAvailable)
|
components.analytics.metrics.track(Event.ReaderModeAvailable)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
owner = this,
|
owner = this,
|
||||||
|
@ -87,12 +90,23 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||||
|
|
||||||
windowFeature.set(
|
windowFeature.set(
|
||||||
feature = WindowFeature(
|
feature = WindowFeature(
|
||||||
store = context.components.core.store,
|
store = components.core.store,
|
||||||
tabsUseCases = context.components.useCases.tabsUseCases
|
tabsUseCases = components.useCases.tabsUseCases
|
||||||
),
|
),
|
||||||
owner = this,
|
owner = this,
|
||||||
view = view
|
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) {
|
consumeFrom(browserFragmentStore) {
|
||||||
browserToolbarView.update(it)
|
browserToolbarView.update(it)
|
||||||
|
|
Loading…
Reference in New Issue