mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
Use sessionId in FIP Integration, use pendingIntent for startActivity
This commit is contained in:
parent
6d0a4fdb4d
commit
7fa4cf4487
@ -108,6 +108,7 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||
private var tabCollectionObserver: Observer<List<TabCollection>>? = null
|
||||
private var sessionObserver: Session.Observer? = null
|
||||
private var sessionManagerObserver: SessionManager.Observer? = null
|
||||
private var pendingOpenInBrowserIntent: Intent? = null
|
||||
|
||||
private val sessionFeature = ViewBoundFeatureWrapper<SessionFeature>()
|
||||
private val contextMenuFeature = ViewBoundFeatureWrapper<ContextMenuFeature>()
|
||||
@ -272,7 +273,7 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||
|
||||
findInPageIntegration.set(
|
||||
feature = FindInPageIntegration(
|
||||
requireComponents.core.sessionManager, view.findInPageView, view.engineView, toolbar
|
||||
requireComponents.core.sessionManager, customTabSessionId, view.findInPageView, view.engineView, toolbar
|
||||
),
|
||||
owner = this,
|
||||
view = view
|
||||
@ -450,6 +451,7 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||
|
||||
@SuppressWarnings("ComplexMethod")
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
sessionObserver = subscribeToSession()
|
||||
sessionManagerObserver = subscribeToSessions()
|
||||
tabCollectionObserver = subscribeToTabCollections()
|
||||
@ -458,7 +460,6 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||
getSessionById()?.let { updateBookmarkState(it) }
|
||||
|
||||
if (getSessionById() == null) findNavController(this).popBackStack(R.id.homeFragment, false)
|
||||
super.onResume()
|
||||
context?.components?.core?.let {
|
||||
val preferredColorScheme = it.getPreferredColorScheme()
|
||||
if (it.engine.settings.preferredColorScheme != preferredColorScheme) {
|
||||
@ -629,6 +630,10 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||
sessionManagerObserver?.let {
|
||||
requireComponents.core.sessionManager.unregister(it)
|
||||
}
|
||||
pendingOpenInBrowserIntent?.let {
|
||||
startActivity(it)
|
||||
pendingOpenInBrowserIntent = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
@ -760,14 +765,13 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||
ToolbarMenu.Item.OpenInFenix -> {
|
||||
// To not get a "Display Already Acquired" error we need to force remove the engineView here
|
||||
swipeRefresh?.removeView(engineView as View)
|
||||
val intent = Intent(context, IntentReceiverActivity::class.java)
|
||||
intent.action = Intent.ACTION_VIEW
|
||||
pendingOpenInBrowserIntent = Intent(context, IntentReceiverActivity::class.java)
|
||||
pendingOpenInBrowserIntent?.action = Intent.ACTION_VIEW
|
||||
getSessionById()?.customTabConfig = null
|
||||
getSessionById()?.let {
|
||||
requireComponents.core.sessionManager.select(it)
|
||||
}
|
||||
activity?.finish()
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.browser.session.runWithSessionIdOrSelected
|
||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.feature.findinpage.FindInPageFeature
|
||||
@ -21,6 +22,7 @@ import org.mozilla.fenix.test.Mockable
|
||||
@Mockable
|
||||
class FindInPageIntegration(
|
||||
private val sessionManager: SessionManager,
|
||||
private val sessionId: String? = null,
|
||||
private val view: FindInPageView,
|
||||
engineView: EngineView,
|
||||
private val toolbar: BrowserToolbar
|
||||
@ -49,11 +51,11 @@ class FindInPageIntegration(
|
||||
}
|
||||
|
||||
private fun launch() {
|
||||
val session = sessionManager.selectedSession ?: return
|
||||
|
||||
toolbar.visibility = View.GONE
|
||||
view.asView().visibility = View.VISIBLE
|
||||
feature.bind(session)
|
||||
sessionManager.runWithSessionIdOrSelected(sessionId) {
|
||||
toolbar.visibility = View.GONE
|
||||
view.asView().visibility = View.VISIBLE
|
||||
feature.bind(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
Loading…
Reference in New Issue
Block a user