|
|
@ -184,6 +184,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
protected var webAppToolbarShouldBeVisible = true
|
|
|
|
protected var webAppToolbarShouldBeVisible = true
|
|
|
|
|
|
|
|
|
|
|
|
private val sharedViewModel: SharedViewModel by activityViewModels()
|
|
|
|
private val sharedViewModel: SharedViewModel by activityViewModels()
|
|
|
|
|
|
|
|
private val homeViewModel: HomeScreenViewModel by activityViewModels()
|
|
|
|
|
|
|
|
|
|
|
|
@VisibleForTesting
|
|
|
|
@VisibleForTesting
|
|
|
|
internal val onboarding by lazy { FenixOnboarding(requireContext()) }
|
|
|
|
internal val onboarding by lazy { FenixOnboarding(requireContext()) }
|
|
|
@ -220,7 +221,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
browserInitialized = initializeUI(view) != null
|
|
|
|
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
|
|
|
@ -238,12 +239,19 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
requireContext().accessibilityManager.addAccessibilityStateChangeListener(this)
|
|
|
|
requireContext().accessibilityManager.addAccessibilityStateChangeListener(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private val homeViewModel: HomeScreenViewModel by activityViewModels()
|
|
|
|
private fun initializeUI(view: View) {
|
|
|
|
|
|
|
|
val tab = getCurrentTab()
|
|
|
|
|
|
|
|
browserInitialized = if (tab != null) {
|
|
|
|
|
|
|
|
initializeUI(view, tab)
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Suppress("ComplexMethod", "LongMethod")
|
|
|
|
@Suppress("ComplexMethod", "LongMethod")
|
|
|
|
@CallSuper
|
|
|
|
@CallSuper
|
|
|
|
@VisibleForTesting
|
|
|
|
internal open fun initializeUI(view: View, tab: SessionState) {
|
|
|
|
internal open fun initializeUI(view: View): Session? {
|
|
|
|
|
|
|
|
val context = requireContext()
|
|
|
|
val context = requireContext()
|
|
|
|
val sessionManager = context.components.core.sessionManager
|
|
|
|
val sessionManager = context.components.core.sessionManager
|
|
|
|
val store = context.components.core.store
|
|
|
|
val store = context.components.core.store
|
|
|
@ -260,7 +268,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
beginAnimateInIfNecessary()
|
|
|
|
beginAnimateInIfNecessary()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return getSessionById()?.also { _ ->
|
|
|
|
|
|
|
|
val openInFenixIntent = Intent(context, IntentReceiverActivity::class.java).apply {
|
|
|
|
val openInFenixIntent = Intent(context, IntentReceiverActivity::class.java).apply {
|
|
|
|
action = Intent.ACTION_VIEW
|
|
|
|
action = Intent.ACTION_VIEW
|
|
|
|
putExtra(HomeActivity.OPEN_TO_BROWSER, true)
|
|
|
|
putExtra(HomeActivity.OPEN_TO_BROWSER, true)
|
|
|
@ -289,9 +296,9 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onCloseTab = { closedSession ->
|
|
|
|
onCloseTab = { closedSession ->
|
|
|
|
val tab = store.state.findTab(closedSession.id) ?: return@DefaultBrowserToolbarController
|
|
|
|
val closedTab = store.state.findTab(closedSession.id) ?: return@DefaultBrowserToolbarController
|
|
|
|
|
|
|
|
|
|
|
|
val snackbarMessage = if (tab.content.private) {
|
|
|
|
val snackbarMessage = if (closedTab.content.private) {
|
|
|
|
requireContext().getString(R.string.snackbar_private_tab_closed)
|
|
|
|
requireContext().getString(R.string.snackbar_private_tab_closed)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
requireContext().getString(R.string.snackbar_tab_closed)
|
|
|
|
requireContext().getString(R.string.snackbar_tab_closed)
|
|
|
@ -710,7 +717,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
|
|
|
|
|
|
|
|
initializeEngineView(toolbarHeight)
|
|
|
|
initializeEngineView(toolbarHeight)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@VisibleForTesting
|
|
|
|
@VisibleForTesting
|
|
|
|
internal fun expandToolbarOnNavigation(store: BrowserStore) {
|
|
|
|
internal fun expandToolbarOnNavigation(store: BrowserStore) {
|
|
|
@ -928,9 +934,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
resumeDownloadDialogState(selectedTab.id, context.components.core.store, view, context, toolbarHeight)
|
|
|
|
resumeDownloadDialogState(selectedTab.id, context.components.core.store, view, context, toolbarHeight)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
view?.let { view ->
|
|
|
|
view?.let { view -> initializeUI(view) }
|
|
|
|
browserInitialized = initializeUI(view) != null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1070,7 +1074,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
sitePermissions: SitePermissions?
|
|
|
|
sitePermissions: SitePermissions?
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract fun navToTrackingProtectionPanel(session: Session)
|
|
|
|
protected abstract fun navToTrackingProtectionPanel(tab: SessionState)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the layout [android.view.Gravity] for the quick settings and ETP dialog.
|
|
|
|
* Returns the layout [android.view.Gravity] for the quick settings and ETP dialog.
|
|
|
@ -1108,9 +1112,9 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun showTrackingProtectionPanel() {
|
|
|
|
private fun showTrackingProtectionPanel() {
|
|
|
|
val session = getSessionById() ?: return
|
|
|
|
val tab = getCurrentTab() ?: return
|
|
|
|
view?.let {
|
|
|
|
view?.let {
|
|
|
|
navToTrackingProtectionPanel(session)
|
|
|
|
navToTrackingProtectionPanel(tab)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|