|
|
|
@ -35,16 +35,9 @@ import mozilla.components.support.utils.SafeIntent
|
|
|
|
|
import org.mozilla.fenix.components.FenixSnackbar
|
|
|
|
|
import org.mozilla.fenix.components.isSentryEnabled
|
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
|
import org.mozilla.fenix.exceptions.ExceptionsFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
import org.mozilla.fenix.ext.getRootView
|
|
|
|
|
import org.mozilla.fenix.ext.nav
|
|
|
|
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.library.bookmarks.selectfolder.SelectBookmarkFolderFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.search.SearchFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.settings.SettingsFragmentDirections
|
|
|
|
|
import org.mozilla.fenix.share.ShareFragment
|
|
|
|
|
import org.mozilla.fenix.utils.Settings
|
|
|
|
|
|
|
|
|
@ -225,7 +218,6 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
|
|
|
|
load(searchTermOrURL, newTab, engine, forceSearch)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Suppress("ComplexMethod")
|
|
|
|
|
fun openToBrowser(from: BrowserDirection, customTabSessionId: String? = null) {
|
|
|
|
|
if (sessionObserver == null)
|
|
|
|
|
sessionObserver = subscribeToSessions()
|
|
|
|
@ -238,52 +230,8 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
|
|
|
|
) return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@IdRes var fragmentId: Int? = null
|
|
|
|
|
val directions = when (from) {
|
|
|
|
|
BrowserDirection.FromGlobal ->
|
|
|
|
|
NavGraphDirections.actionGlobalBrowser(customTabSessionId)
|
|
|
|
|
BrowserDirection.FromHome -> {
|
|
|
|
|
fragmentId = R.id.homeFragment
|
|
|
|
|
HomeFragmentDirections.actionHomeFragmentToBrowserFragment(customTabSessionId)
|
|
|
|
|
}
|
|
|
|
|
BrowserDirection.FromSearch -> {
|
|
|
|
|
fragmentId = R.id.searchFragment
|
|
|
|
|
SearchFragmentDirections.actionSearchFragmentToBrowserFragment(
|
|
|
|
|
customTabSessionId
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
BrowserDirection.FromSettings -> {
|
|
|
|
|
fragmentId = R.id.settingsFragment
|
|
|
|
|
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(
|
|
|
|
|
customTabSessionId
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
BrowserDirection.FromBookmarks -> {
|
|
|
|
|
fragmentId = R.id.bookmarkFragment
|
|
|
|
|
BookmarkFragmentDirections.actionBookmarkFragmentToBrowserFragment(
|
|
|
|
|
customTabSessionId
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
BrowserDirection.FromBookmarksFolderSelect -> {
|
|
|
|
|
fragmentId = R.id.bookmarkSelectFolderFragment
|
|
|
|
|
SelectBookmarkFolderFragmentDirections
|
|
|
|
|
.actionBookmarkSelectFolderFragmentToBrowserFragment(customTabSessionId)
|
|
|
|
|
}
|
|
|
|
|
BrowserDirection.FromHistory -> {
|
|
|
|
|
fragmentId = R.id.historyFragment
|
|
|
|
|
HistoryFragmentDirections.actionHistoryFragmentToBrowserFragment(
|
|
|
|
|
customTabSessionId
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
BrowserDirection.FromExceptions -> {
|
|
|
|
|
fragmentId = R.id.exceptionsFragment
|
|
|
|
|
ExceptionsFragmentDirections.actionExceptionsFragmentToBrowserFragment(
|
|
|
|
|
customTabSessionId
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navHost.navController.nav(fragmentId, directions)
|
|
|
|
|
@IdRes val fragmentId = if (from.fragmentId != 0) from.fragmentId else null
|
|
|
|
|
navHost.navController.nav(fragmentId, NavGraphDirections.actionGlobalBrowser(customTabSessionId))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun load(
|
|
|
|
@ -406,8 +354,3 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
|
|
|
|
const val OPEN_TO_SEARCH = "open_to_search"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum class BrowserDirection {
|
|
|
|
|
FromGlobal, FromHome, FromSearch, FromSettings, FromBookmarks,
|
|
|
|
|
FromBookmarksFolderSelect, FromHistory, FromExceptions
|
|
|
|
|
}
|
|
|
|
|