|
|
|
@ -11,6 +11,8 @@ import kotlinx.android.synthetic.main.fragment_browser.view.*
|
|
|
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
|
|
|
import kotlinx.coroutines.ObsoleteCoroutinesApi
|
|
|
|
|
import mozilla.components.browser.session.Session
|
|
|
|
|
import mozilla.components.feature.pwa.ext.trustedOrigins
|
|
|
|
|
import mozilla.components.feature.pwa.feature.WebAppHideToolbarFeature
|
|
|
|
|
import mozilla.components.feature.sitepermissions.SitePermissions
|
|
|
|
|
import mozilla.components.lib.state.ext.consumeFrom
|
|
|
|
|
import mozilla.components.support.base.feature.BackHandler
|
|
|
|
@ -19,6 +21,7 @@ import org.mozilla.fenix.R
|
|
|
|
|
import org.mozilla.fenix.browser.BaseBrowserFragment
|
|
|
|
|
import org.mozilla.fenix.components.toolbar.BrowserToolbarController
|
|
|
|
|
import org.mozilla.fenix.components.toolbar.BrowserToolbarInteractor
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
import org.mozilla.fenix.ext.nav
|
|
|
|
|
import org.mozilla.fenix.ext.requireComponents
|
|
|
|
|
|
|
|
|
@ -30,14 +33,16 @@ import org.mozilla.fenix.ext.requireComponents
|
|
|
|
|
class ExternalAppBrowserFragment : BaseBrowserFragment(), BackHandler {
|
|
|
|
|
|
|
|
|
|
private val customTabsIntegration = ViewBoundFeatureWrapper<CustomTabsIntegration>()
|
|
|
|
|
private val hideToolbarFeature = ViewBoundFeatureWrapper<WebAppHideToolbarFeature>()
|
|
|
|
|
|
|
|
|
|
override fun initializeUI(view: View): Session? {
|
|
|
|
|
return super.initializeUI(view)?.also {
|
|
|
|
|
val activity = requireActivity()
|
|
|
|
|
val components = activity.components
|
|
|
|
|
|
|
|
|
|
customTabSessionId?.let { customTabSessionId ->
|
|
|
|
|
customTabsIntegration.set(
|
|
|
|
|
feature = CustomTabsIntegration(
|
|
|
|
|
requireContext(),
|
|
|
|
|
requireComponents.core.sessionManager,
|
|
|
|
|
toolbar,
|
|
|
|
|
customTabSessionId,
|
|
|
|
@ -48,11 +53,36 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), BackHandler {
|
|
|
|
|
),
|
|
|
|
|
owner = this,
|
|
|
|
|
view = view)
|
|
|
|
|
|
|
|
|
|
hideToolbarFeature.set(
|
|
|
|
|
feature = WebAppHideToolbarFeature(
|
|
|
|
|
requireComponents.core.sessionManager,
|
|
|
|
|
toolbar,
|
|
|
|
|
customTabSessionId,
|
|
|
|
|
emptyList()
|
|
|
|
|
) { toolbarVisible ->
|
|
|
|
|
updateLayoutMargins(inFullScreen = !toolbarVisible)
|
|
|
|
|
},
|
|
|
|
|
owner = this,
|
|
|
|
|
view = toolbar)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
consumeFrom(browserStore) {
|
|
|
|
|
browserToolbarView.update(it)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
consumeFrom(components.core.customTabsStore) { state ->
|
|
|
|
|
getSessionById()
|
|
|
|
|
?.let { session -> session.customTabConfig?.sessionToken }
|
|
|
|
|
?.let { token -> state.tabs[token] }
|
|
|
|
|
?.let { tabState ->
|
|
|
|
|
hideToolbarFeature.withFeature {
|
|
|
|
|
it.onTrustedScopesChange(tabState.trustedOrigins)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateLayoutMargins(false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|