|
|
@ -97,8 +97,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
private val customTabsIntegration = ViewBoundFeatureWrapper<CustomTabsIntegration>()
|
|
|
|
private val customTabsIntegration = ViewBoundFeatureWrapper<CustomTabsIntegration>()
|
|
|
|
private lateinit var job: Job
|
|
|
|
private lateinit var job: Job
|
|
|
|
|
|
|
|
|
|
|
|
// Session id for custom tab or opened from external intent
|
|
|
|
var customTabSessionId: String? = null
|
|
|
|
var externalSessionId: String? = null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val coroutineContext: CoroutineContext get() = Dispatchers.IO + job
|
|
|
|
override val coroutineContext: CoroutineContext get() = Dispatchers.IO + job
|
|
|
|
|
|
|
|
|
|
|
@ -113,13 +112,13 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
): View? {
|
|
|
|
): View? {
|
|
|
|
require(arguments != null)
|
|
|
|
require(arguments != null)
|
|
|
|
externalSessionId = BrowserFragmentArgs.fromBundle(arguments!!).externalSessionId
|
|
|
|
customTabSessionId = BrowserFragmentArgs.fromBundle(arguments!!).customTabSessionId
|
|
|
|
|
|
|
|
|
|
|
|
val view = inflater.inflate(R.layout.fragment_browser, container, false)
|
|
|
|
val view = inflater.inflate(R.layout.fragment_browser, container, false)
|
|
|
|
|
|
|
|
|
|
|
|
toolbarComponent = ToolbarComponent(
|
|
|
|
toolbarComponent = ToolbarComponent(
|
|
|
|
view.browserLayout,
|
|
|
|
view.browserLayout,
|
|
|
|
ActionBusFactory.get(this), externalSessionId,
|
|
|
|
ActionBusFactory.get(this), customTabSessionId,
|
|
|
|
(activity as HomeActivity).browsingModeManager.isPrivate,
|
|
|
|
(activity as HomeActivity).browsingModeManager.isPrivate,
|
|
|
|
SearchState("", getSessionById()?.searchTerms ?: "", isEditing = false),
|
|
|
|
SearchState("", getSessionById()?.searchTerms ?: "", isEditing = false),
|
|
|
|
search_engine_icon
|
|
|
|
search_engine_icon
|
|
|
@ -150,7 +149,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun getAppropriateLayoutGravity(): Int {
|
|
|
|
private fun getAppropriateLayoutGravity(): Int {
|
|
|
|
if (getSessionById()?.isCustomTabSession() == true) {
|
|
|
|
if (customTabSessionId != null) {
|
|
|
|
return Gravity.TOP
|
|
|
|
return Gravity.TOP
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -206,7 +205,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
sessionManager,
|
|
|
|
sessionManager,
|
|
|
|
SessionUseCases(sessionManager),
|
|
|
|
SessionUseCases(sessionManager),
|
|
|
|
view.engineView,
|
|
|
|
view.engineView,
|
|
|
|
externalSessionId
|
|
|
|
customTabSessionId
|
|
|
|
),
|
|
|
|
),
|
|
|
|
owner = this,
|
|
|
|
owner = this,
|
|
|
|
view = view
|
|
|
|
view = view
|
|
|
@ -241,7 +240,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
feature = FullScreenFeature(
|
|
|
|
feature = FullScreenFeature(
|
|
|
|
sessionManager,
|
|
|
|
sessionManager,
|
|
|
|
SessionUseCases(sessionManager),
|
|
|
|
SessionUseCases(sessionManager),
|
|
|
|
externalSessionId
|
|
|
|
customTabSessionId
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if (it) {
|
|
|
|
if (it) {
|
|
|
|
FenixSnackbar.make(view.rootView, Snackbar.LENGTH_LONG)
|
|
|
|
FenixSnackbar.make(view.rootView, Snackbar.LENGTH_LONG)
|
|
|
@ -279,20 +278,18 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
|
|
|
|
|
|
|
|
val actionEmitter = ActionBusFactory.get(this).getManagedEmitter(SearchAction::class.java)
|
|
|
|
val actionEmitter = ActionBusFactory.get(this).getManagedEmitter(SearchAction::class.java)
|
|
|
|
|
|
|
|
|
|
|
|
if (getSessionById()?.isCustomTabSession() == true) {
|
|
|
|
customTabSessionId?.let {
|
|
|
|
externalSessionId?.let {
|
|
|
|
customTabsIntegration.set(
|
|
|
|
customTabsIntegration.set(
|
|
|
|
feature = CustomTabsIntegration(
|
|
|
|
feature = CustomTabsIntegration(
|
|
|
|
requireContext(),
|
|
|
|
requireContext(),
|
|
|
|
requireComponents.core.sessionManager,
|
|
|
|
requireComponents.core.sessionManager,
|
|
|
|
toolbar,
|
|
|
|
toolbar,
|
|
|
|
it,
|
|
|
|
it,
|
|
|
|
activity,
|
|
|
|
activity,
|
|
|
|
onItemTapped = { actionEmitter.onNext(SearchAction.ToolbarMenuItemTapped(it)) }
|
|
|
|
onItemTapped = { actionEmitter.onNext(SearchAction.ToolbarMenuItemTapped(it)) }
|
|
|
|
),
|
|
|
|
),
|
|
|
|
owner = this,
|
|
|
|
owner = this,
|
|
|
|
view = view)
|
|
|
|
view = view)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toolbarComponent.getView().setOnSiteSecurityClickedListener {
|
|
|
|
toolbarComponent.getView().setOnSiteSecurityClickedListener {
|
|
|
@ -508,8 +505,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
val directions = BrowserFragmentDirections
|
|
|
|
val directions = BrowserFragmentDirections
|
|
|
|
.actionBrowserFragmentToSearchFragment(null)
|
|
|
|
.actionBrowserFragmentToSearchFragment(null)
|
|
|
|
Navigation.findNavController(view!!).navigate(directions)
|
|
|
|
Navigation.findNavController(view!!).navigate(directions)
|
|
|
|
(activity as HomeActivity).browsingModeManager.mode =
|
|
|
|
(activity as HomeActivity).browsingModeManager.mode = BrowsingModeManager.Mode.Private
|
|
|
|
BrowsingModeManager.Mode.Private
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ToolbarMenu.Item.FindInPage -> {
|
|
|
|
ToolbarMenu.Item.FindInPage -> {
|
|
|
|
FindInPageIntegration.launch?.invoke()
|
|
|
|
FindInPageIntegration.launch?.invoke()
|
|
|
@ -529,8 +525,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
val directions = BrowserFragmentDirections
|
|
|
|
val directions = BrowserFragmentDirections
|
|
|
|
.actionBrowserFragmentToSearchFragment(null)
|
|
|
|
.actionBrowserFragmentToSearchFragment(null)
|
|
|
|
Navigation.findNavController(view!!).navigate(directions)
|
|
|
|
Navigation.findNavController(view!!).navigate(directions)
|
|
|
|
(activity as HomeActivity).browsingModeManager.mode =
|
|
|
|
(activity as HomeActivity).browsingModeManager.mode = BrowsingModeManager.Mode.Normal
|
|
|
|
BrowsingModeManager.Mode.Normal
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ToolbarMenu.Item.OpenInFenix -> {
|
|
|
|
ToolbarMenu.Item.OpenInFenix -> {
|
|
|
|
val intent = Intent(context, IntentReceiverActivity::class.java)
|
|
|
|
val intent = Intent(context, IntentReceiverActivity::class.java)
|
|
|
@ -576,10 +571,10 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun getSessionById(): Session? {
|
|
|
|
private fun getSessionById(): Session? {
|
|
|
|
return if (externalSessionId != null) {
|
|
|
|
return if (customTabSessionId != null) {
|
|
|
|
requireNotNull(
|
|
|
|
requireNotNull(
|
|
|
|
requireContext().components.core.sessionManager.findSessionById(
|
|
|
|
requireContext().components.core.sessionManager.findSessionById(
|
|
|
|
externalSessionId!!
|
|
|
|
customTabSessionId!!
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -628,7 +623,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun setToolbarBehavior(loading: Boolean) {
|
|
|
|
private fun setToolbarBehavior(loading: Boolean) {
|
|
|
|
if (getSessionById()?.isCustomTabSession() == true) {
|
|
|
|
if (customTabSessionId != null) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|