From e4e0d45c1b7d770620b907b7786fd2c3306591a2 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Fri, 12 Jul 2019 19:15:47 +0200 Subject: [PATCH] Closes #3996: Remove workaround for opening custom tab in browser. `EngineView` now allows releasing the `Session` so that it can be rendered by an other `EngineView` instance. --- .../mozilla/fenix/browser/BrowserFragment.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index 47d815c8e4..febb12e1b3 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -769,14 +769,22 @@ class BrowserFragment : Fragment(), BackHandler { } ToolbarMenu.Item.SaveToCollection -> showSaveToCollection() ToolbarMenu.Item.OpenInFenix -> { - // To not get a "Display Already Acquired" error we need to force remove the engineView here - swipeRefresh?.removeView(engineView as View) - pendingOpenInBrowserIntent = Intent(context, IntentReceiverActivity::class.java) - pendingOpenInBrowserIntent?.action = Intent.ACTION_VIEW - getSessionById()?.customTabConfig = null + // Release the session from this view so that it can immediately be rendered by a different view + engineView.release() + + // Strip the CustomTabConfig to turn this Session into a regular tab and then select it getSessionById()?.let { + it.customTabConfig = null requireComponents.core.sessionManager.select(it) } + + // Switch to the actual browser which should now display our new selected session + pendingOpenInBrowserIntent = Intent(context, IntentReceiverActivity::class.java).also { + it.action = Intent.ACTION_VIEW + it.flags = Intent.FLAG_ACTIVITY_NEW_TASK + } + + // Close this activity since it is no longer displaying any session activity?.finish() } }