mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] Closes https://github.com/mozilla-mobile/fenix/issues/4052: Remove pending intent workaround. (https://github.com/mozilla-mobile/fenix/pull/4059)
Previously we needed to set a static launch function to be invoked when the find in page integration should be launched. Now we can access the integration class directly and can avoid the static property that caused issues when used by multiple activities.
This commit is contained in:
parent
71f174f922
commit
5aa444e448
@ -109,7 +109,6 @@ class BrowserFragment : Fragment(), BackHandler {
|
|||||||
private var tabCollectionObserver: Observer<List<TabCollection>>? = null
|
private var tabCollectionObserver: Observer<List<TabCollection>>? = null
|
||||||
private var sessionObserver: Session.Observer? = null
|
private var sessionObserver: Session.Observer? = null
|
||||||
private var sessionManagerObserver: SessionManager.Observer? = null
|
private var sessionManagerObserver: SessionManager.Observer? = null
|
||||||
private var pendingOpenInBrowserIntent: Intent? = null
|
|
||||||
|
|
||||||
private val sessionFeature = ViewBoundFeatureWrapper<SessionFeature>()
|
private val sessionFeature = ViewBoundFeatureWrapper<SessionFeature>()
|
||||||
private val contextMenuFeature = ViewBoundFeatureWrapper<ContextMenuFeature>()
|
private val contextMenuFeature = ViewBoundFeatureWrapper<ContextMenuFeature>()
|
||||||
@ -631,10 +630,6 @@ class BrowserFragment : Fragment(), BackHandler {
|
|||||||
sessionManagerObserver?.let {
|
sessionManagerObserver?.let {
|
||||||
requireComponents.core.sessionManager.unregister(it)
|
requireComponents.core.sessionManager.unregister(it)
|
||||||
}
|
}
|
||||||
pendingOpenInBrowserIntent?.let {
|
|
||||||
startActivity(it)
|
|
||||||
pendingOpenInBrowserIntent = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed(): Boolean {
|
override fun onBackPressed(): Boolean {
|
||||||
@ -743,7 +738,7 @@ class BrowserFragment : Fragment(), BackHandler {
|
|||||||
(BottomSheetBehavior.from(nestedScrollQuickAction as View) as QuickActionSheetBehavior).apply {
|
(BottomSheetBehavior.from(nestedScrollQuickAction as View) as QuickActionSheetBehavior).apply {
|
||||||
state = BottomSheetBehavior.STATE_COLLAPSED
|
state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
}
|
}
|
||||||
FindInPageIntegration.launch?.invoke()
|
findInPageIntegration.get()?.launch()
|
||||||
requireComponents.analytics.metrics.track(Event.FindInPageOpened)
|
requireComponents.analytics.metrics.track(Event.FindInPageOpened)
|
||||||
}
|
}
|
||||||
ToolbarMenu.Item.ReportIssue -> getSessionById()?.let { session ->
|
ToolbarMenu.Item.ReportIssue -> getSessionById()?.let { session ->
|
||||||
@ -779,10 +774,10 @@ class BrowserFragment : Fragment(), BackHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Switch to the actual browser which should now display our new selected session
|
// Switch to the actual browser which should now display our new selected session
|
||||||
pendingOpenInBrowserIntent = Intent(context, IntentReceiverActivity::class.java).also {
|
startActivity(Intent(context, IntentReceiverActivity::class.java).also {
|
||||||
it.action = Intent.ACTION_VIEW
|
it.action = Intent.ACTION_VIEW
|
||||||
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
}
|
})
|
||||||
|
|
||||||
// Close this activity since it is no longer displaying any session
|
// Close this activity since it is no longer displaying any session
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
|
@ -31,14 +31,10 @@ class FindInPageIntegration(
|
|||||||
|
|
||||||
override fun start() {
|
override fun start() {
|
||||||
feature.start()
|
feature.start()
|
||||||
|
|
||||||
FindInPageIntegration.launch = this::launch
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stop() {
|
override fun stop() {
|
||||||
feature.stop()
|
feature.stop()
|
||||||
|
|
||||||
FindInPageIntegration.launch = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed(): Boolean {
|
override fun onBackPressed(): Boolean {
|
||||||
@ -50,7 +46,7 @@ class FindInPageIntegration(
|
|||||||
view.asView().visibility = View.GONE
|
view.asView().visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launch() {
|
fun launch() {
|
||||||
sessionManager.runWithSessionIdOrSelected(sessionId) {
|
sessionManager.runWithSessionIdOrSelected(sessionId) {
|
||||||
if (!it.isCustomTabSession()) {
|
if (!it.isCustomTabSession()) {
|
||||||
toolbar.visibility = View.GONE
|
toolbar.visibility = View.GONE
|
||||||
@ -59,15 +55,6 @@ class FindInPageIntegration(
|
|||||||
feature.bind(it)
|
feature.bind(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
// This is a workaround to let the menu item find this integration and active "Find in Page" mode. That's a bit
|
|
||||||
// ridiculous and there's no need that we create the toolbar menu items at app start time. Instead the
|
|
||||||
// ToolbarIntegration should create them and get the FindInPageIntegration injected as a dependency if the
|
|
||||||
// menu items need them.
|
|
||||||
var launch: (() -> Unit)? = null
|
|
||||||
private set
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user