Fixes #5085 - Use CustomTabWindowFeature (#6603)

Opens _blank links in new custom tab
This commit is contained in:
Tiger Oakes 2019-11-14 12:02:27 -08:00 committed by GitHub
parent 4ae60f2cce
commit ee4e1c8f39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 16 deletions

View File

@ -53,7 +53,6 @@ import mozilla.components.feature.session.SwipeRefreshFeature
import mozilla.components.feature.sitepermissions.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissions
import mozilla.components.feature.sitepermissions.SitePermissionsFeature import mozilla.components.feature.sitepermissions.SitePermissionsFeature
import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules
import mozilla.components.feature.tabs.WindowFeature
import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.PermissionsFeature import mozilla.components.support.base.feature.PermissionsFeature
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
@ -103,7 +102,6 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
protected val readerViewFeature = ViewBoundFeatureWrapper<ReaderViewFeature>() protected val readerViewFeature = ViewBoundFeatureWrapper<ReaderViewFeature>()
private val sessionFeature = ViewBoundFeatureWrapper<SessionFeature>() private val sessionFeature = ViewBoundFeatureWrapper<SessionFeature>()
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
private val contextMenuFeature = ViewBoundFeatureWrapper<ContextMenuFeature>() private val contextMenuFeature = ViewBoundFeatureWrapper<ContextMenuFeature>()
private val downloadsFeature = ViewBoundFeatureWrapper<DownloadsFeature>() private val downloadsFeature = ViewBoundFeatureWrapper<DownloadsFeature>()
private val appLinksFeature = ViewBoundFeatureWrapper<AppLinksFeature>() private val appLinksFeature = ViewBoundFeatureWrapper<AppLinksFeature>()
@ -243,15 +241,6 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
view = view view = view
) )
windowFeature.set(
feature = WindowFeature(
store = store,
tabsUseCases = context.components.useCases.tabsUseCases
),
owner = this,
view = view
)
val downloadFeature = DownloadsFeature( val downloadFeature = DownloadsFeature(
context.applicationContext, context.applicationContext,
store = store, store = store,

View File

@ -22,18 +22,19 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.transition.TransitionInflater import androidx.transition.TransitionInflater
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_browser.view.browserLayout import kotlinx.android.synthetic.main.fragment_browser.view.*
import kotlinx.android.synthetic.main.fragment_browser.view.readerViewControlsBar import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.android.synthetic.main.fragment_home.bottom_bar import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.view.*
import kotlinx.android.synthetic.main.tracking_protection_onboarding_popup.view.onboarding_message
import kotlinx.coroutines.ExperimentalCoroutinesApi 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.session.TrackingProtectionUseCases import mozilla.components.feature.session.TrackingProtectionUseCases
import mozilla.components.feature.sitepermissions.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissions
import mozilla.components.feature.tabs.WindowFeature
import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import org.jetbrains.anko.dimen import org.jetbrains.anko.dimen
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
@ -54,9 +55,11 @@ import org.mozilla.fenix.mvi.getManagedEmitter
* Fragment used for browsing the web within the main app. * Fragment used for browsing the web within the main app.
*/ */
@ExperimentalCoroutinesApi @ExperimentalCoroutinesApi
@Suppress("TooManyFunctions", "LargeClass") @Suppress("TooManyFunctions")
class BrowserFragment : BaseBrowserFragment(), BackHandler { class BrowserFragment : BaseBrowserFragment(), BackHandler {
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
postponeEnterTransition() postponeEnterTransition()
@ -100,6 +103,15 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {
view = view view = view
) )
windowFeature.set(
feature = WindowFeature(
store = context.components.core.store,
tabsUseCases = context.components.useCases.tabsUseCases
),
owner = this,
view = view
)
if ((activity as HomeActivity).browsingModeManager.mode.isPrivate) { if ((activity as HomeActivity).browsingModeManager.mode.isPrivate) {
// We need to update styles for private mode programmatically for now: // We need to update styles for private mode programmatically for now:
// https://github.com/mozilla-mobile/android-components/issues/3400 // https://github.com/mozilla-mobile/android-components/issues/3400

View File

@ -16,6 +16,7 @@ import mozilla.components.browser.session.Session
import mozilla.components.concept.engine.manifest.WebAppManifestParser import mozilla.components.concept.engine.manifest.WebAppManifestParser
import mozilla.components.concept.engine.manifest.getOrNull import mozilla.components.concept.engine.manifest.getOrNull
import mozilla.components.feature.contextmenu.ContextMenuCandidate import mozilla.components.feature.contextmenu.ContextMenuCandidate
import mozilla.components.feature.customtabs.CustomTabWindowFeature
import mozilla.components.feature.pwa.ext.getTrustedScope import mozilla.components.feature.pwa.ext.getTrustedScope
import mozilla.components.feature.pwa.ext.trustedOrigins import mozilla.components.feature.pwa.ext.trustedOrigins
import mozilla.components.feature.pwa.feature.ManifestUpdateFeature import mozilla.components.feature.pwa.feature.ManifestUpdateFeature
@ -45,6 +46,7 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), BackHandler {
private val args by navArgs<ExternalAppBrowserFragmentArgs>() private val args by navArgs<ExternalAppBrowserFragmentArgs>()
private val customTabsIntegration = ViewBoundFeatureWrapper<CustomTabsIntegration>() private val customTabsIntegration = ViewBoundFeatureWrapper<CustomTabsIntegration>()
private val windowFeature = ViewBoundFeatureWrapper<CustomTabWindowFeature>()
private val hideToolbarFeature = ViewBoundFeatureWrapper<WebAppHideToolbarFeature>() private val hideToolbarFeature = ViewBoundFeatureWrapper<WebAppHideToolbarFeature>()
@Suppress("LongMethod") @Suppress("LongMethod")
@ -71,6 +73,16 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), BackHandler {
owner = this, owner = this,
view = view) view = view)
windowFeature.set(
feature = CustomTabWindowFeature(
activity,
components.core.store,
customTabSessionId
),
owner = this,
view = view
)
hideToolbarFeature.set( hideToolbarFeature.set(
feature = WebAppHideToolbarFeature( feature = WebAppHideToolbarFeature(
requireComponents.core.sessionManager, requireComponents.core.sessionManager,