2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/19970 [Crash] IllegalStateException when navigating to TP panel

This commit is contained in:
Arturo Mejia 2021-07-09 16:57:21 -04:00 committed by mergify[bot]
parent 24b4a03d32
commit 39ea051a14
3 changed files with 25 additions and 21 deletions

View File

@ -39,6 +39,7 @@ import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.navigateSafe
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.runIfFragmentIsAttached
import org.mozilla.fenix.shortcut.PwaOnboardingObserver
import org.mozilla.fenix.theme.ThemeManager
import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay
@ -256,17 +257,18 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
override fun navToTrackingProtectionPanel(tab: SessionState) {
val navController = findNavController()
requireComponents.useCases.trackingProtectionUseCases.containsException(tab.id) { contains ->
val isEnabled = tab.trackingProtection.enabled && !contains
val directions =
BrowserFragmentDirections.actionBrowserFragmentToTrackingProtectionPanelDialogFragment(
sessionId = tab.id,
url = tab.content.url,
trackingProtectionEnabled = isEnabled,
gravity = getAppropriateLayoutGravity()
)
navController.navigateSafe(R.id.browserFragment, directions)
runIfFragmentIsAttached {
val isEnabled = tab.trackingProtection.enabled && !contains
val directions =
BrowserFragmentDirections.actionBrowserFragmentToTrackingProtectionPanelDialogFragment(
sessionId = tab.id,
url = tab.content.url,
trackingProtectionEnabled = isEnabled,
gravity = getAppropriateLayoutGravity()
)
navController.navigateSafe(R.id.browserFragment, directions)
}
}
}

View File

@ -90,7 +90,6 @@ class BrowserToolbarView(
setToolbarBehavior()
elevation = resources.getDimension(R.dimen.browser_fragment_toolbar_elevation)
if (!isCustomTabSession) {
display.setUrlBackground(getDrawable(R.drawable.search_url_background))
}

View File

@ -37,6 +37,7 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.runIfFragmentIsAttached
/**
* Fragment used for browsing the web within external apps.
@ -193,16 +194,18 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
override fun navToTrackingProtectionPanel(tab: SessionState) {
requireComponents.useCases.trackingProtectionUseCases.containsException(tab.id) { contains ->
val isEnabled = tab.trackingProtection.enabled && !contains
val directions =
ExternalAppBrowserFragmentDirections
.actionGlobalTrackingProtectionPanelDialogFragment(
sessionId = tab.id,
url = tab.content.url,
trackingProtectionEnabled = isEnabled,
gravity = getAppropriateLayoutGravity()
)
nav(R.id.externalAppBrowserFragment, directions)
runIfFragmentIsAttached {
val isEnabled = tab.trackingProtection.enabled && !contains
val directions =
ExternalAppBrowserFragmentDirections
.actionGlobalTrackingProtectionPanelDialogFragment(
sessionId = tab.id,
url = tab.content.url,
trackingProtectionEnabled = isEnabled,
gravity = getAppropriateLayoutGravity()
)
nav(R.id.externalAppBrowserFragment, directions)
}
}
}