parent
4ae40b35e0
commit
46924544b6
|
@ -136,40 +136,43 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
private fun handleOpenedFromExternalSource() {
|
private fun handleOpenedFromExternalSource() {
|
||||||
intent?.putExtra(OPEN_TO_BROWSER, false)
|
intent?.putExtra(OPEN_TO_BROWSER, false)
|
||||||
openToBrowser(
|
openToBrowser(
|
||||||
|
BrowserDirection.FromGlobal,
|
||||||
SafeIntent(intent).getStringExtra(IntentProcessor.ACTIVE_SESSION_ID)
|
SafeIntent(intent).getStringExtra(IntentProcessor.ACTIVE_SESSION_ID)
|
||||||
?: components.core.sessionManager.selectedSession?.id, BrowserDirection.FromGlobal
|
?: components.core.sessionManager.selectedSession?.id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openToBrowserAndLoad(
|
fun openToBrowserAndLoad(
|
||||||
text: String,
|
searchTermOrURL: String,
|
||||||
sessionId: String? = null,
|
externalSessionId: String? = null,
|
||||||
engine: SearchEngine? = null,
|
engine: SearchEngine? = null,
|
||||||
from: BrowserDirection
|
from: BrowserDirection
|
||||||
) {
|
) {
|
||||||
openToBrowser(sessionId, from)
|
openToBrowser(from, externalSessionId)
|
||||||
load(text, sessionId, engine)
|
load(searchTermOrURL, externalSessionId, engine)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openToBrowser(sessionId: String?, from: BrowserDirection) {
|
fun openToBrowser(from: BrowserDirection, externalSessionId: String? = null) {
|
||||||
val directions = when (from) {
|
val directions = when (from) {
|
||||||
BrowserDirection.FromGlobal -> NavGraphDirections.actionGlobalBrowser(sessionId)
|
BrowserDirection.FromGlobal -> NavGraphDirections.actionGlobalBrowser(externalSessionId)
|
||||||
BrowserDirection.FromHome -> HomeFragmentDirections.actionHomeFragmentToBrowserFragment(sessionId)
|
BrowserDirection.FromHome -> HomeFragmentDirections.actionHomeFragmentToBrowserFragment(externalSessionId)
|
||||||
BrowserDirection.FromSearch -> SearchFragmentDirections.actionSearchFragmentToBrowserFragment(sessionId)
|
BrowserDirection.FromSearch ->
|
||||||
|
SearchFragmentDirections.actionSearchFragmentToBrowserFragment(externalSessionId)
|
||||||
BrowserDirection.FromSettings ->
|
BrowserDirection.FromSettings ->
|
||||||
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(sessionId)
|
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(externalSessionId)
|
||||||
BrowserDirection.FromBookmarks ->
|
BrowserDirection.FromBookmarks ->
|
||||||
BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(sessionId)
|
BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(externalSessionId)
|
||||||
BrowserDirection.FromBookmarksFolderSelect ->
|
BrowserDirection.FromBookmarksFolderSelect ->
|
||||||
SelectBookmarkFolderFragmentDirections.actionBookmarkSelectFolderFragmentToBrowserFragment(sessionId)
|
SelectBookmarkFolderFragmentDirections
|
||||||
|
.actionBookmarkSelectFolderFragmentToBrowserFragment(externalSessionId)
|
||||||
BrowserDirection.FromHistory ->
|
BrowserDirection.FromHistory ->
|
||||||
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(sessionId)
|
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(externalSessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
navHost.navController.navigate(directions)
|
navHost.navController.navigate(directions)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun load(text: String, sessionId: String?, engine: SearchEngine?) {
|
private fun load(searchTermOrURL: String, sessionId: String?, engine: SearchEngine?) {
|
||||||
val isPrivate = this.browsingModeManager.isPrivate
|
val isPrivate = this.browsingModeManager.isPrivate
|
||||||
|
|
||||||
val loadUrlUseCase = if (sessionId == null) {
|
val loadUrlUseCase = if (sessionId == null) {
|
||||||
|
@ -187,10 +190,10 @@ open class HomeActivity : AppCompatActivity() {
|
||||||
} else components.useCases.searchUseCases.defaultSearch.invoke(searchTerms, engine)
|
} else components.useCases.searchUseCases.defaultSearch.invoke(searchTerms, engine)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.isUrl()) {
|
if (searchTermOrURL.isUrl()) {
|
||||||
loadUrlUseCase.invoke(text.toNormalizedUrl())
|
loadUrlUseCase.invoke(searchTermOrURL.toNormalizedUrl())
|
||||||
} else {
|
} else {
|
||||||
searchUseCase.invoke(text)
|
searchUseCase.invoke(searchTermOrURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,8 @@ 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
|
||||||
|
|
||||||
var sessionId: String? = null
|
// Session id for custom tab or opened from external intent
|
||||||
|
var externalSessionId: String? = null
|
||||||
|
|
||||||
override val coroutineContext: CoroutineContext get() = Dispatchers.IO + job
|
override val coroutineContext: CoroutineContext get() = Dispatchers.IO + job
|
||||||
|
|
||||||
|
@ -109,15 +110,15 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
require(arguments != null)
|
require(arguments != null)
|
||||||
sessionId = BrowserFragmentArgs.fromBundle(arguments!!).sessionId
|
externalSessionId = BrowserFragmentArgs.fromBundle(arguments!!).externalSessionId
|
||||||
|
|
||||||
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), sessionId,
|
ActionBusFactory.get(this), externalSessionId,
|
||||||
(activity as HomeActivity).browsingModeManager.isPrivate,
|
(activity as HomeActivity).browsingModeManager.isPrivate,
|
||||||
SearchState("", getSessionByIdOrUseSelectedSession().searchTerms, isEditing = false),
|
SearchState("", getSessionById()?.searchTerms ?: "", isEditing = false),
|
||||||
search_engine_icon
|
search_engine_icon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -146,11 +147,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAppropriateLayoutGravity(): Int {
|
private fun getAppropriateLayoutGravity(): Int {
|
||||||
sessionId?.let { sessionId ->
|
if (getSessionById()?.isCustomTabSession() == true) { return Gravity.TOP }
|
||||||
if (requireComponents.core.sessionManager.findSessionById(sessionId)?.isCustomTabSession() == true) {
|
|
||||||
return Gravity.TOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Gravity.BOTTOM
|
return Gravity.BOTTOM
|
||||||
}
|
}
|
||||||
|
@ -158,8 +155,6 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
sessionId = BrowserFragmentArgs.fromBundle(arguments!!).sessionId
|
|
||||||
|
|
||||||
val sessionManager = requireComponents.core.sessionManager
|
val sessionManager = requireComponents.core.sessionManager
|
||||||
|
|
||||||
contextMenuFeature.set(
|
contextMenuFeature.set(
|
||||||
|
@ -206,7 +201,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
sessionManager,
|
sessionManager,
|
||||||
SessionUseCases(sessionManager),
|
SessionUseCases(sessionManager),
|
||||||
view.engineView,
|
view.engineView,
|
||||||
sessionId
|
externalSessionId
|
||||||
),
|
),
|
||||||
owner = this,
|
owner = this,
|
||||||
view = view
|
view = view
|
||||||
|
@ -241,7 +236,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
feature = FullScreenFeature(
|
feature = FullScreenFeature(
|
||||||
sessionManager,
|
sessionManager,
|
||||||
SessionUseCases(sessionManager),
|
SessionUseCases(sessionManager),
|
||||||
sessionId
|
externalSessionId
|
||||||
) {
|
) {
|
||||||
if (it) {
|
if (it) {
|
||||||
FenixSnackbar.make(view.rootView, Snackbar.LENGTH_LONG)
|
FenixSnackbar.make(view.rootView, Snackbar.LENGTH_LONG)
|
||||||
|
@ -275,21 +270,18 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
|
|
||||||
val actionEmitter = ActionBusFactory.get(this).getManagedEmitter(SearchAction::class.java)
|
val actionEmitter = ActionBusFactory.get(this).getManagedEmitter(SearchAction::class.java)
|
||||||
|
|
||||||
sessionId?.let { sessionId ->
|
externalSessionId?.let {
|
||||||
if (sessionManager.findSessionById(sessionId)?.isCustomTabSession() == true) {
|
customTabsIntegration.set(
|
||||||
customTabsIntegration.set(
|
feature = CustomTabsIntegration(
|
||||||
feature = CustomTabsIntegration(
|
requireContext(),
|
||||||
requireContext(),
|
requireComponents.core.sessionManager,
|
||||||
requireComponents.core.sessionManager,
|
toolbar,
|
||||||
toolbar,
|
it,
|
||||||
sessionId,
|
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 {
|
||||||
|
@ -322,7 +314,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
.findNavController(toolbarComponent.getView())
|
.findNavController(toolbarComponent.getView())
|
||||||
.navigate(
|
.navigate(
|
||||||
BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
|
BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
|
||||||
getSessionByIdOrUseSelectedSession().id
|
getSessionById()?.id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -335,10 +327,12 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
handleToolbarItemInteraction(it)
|
handleToolbarItemInteraction(it)
|
||||||
}
|
}
|
||||||
is SearchAction.ToolbarLongClicked -> {
|
is SearchAction.ToolbarLongClicked -> {
|
||||||
getSessionByIdOrUseSelectedSession().copyUrl(requireContext())
|
getSessionById()?.let { session ->
|
||||||
FenixSnackbar.make(view!!, Snackbar.LENGTH_LONG)
|
session.copyUrl(requireContext())
|
||||||
.setText(resources.getString(R.string.url_copied))
|
FenixSnackbar.make(view!!, Snackbar.LENGTH_LONG)
|
||||||
.show()
|
.setText(resources.getString(R.string.url_copied))
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,7 +348,9 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
is QuickActionAction.SharePressed -> {
|
is QuickActionAction.SharePressed -> {
|
||||||
requireComponents.analytics.metrics.track(Event.QuickActionSheetShareTapped)
|
requireComponents.analytics.metrics.track(Event.QuickActionSheetShareTapped)
|
||||||
getSessionByIdOrUseSelectedSession().url.apply { requireContext().share(this) }
|
getSessionById()?.let { session ->
|
||||||
|
session.url.apply { requireContext().share(this) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is QuickActionAction.DownloadsPressed -> {
|
is QuickActionAction.DownloadsPressed -> {
|
||||||
requireComponents.analytics.metrics.track(Event.QuickActionSheetDownloadTapped)
|
requireComponents.analytics.metrics.track(Event.QuickActionSheetDownloadTapped)
|
||||||
|
@ -362,28 +358,29 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
is QuickActionAction.BookmarkPressed -> {
|
is QuickActionAction.BookmarkPressed -> {
|
||||||
requireComponents.analytics.metrics.track(Event.QuickActionSheetBookmarkTapped)
|
requireComponents.analytics.metrics.track(Event.QuickActionSheetBookmarkTapped)
|
||||||
val session = getSessionByIdOrUseSelectedSession()
|
getSessionById()?.let { session ->
|
||||||
CoroutineScope(IO).launch {
|
CoroutineScope(IO).launch {
|
||||||
val guid = requireComponents.core.bookmarksStorage
|
val guid = requireComponents.core.bookmarksStorage
|
||||||
.addItem(BookmarkRoot.Mobile.id, session.url, session.title, null)
|
.addItem(BookmarkRoot.Mobile.id, session.url, session.title, null)
|
||||||
launch(Main) {
|
launch(Main) {
|
||||||
requireComponents.analytics.metrics.track(Event.AddBookmark)
|
requireComponents.analytics.metrics.track(Event.AddBookmark)
|
||||||
view?.let {
|
view?.let {
|
||||||
FenixSnackbar.make(
|
FenixSnackbar.make(
|
||||||
it,
|
it,
|
||||||
Snackbar.LENGTH_LONG
|
Snackbar.LENGTH_LONG
|
||||||
)
|
)
|
||||||
.setAction(getString(R.string.edit_bookmark_snackbar_action)) {
|
.setAction(getString(R.string.edit_bookmark_snackbar_action)) {
|
||||||
Navigation.findNavController(requireActivity(), R.id.container)
|
Navigation.findNavController(requireActivity(), R.id.container)
|
||||||
.navigate(
|
.navigate(
|
||||||
BrowserFragmentDirections
|
BrowserFragmentDirections
|
||||||
.actionBrowserFragmentToBookmarkEditFragment(
|
.actionBrowserFragmentToBookmarkEditFragment(
|
||||||
guid
|
guid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.setText(getString(R.string.bookmark_saved_snackbar))
|
.setText(getString(R.string.bookmark_saved_snackbar))
|
||||||
.show()
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +471,10 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
ToolbarMenu.Item.Library -> Navigation.findNavController(toolbarComponent.getView())
|
ToolbarMenu.Item.Library -> Navigation.findNavController(toolbarComponent.getView())
|
||||||
.navigate(BrowserFragmentDirections.actionBrowserFragmentToLibraryFragment())
|
.navigate(BrowserFragmentDirections.actionBrowserFragmentToLibraryFragment())
|
||||||
is ToolbarMenu.Item.RequestDesktop -> sessionUseCases.requestDesktopSite.invoke(action.item.isChecked)
|
is ToolbarMenu.Item.RequestDesktop -> sessionUseCases.requestDesktopSite.invoke(action.item.isChecked)
|
||||||
ToolbarMenu.Item.Share -> getSessionByIdOrUseSelectedSession().url.apply { requireContext().share(this) }
|
ToolbarMenu.Item.Share -> getSessionById()?.let { session ->
|
||||||
|
session.url.apply { requireContext().share(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
ToolbarMenu.Item.NewPrivateTab -> {
|
ToolbarMenu.Item.NewPrivateTab -> {
|
||||||
val directions = BrowserFragmentDirections
|
val directions = BrowserFragmentDirections
|
||||||
.actionBrowserFragmentToSearchFragment(null)
|
.actionBrowserFragmentToSearchFragment(null)
|
||||||
|
@ -485,9 +485,11 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
FindInPageIntegration.launch?.invoke()
|
FindInPageIntegration.launch?.invoke()
|
||||||
requireComponents.analytics.metrics.track(Event.FindInPageOpened)
|
requireComponents.analytics.metrics.track(Event.FindInPageOpened)
|
||||||
}
|
}
|
||||||
ToolbarMenu.Item.ReportIssue -> getSessionByIdOrUseSelectedSession().url.apply {
|
ToolbarMenu.Item.ReportIssue -> getSessionById()?.let { session ->
|
||||||
val reportUrl = String.format(REPORT_SITE_ISSUE_URL, this)
|
session.url.apply {
|
||||||
sessionUseCases.loadUrl.invoke(reportUrl)
|
val reportUrl = String.format(REPORT_SITE_ISSUE_URL, this)
|
||||||
|
sessionUseCases.loadUrl.invoke(reportUrl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ToolbarMenu.Item.Help -> {
|
ToolbarMenu.Item.Help -> {
|
||||||
// TODO Help #1016
|
// TODO Help #1016
|
||||||
|
@ -501,9 +503,8 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
ToolbarMenu.Item.OpenInFenix -> {
|
ToolbarMenu.Item.OpenInFenix -> {
|
||||||
val intent = Intent(context, IntentReceiverActivity::class.java)
|
val intent = Intent(context, IntentReceiverActivity::class.java)
|
||||||
val session = context!!.components.core.sessionManager.findSessionById(sessionId!!)
|
|
||||||
intent.action = Intent.ACTION_VIEW
|
intent.action = Intent.ACTION_VIEW
|
||||||
intent.data = Uri.parse(session?.url)
|
intent.data = Uri.parse(getSessionById()?.url)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,8 +521,8 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showQuickSettingsDialog() {
|
private fun showQuickSettingsDialog() {
|
||||||
val session = getSessionByIdOrUseSelectedSession()
|
val session = requireNotNull(getSessionById())
|
||||||
val host = requireNotNull(session.url.toUri().host)
|
val host = requireNotNull(session.url.toUri()?.host)
|
||||||
|
|
||||||
launch {
|
launch {
|
||||||
val storage = requireContext().components.storage
|
val storage = requireContext().components.storage
|
||||||
|
@ -543,11 +544,11 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSessionByIdOrUseSelectedSession(): Session {
|
private fun getSessionById(): Session? {
|
||||||
return if (sessionId != null) {
|
return if (externalSessionId != null) {
|
||||||
requireNotNull(requireContext().components.core.sessionManager.findSessionById(requireNotNull(sessionId)))
|
requireNotNull(requireContext().components.core.sessionManager.findSessionById(externalSessionId!!))
|
||||||
} else {
|
} else {
|
||||||
requireContext().components.core.sessionManager.selectedSessionOrThrow
|
requireComponents.core.sessionManager.selectedSession
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,9 +569,8 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setToolbarBehavior(loading: Boolean) {
|
private fun setToolbarBehavior(loading: Boolean) {
|
||||||
if (sessionId?.let { sessionId ->
|
if (getSessionById()?.isCustomTabSession() == true) { return }
|
||||||
context?.components?.core?.sessionManager?.findSessionById(sessionId)?.isCustomTabSession() == true
|
|
||||||
} == true) return
|
|
||||||
val toolbarView = toolbarComponent.uiView.view
|
val toolbarView = toolbarComponent.uiView.view
|
||||||
(toolbarView.layoutParams as CoordinatorLayout.LayoutParams).apply {
|
(toolbarView.layoutParams as CoordinatorLayout.LayoutParams).apply {
|
||||||
// Stop toolbar from collapsing if TalkBack is enabled or page is loading
|
// Stop toolbar from collapsing if TalkBack is enabled or page is loading
|
||||||
|
@ -581,7 +581,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
behavior = BrowserToolbarBottomBehavior(context, null)
|
behavior = BrowserToolbarBottomBehavior(context, null)
|
||||||
} else {
|
} else {
|
||||||
(behavior as? BrowserToolbarBottomBehavior)?.forceExpand(toolbarView)
|
(behavior as? BrowserToolbarBottomBehavior)?.forceExpand(toolbarView)
|
||||||
behavior = null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,8 +208,7 @@ class HomeFragment : Fragment(), CoroutineScope {
|
||||||
is TabAction.Select -> {
|
is TabAction.Select -> {
|
||||||
val session = requireComponents.core.sessionManager.findSessionById(action.sessionId)
|
val session = requireComponents.core.sessionManager.findSessionById(action.sessionId)
|
||||||
requireComponents.core.sessionManager.select(session!!)
|
requireComponents.core.sessionManager.select(session!!)
|
||||||
val directions = HomeFragmentDirections.actionHomeFragmentToBrowserFragment(action.sessionId)
|
(activity as HomeActivity).openToBrowser(BrowserDirection.FromHome)
|
||||||
Navigation.findNavController(view!!).navigate(directions)
|
|
||||||
}
|
}
|
||||||
is TabAction.Close -> {
|
is TabAction.Close -> {
|
||||||
requireComponents.core.sessionManager.findSessionById(action.sessionId)?.let { session ->
|
requireComponents.core.sessionManager.findSessionById(action.sessionId)?.let { session ->
|
||||||
|
@ -225,12 +224,8 @@ class HomeFragment : Fragment(), CoroutineScope {
|
||||||
requireComponents.useCases.tabsUseCases.removeAllTabsOfType.invoke(action.private)
|
requireComponents.useCases.tabsUseCases.removeAllTabsOfType.invoke(action.private)
|
||||||
}
|
}
|
||||||
is TabAction.PrivateBrowsingLearnMore -> {
|
is TabAction.PrivateBrowsingLearnMore -> {
|
||||||
requireComponents.useCases.tabsUseCases.addPrivateTab
|
(activity as HomeActivity).openToBrowserAndLoad(SupportUtils.getGenericSumoURLForTopic
|
||||||
.invoke(SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.PRIVATE_BROWSING_MYTHS))
|
(SupportUtils.SumoTopic.PRIVATE_BROWSING_MYTHS), from = BrowserDirection.FromHome)
|
||||||
(activity as HomeActivity).openToBrowser(
|
|
||||||
requireComponents.core.sessionManager.selectedSession?.id,
|
|
||||||
BrowserDirection.FromHome
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
is TabAction.Add -> {
|
is TabAction.Add -> {
|
||||||
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null)
|
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null)
|
||||||
|
|
|
@ -187,7 +187,7 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
|
||||||
(activity as HomeActivity).browsingModeManager.mode =
|
(activity as HomeActivity).browsingModeManager.mode =
|
||||||
BrowsingModeManager.Mode.Normal
|
BrowsingModeManager.Mode.Normal
|
||||||
(activity as HomeActivity).openToBrowserAndLoad(
|
(activity as HomeActivity).openToBrowserAndLoad(
|
||||||
text = url,
|
searchTermOrURL = url,
|
||||||
from = BrowserDirection.FromBookmarks
|
from = BrowserDirection.FromBookmarks
|
||||||
)
|
)
|
||||||
requireComponents.analytics.metrics.track(Event.OpenedBookmarkInNewTab)
|
requireComponents.analytics.metrics.track(Event.OpenedBookmarkInNewTab)
|
||||||
|
@ -198,7 +198,7 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
|
||||||
(activity as HomeActivity).browsingModeManager.mode =
|
(activity as HomeActivity).browsingModeManager.mode =
|
||||||
BrowsingModeManager.Mode.Private
|
BrowsingModeManager.Mode.Private
|
||||||
(activity as HomeActivity).openToBrowserAndLoad(
|
(activity as HomeActivity).openToBrowserAndLoad(
|
||||||
text = url,
|
searchTermOrURL = url,
|
||||||
from = BrowserDirection.FromBookmarks
|
from = BrowserDirection.FromBookmarks
|
||||||
)
|
)
|
||||||
requireComponents.analytics.metrics.track(Event.OpenedBookmarkInPrivateTab)
|
requireComponents.analytics.metrics.track(Event.OpenedBookmarkInPrivateTab)
|
||||||
|
@ -223,7 +223,7 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
|
||||||
when (it) {
|
when (it) {
|
||||||
is SignInAction.ClickedSignIn -> {
|
is SignInAction.ClickedSignIn -> {
|
||||||
requireComponents.services.accountsAuthFeature.beginAuthentication()
|
requireComponents.services.accountsAuthFeature.beginAuthentication()
|
||||||
(activity as HomeActivity).openToBrowser(null, from = BrowserDirection.FromBookmarks)
|
(activity as HomeActivity).openToBrowser(BrowserDirection.FromBookmarks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class SelectBookmarkFolderFragment : Fragment(), CoroutineScope, AccountObserver
|
||||||
is SignInAction.ClickedSignIn -> {
|
is SignInAction.ClickedSignIn -> {
|
||||||
requireComponents.services.accountsAuthFeature.beginAuthentication()
|
requireComponents.services.accountsAuthFeature.beginAuthentication()
|
||||||
view?.let {
|
view?.let {
|
||||||
(activity as HomeActivity).openToBrowser(null, BrowserDirection.FromBookmarksFolderSelect)
|
(activity as HomeActivity).openToBrowser(BrowserDirection.FromBookmarksFolderSelect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,8 +152,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
is SearchAction.UrlCommitted -> {
|
is SearchAction.UrlCommitted -> {
|
||||||
if (it.url.isNotBlank()) {
|
if (it.url.isNotBlank()) {
|
||||||
(activity as HomeActivity).openToBrowserAndLoad(
|
(activity as HomeActivity).openToBrowserAndLoad(
|
||||||
it.url, it.session, it.engine,
|
it.url, engine = it.engine, from = BrowserDirection.FromSearch
|
||||||
BrowserDirection.FromSearch
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val event = if (it.url.isUrl()) {
|
val event = if (it.url.isUrl()) {
|
||||||
|
@ -184,13 +183,13 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
when (it) {
|
when (it) {
|
||||||
is AwesomeBarAction.URLTapped -> {
|
is AwesomeBarAction.URLTapped -> {
|
||||||
getSessionUseCase(requireContext(), sessionId == null).invoke(it.url)
|
getSessionUseCase(requireContext(), sessionId == null).invoke(it.url)
|
||||||
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
|
(activity as HomeActivity).openToBrowser(BrowserDirection.FromSearch)
|
||||||
requireComponents.analytics.metrics.track(Event.EnteredUrl(false))
|
requireComponents.analytics.metrics.track(Event.EnteredUrl(false))
|
||||||
}
|
}
|
||||||
is AwesomeBarAction.SearchTermsTapped -> {
|
is AwesomeBarAction.SearchTermsTapped -> {
|
||||||
getSearchUseCase(requireContext(), sessionId == null)
|
getSearchUseCase(requireContext(), sessionId == null)
|
||||||
.invoke(it.searchTerms, it.engine)
|
.invoke(it.searchTerms, it.engine)
|
||||||
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
|
(activity as HomeActivity).openToBrowser(BrowserDirection.FromSearch)
|
||||||
|
|
||||||
val engine = it.engine ?: requireComponents
|
val engine = it.engine ?: requireComponents
|
||||||
.search.searchEngineManager.getDefaultSearchEngine(requireContext())
|
.search.searchEngineManager.getDefaultSearchEngine(requireContext())
|
||||||
|
|
|
@ -180,7 +180,7 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
||||||
// We could auto-close this tab once we get to the end of the authentication process?
|
// We could auto-close this tab once we get to the end of the authentication process?
|
||||||
// Via an interceptor, perhaps.
|
// Via an interceptor, perhaps.
|
||||||
view?.let {
|
view?.let {
|
||||||
(activity as HomeActivity).openToBrowser(null, BrowserDirection.FromSettings)
|
(activity as HomeActivity).openToBrowser(BrowserDirection.FromSettings)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
android:id="@+id/action_browserFragment_to_searchFragment"
|
android:id="@+id/action_browserFragment_to_searchFragment"
|
||||||
app:destination="@id/searchFragment" />
|
app:destination="@id/searchFragment" />
|
||||||
<argument
|
<argument
|
||||||
android:name="session_id"
|
android:name="external_session_id"
|
||||||
app:argType="string"
|
app:argType="string"
|
||||||
app:nullable="true" />
|
app:nullable="true" />
|
||||||
<action
|
<action
|
||||||
|
@ -267,12 +267,6 @@
|
||||||
android:label="AboutFragment" />
|
android:label="AboutFragment" />
|
||||||
<fragment android:id="@+id/crashReporterFragment" android:name="org.mozilla.fenix.crashes.CrashReporterFragment"
|
<fragment android:id="@+id/crashReporterFragment" android:name="org.mozilla.fenix.crashes.CrashReporterFragment"
|
||||||
android:label="CrashReporterFragment">
|
android:label="CrashReporterFragment">
|
||||||
<action
|
|
||||||
android:id="@+id/action_crashReporterFragment_to_browserFragment"
|
|
||||||
app:destination="@id/browserFragment"
|
|
||||||
app:popUpTo="@id/homeFragment">
|
|
||||||
<argument android:name="session_id" app:argType="string" app:nullable="true"/>
|
|
||||||
</action>
|
|
||||||
<action android:id="@+id/action_crashReporterFragment_to_homeFragment" app:destination="@id/homeFragment"/>
|
<action android:id="@+id/action_crashReporterFragment_to_homeFragment" app:destination="@id/homeFragment"/>
|
||||||
<argument android:name="crashIntent" app:argType="android.content.Intent"/>
|
<argument android:name="crashIntent" app:argType="android.content.Intent"/>
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
Loading…
Reference in New Issue