|
|
@ -148,8 +148,12 @@ import mozilla.components.feature.session.behavior.ToolbarPosition as MozacToolb
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ExperimentalCoroutinesApi
|
|
|
|
@ExperimentalCoroutinesApi
|
|
|
|
@Suppress("TooManyFunctions", "LargeClass")
|
|
|
|
@Suppress("TooManyFunctions", "LargeClass")
|
|
|
|
abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, ActivityResultHandler,
|
|
|
|
abstract class BaseBrowserFragment :
|
|
|
|
OnBackLongPressedListener, AccessibilityManager.AccessibilityStateChangeListener {
|
|
|
|
Fragment(),
|
|
|
|
|
|
|
|
UserInteractionHandler,
|
|
|
|
|
|
|
|
ActivityResultHandler,
|
|
|
|
|
|
|
|
OnBackLongPressedListener,
|
|
|
|
|
|
|
|
AccessibilityManager.AccessibilityStateChangeListener {
|
|
|
|
|
|
|
|
|
|
|
|
private lateinit var browserFragmentStore: BrowserFragmentStore
|
|
|
|
private lateinit var browserFragmentStore: BrowserFragmentStore
|
|
|
|
private lateinit var browserAnimator: BrowserAnimator
|
|
|
|
private lateinit var browserAnimator: BrowserAnimator
|
|
|
@ -235,25 +239,25 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) =
|
|
|
|
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) =
|
|
|
|
PerfStartup.baseBfragmentOnViewCreated.measureNoInline { // weird indentation to avoid breaking blame.
|
|
|
|
PerfStartup.baseBfragmentOnViewCreated.measureNoInline { // weird indentation to avoid breaking blame.
|
|
|
|
initializeUI(view)
|
|
|
|
initializeUI(view)
|
|
|
|
|
|
|
|
|
|
|
|
if (customTabSessionId == null) {
|
|
|
|
if (customTabSessionId == null) {
|
|
|
|
// We currently only need this observer to navigate to home
|
|
|
|
// We currently only need this observer to navigate to home
|
|
|
|
// in case all tabs have been removed on startup. No need to
|
|
|
|
// in case all tabs have been removed on startup. No need to
|
|
|
|
// this if we have a known session to display.
|
|
|
|
// this if we have a known session to display.
|
|
|
|
observeRestoreComplete(requireComponents.core.store, findNavController())
|
|
|
|
observeRestoreComplete(requireComponents.core.store, findNavController())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
observeTabSelection(requireComponents.core.store)
|
|
|
|
observeTabSelection(requireComponents.core.store)
|
|
|
|
|
|
|
|
|
|
|
|
if (!onboarding.userHasBeenOnboarded()) {
|
|
|
|
if (!onboarding.userHasBeenOnboarded()) {
|
|
|
|
observeTabSource(requireComponents.core.store)
|
|
|
|
observeTabSource(requireComponents.core.store)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requireContext().accessibilityManager.addAccessibilityStateChangeListener(this)
|
|
|
|
requireContext().accessibilityManager.addAccessibilityStateChangeListener(this)
|
|
|
|
Unit
|
|
|
|
Unit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun initializeUI(view: View) {
|
|
|
|
private fun initializeUI(view: View) {
|
|
|
|
val tab = getCurrentTab()
|
|
|
|
val tab = getCurrentTab()
|
|
|
@ -823,15 +827,17 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|
|
|
internal fun expandToolbarOnNavigation(store: BrowserStore) {
|
|
|
|
internal fun expandToolbarOnNavigation(store: BrowserStore) {
|
|
|
|
consumeFlow(store) { flow ->
|
|
|
|
consumeFlow(store) { flow ->
|
|
|
|
flow.mapNotNull {
|
|
|
|
flow.mapNotNull {
|
|
|
|
state -> state.findCustomTabOrSelectedTab(customTabSessionId)
|
|
|
|
state ->
|
|
|
|
}
|
|
|
|
state.findCustomTabOrSelectedTab(customTabSessionId)
|
|
|
|
.ifAnyChanged {
|
|
|
|
|
|
|
|
tab -> arrayOf(tab.content.url, tab.content.loadRequest)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.collect {
|
|
|
|
|
|
|
|
findInPageIntegration.onBackPressed()
|
|
|
|
|
|
|
|
browserToolbarView.expand()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.ifAnyChanged {
|
|
|
|
|
|
|
|
tab ->
|
|
|
|
|
|
|
|
arrayOf(tab.content.url, tab.content.loadRequest)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.collect {
|
|
|
|
|
|
|
|
findInPageIntegration.onBackPressed()
|
|
|
|
|
|
|
|
browserToolbarView.expand()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -907,8 +913,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|
|
|
@VisibleForTesting
|
|
|
|
@VisibleForTesting
|
|
|
|
internal fun shouldPullToRefreshBeEnabled(inFullScreen: Boolean): Boolean {
|
|
|
|
internal fun shouldPullToRefreshBeEnabled(inFullScreen: Boolean): Boolean {
|
|
|
|
return FeatureFlags.pullToRefreshEnabled &&
|
|
|
|
return FeatureFlags.pullToRefreshEnabled &&
|
|
|
|
requireContext().settings().isPullToRefreshEnabledInBrowser &&
|
|
|
|
requireContext().settings().isPullToRefreshEnabledInBrowser &&
|
|
|
|
!inFullScreen
|
|
|
|
!inFullScreen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@VisibleForTesting
|
|
|
|
@VisibleForTesting
|
|
|
@ -981,12 +987,12 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|
|
|
flow.ifChanged {
|
|
|
|
flow.ifChanged {
|
|
|
|
it.selectedTabId
|
|
|
|
it.selectedTabId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.mapNotNull {
|
|
|
|
.mapNotNull {
|
|
|
|
it.selectedTab
|
|
|
|
it.selectedTab
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.collect {
|
|
|
|
.collect {
|
|
|
|
handleTabSelected(it)
|
|
|
|
handleTabSelected(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -998,14 +1004,14 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|
|
|
state.selectedTab
|
|
|
|
state.selectedTab
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.collect {
|
|
|
|
.collect {
|
|
|
|
if (!onboarding.userHasBeenOnboarded() &&
|
|
|
|
if (!onboarding.userHasBeenOnboarded() &&
|
|
|
|
it.content.loadRequest?.triggeredByRedirect != true &&
|
|
|
|
it.content.loadRequest?.triggeredByRedirect != true &&
|
|
|
|
it.source !in intentSourcesList &&
|
|
|
|
it.source !in intentSourcesList &&
|
|
|
|
it.content.url !in onboardingLinksList
|
|
|
|
it.content.url !in onboardingLinksList
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
onboarding.finish()
|
|
|
|
onboarding.finish()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1070,10 +1076,10 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
|
|
|
@CallSuper
|
|
|
|
@CallSuper
|
|
|
|
override fun onBackPressed(): Boolean {
|
|
|
|
override fun onBackPressed(): Boolean {
|
|
|
|
return findInPageIntegration.onBackPressed() ||
|
|
|
|
return findInPageIntegration.onBackPressed() ||
|
|
|
|
fullScreenFeature.onBackPressed() ||
|
|
|
|
fullScreenFeature.onBackPressed() ||
|
|
|
|
promptsFeature.onBackPressed() ||
|
|
|
|
promptsFeature.onBackPressed() ||
|
|
|
|
sessionFeature.onBackPressed() ||
|
|
|
|
sessionFeature.onBackPressed() ||
|
|
|
|
removeSessionIfNeeded()
|
|
|
|
removeSessionIfNeeded()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onBackLongPressed(): Boolean {
|
|
|
|
override fun onBackLongPressed(): Boolean {
|
|
|
|