For #10504 - Removes "old" TabTrayFragment
parent
c32904a1d0
commit
601aedda46
|
@ -17,7 +17,6 @@ enum class BrowserDirection(@IdRes val fragmentId: Int) {
|
||||||
FromGlobal(0),
|
FromGlobal(0),
|
||||||
FromHome(R.id.homeFragment),
|
FromHome(R.id.homeFragment),
|
||||||
FromSearch(R.id.searchFragment),
|
FromSearch(R.id.searchFragment),
|
||||||
FromTabTray(R.id.tabTrayFragment),
|
|
||||||
FromSettings(R.id.settingsFragment),
|
FromSettings(R.id.settingsFragment),
|
||||||
FromBookmarks(R.id.bookmarkFragment),
|
FromBookmarks(R.id.bookmarkFragment),
|
||||||
FromHistory(R.id.historyFragment),
|
FromHistory(R.id.historyFragment),
|
||||||
|
|
|
@ -80,7 +80,6 @@ import org.mozilla.fenix.utils.RunWhenReadyQueue
|
||||||
import mozilla.components.concept.tabstray.TabsTray
|
import mozilla.components.concept.tabstray.TabsTray
|
||||||
import mozilla.components.browser.tabstray.TabsAdapter
|
import mozilla.components.browser.tabstray.TabsAdapter
|
||||||
import mozilla.components.browser.tabstray.BrowserTabsTray
|
import mozilla.components.browser.tabstray.BrowserTabsTray
|
||||||
import org.mozilla.fenix.tabtray.TabTrayFragmentDirections
|
|
||||||
import org.mozilla.fenix.tabtray.TabTrayViewHolder
|
import org.mozilla.fenix.tabtray.TabTrayViewHolder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -368,8 +367,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
||||||
HomeFragmentDirections.actionHomeFragmentToBrowserFragment(customTabSessionId, true)
|
HomeFragmentDirections.actionHomeFragmentToBrowserFragment(customTabSessionId, true)
|
||||||
BrowserDirection.FromSearch ->
|
BrowserDirection.FromSearch ->
|
||||||
SearchFragmentDirections.actionGlobalBrowser(customTabSessionId)
|
SearchFragmentDirections.actionGlobalBrowser(customTabSessionId)
|
||||||
BrowserDirection.FromTabTray ->
|
|
||||||
TabTrayFragmentDirections.actionGlobalBrowser(customTabSessionId)
|
|
||||||
BrowserDirection.FromSettings ->
|
BrowserDirection.FromSettings ->
|
||||||
SettingsFragmentDirections.actionGlobalBrowser(customTabSessionId)
|
SettingsFragmentDirections.actionGlobalBrowser(customTabSessionId)
|
||||||
BrowserDirection.FromBookmarks ->
|
BrowserDirection.FromBookmarks ->
|
||||||
|
|
|
@ -64,7 +64,6 @@ import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||||
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
|
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
|
||||||
import mozilla.components.support.ktx.android.view.hideKeyboard
|
import mozilla.components.support.ktx.android.view.hideKeyboard
|
||||||
import org.mozilla.fenix.BrowserDirection
|
|
||||||
import org.mozilla.fenix.FeatureFlags
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.IntentReceiverActivity
|
import org.mozilla.fenix.IntentReceiverActivity
|
||||||
|
|
|
@ -325,8 +325,6 @@ class DefaultBrowserToolbarController(
|
||||||
|
|
||||||
private fun animateTabAndNavigateHome() {
|
private fun animateTabAndNavigateHome() {
|
||||||
if (activity.settings().useNewTabTray) {
|
if (activity.settings().useNewTabTray) {
|
||||||
// val directions = BrowserFragmentDirections.actionBrowserFragmentToTabsTrayFragment()
|
|
||||||
// navController.navigate(directions)
|
|
||||||
onTabCounterClicked.invoke()
|
onTabCounterClicked.invoke()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@ import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit
|
||||||
import org.mozilla.fenix.tabtray.TabTrayDialogFragment
|
import org.mozilla.fenix.tabtray.TabTrayDialogFragment
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
import org.mozilla.fenix.utils.FragmentPreDrawManager
|
import org.mozilla.fenix.utils.FragmentPreDrawManager
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
import org.mozilla.fenix.utils.allowUndo
|
import org.mozilla.fenix.utils.allowUndo
|
||||||
import org.mozilla.fenix.whatsnew.WhatsNew
|
import org.mozilla.fenix.whatsnew.WhatsNew
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
|
|
@ -73,4 +73,4 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
|
||||||
override fun onTabTrayDismissed() {
|
override fun onTabTrayDismissed() {
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,293 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.tabtray
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import mozilla.components.concept.engine.prompt.ShareData
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import mozilla.components.feature.tabs.tabstray.TabsFeature
|
|
||||||
import kotlinx.android.synthetic.main.fragment_tab_tray.tabsTray
|
|
||||||
import kotlinx.android.synthetic.main.fragment_tab_tray.view.*
|
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
|
||||||
import org.mozilla.fenix.R
|
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import mozilla.components.browser.session.Session
|
|
||||||
import mozilla.components.browser.session.SessionManager
|
|
||||||
import mozilla.components.browser.tabstray.BrowserTabsTray
|
|
||||||
import mozilla.components.concept.tabstray.Tab
|
|
||||||
import mozilla.components.concept.tabstray.TabsTray
|
|
||||||
import org.mozilla.fenix.BrowserDirection
|
|
||||||
import org.mozilla.fenix.HomeActivity
|
|
||||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
|
||||||
import org.mozilla.fenix.collections.SaveCollectionStep
|
|
||||||
import org.mozilla.fenix.ext.components
|
|
||||||
import org.mozilla.fenix.ext.nav
|
|
||||||
import org.mozilla.fenix.ext.sessionsOfType
|
|
||||||
import org.mozilla.fenix.ext.showToolbar
|
|
||||||
import org.mozilla.fenix.utils.allowUndo
|
|
||||||
|
|
||||||
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
|
||||||
class TabTrayFragment : Fragment(R.layout.fragment_tab_tray), TabsTray.Observer, UserInteractionHandler {
|
|
||||||
private var tabsFeature: TabsFeature? = null
|
|
||||||
var tabTrayMenu: Menu? = null
|
|
||||||
|
|
||||||
private val sessionManager: SessionManager
|
|
||||||
get() = requireComponents.core.sessionManager
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
showToolbar(getString(R.string.tab_tray_title))
|
|
||||||
onTabsChanged()
|
|
||||||
|
|
||||||
(tabsTray as? BrowserTabsTray)?.also { tray ->
|
|
||||||
TabsTouchHelper(tray.tabsAdapter).attachToRecyclerView(tray)
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionManager.register(observer = object : SessionManager.Observer {
|
|
||||||
override fun onSessionAdded(session: Session) {
|
|
||||||
onTabsChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSessionRemoved(session: Session) {
|
|
||||||
onTabsChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSessionsRestored() {
|
|
||||||
onTabsChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAllSessionsRemoved() {
|
|
||||||
onTabsChanged()
|
|
||||||
}
|
|
||||||
}, owner = viewLifecycleOwner)
|
|
||||||
|
|
||||||
tabsFeature = TabsFeature(
|
|
||||||
tabsTray,
|
|
||||||
requireComponents.core.store,
|
|
||||||
requireComponents.useCases.tabsUseCases,
|
|
||||||
{ it.content.private == (activity as HomeActivity?)?.browsingModeManager?.mode?.isPrivate },
|
|
||||||
::closeTabsTray)
|
|
||||||
|
|
||||||
view.tab_tray_open_new_tab.setOnClickListener {
|
|
||||||
val directions = TabTrayFragmentDirections.actionGlobalSearch(null)
|
|
||||||
findNavController().navigate(directions)
|
|
||||||
}
|
|
||||||
|
|
||||||
view.tab_tray_go_home.setOnClickListener {
|
|
||||||
val directions = TabTrayFragmentDirections.actionGlobalHome()
|
|
||||||
findNavController().navigate(directions)
|
|
||||||
}
|
|
||||||
|
|
||||||
view.private_browsing_button.setOnClickListener {
|
|
||||||
val newMode = !(activity as HomeActivity).browsingModeManager.mode.isPrivate
|
|
||||||
val invertedMode = BrowsingMode.fromBoolean(newMode)
|
|
||||||
(activity as HomeActivity).browsingModeManager.mode = invertedMode
|
|
||||||
tabsFeature?.filterTabs { tabSessionState ->
|
|
||||||
tabSessionState.content.private == newMode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view.save_to_collection_button.setOnClickListener {
|
|
||||||
saveToCollection()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
onTabsChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.tab_tray_menu, menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
||||||
this.tabTrayMenu = menu
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
return when (item.itemId) {
|
|
||||||
R.id.tab_tray_select_to_save_menu_item -> {
|
|
||||||
saveToCollection()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
R.id.tab_tray_share_menu_item -> {
|
|
||||||
share(getListOfSessions().toList())
|
|
||||||
true
|
|
||||||
}
|
|
||||||
R.id.tab_tray_close_menu_item -> {
|
|
||||||
closeAllTabs()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun closeAllTabs() {
|
|
||||||
val tabs = getListOfSessions()
|
|
||||||
|
|
||||||
val selectedIndex = sessionManager
|
|
||||||
.selectedSession?.let { sessionManager.sessions.indexOf(it) } ?: 0
|
|
||||||
|
|
||||||
val snapshot = tabs
|
|
||||||
.map(sessionManager::createSessionSnapshot)
|
|
||||||
.map { it.copy(engineSession = null, engineSessionState = it.engineSession?.saveState()) }
|
|
||||||
.let { SessionManager.Snapshot(it, selectedIndex) }
|
|
||||||
|
|
||||||
tabs.forEach {
|
|
||||||
sessionManager.remove(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
val isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate
|
|
||||||
val snackbarMessage = if (isPrivate) {
|
|
||||||
getString(R.string.snackbar_private_tabs_closed)
|
|
||||||
} else {
|
|
||||||
getString(R.string.snackbar_tabs_closed)
|
|
||||||
}
|
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.allowUndo(
|
|
||||||
requireView(),
|
|
||||||
snackbarMessage,
|
|
||||||
getString(R.string.snackbar_deleted_undo),
|
|
||||||
{
|
|
||||||
sessionManager.restore(snapshot)
|
|
||||||
},
|
|
||||||
operation = { },
|
|
||||||
anchorView = view?.tab_tray_controls
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun saveToCollection() {
|
|
||||||
val tabs = getListOfSessions()
|
|
||||||
val tabIds = tabs.map { it.id }.toList().toTypedArray()
|
|
||||||
val tabCollectionStorage = (activity as HomeActivity).components.core.tabCollectionStorage
|
|
||||||
val navController = findNavController()
|
|
||||||
|
|
||||||
val step = when {
|
|
||||||
// Show the SelectTabs fragment if there are multiple opened tabs to select which tabs
|
|
||||||
// you want to save to a collection.
|
|
||||||
tabs.size > 1 -> SaveCollectionStep.SelectTabs
|
|
||||||
// If there is an existing tab collection, show the SelectCollection fragment to save
|
|
||||||
// the selected tab to a collection of your choice.
|
|
||||||
tabCollectionStorage.cachedTabCollections.isNotEmpty() -> SaveCollectionStep.SelectCollection
|
|
||||||
// Show the NameCollection fragment to create a new collection for the selected tab.
|
|
||||||
else -> SaveCollectionStep.NameCollection
|
|
||||||
}
|
|
||||||
|
|
||||||
if (navController.currentDestination?.id == R.id.collectionCreationFragment) return
|
|
||||||
|
|
||||||
val directions = TabTrayFragmentDirections.actionTabTrayFragmentToCreateCollectionFragment(
|
|
||||||
tabIds = tabIds,
|
|
||||||
previousFragmentId = R.id.tabTrayFragment,
|
|
||||||
saveCollectionStep = step,
|
|
||||||
selectedTabIds = tabIds
|
|
||||||
)
|
|
||||||
navController.nav(R.id.tabTrayFragment, directions)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
|
|
||||||
tabsTray.register(this)
|
|
||||||
tabsFeature?.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
super.onStop()
|
|
||||||
|
|
||||||
tabsTray.unregister(this)
|
|
||||||
tabsFeature?.stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBackPressed(): Boolean {
|
|
||||||
if (getListOfSessions().isEmpty()) {
|
|
||||||
findNavController().popBackStack(R.id.homeFragment, false)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun closeTabsTray() {
|
|
||||||
activity?.supportFragmentManager?.beginTransaction()?.apply {
|
|
||||||
commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTabClosed(tab: Tab) {
|
|
||||||
val snapshot = sessionManager
|
|
||||||
.findSessionById(tab.id)?.let {
|
|
||||||
sessionManager.createSessionSnapshot(it)
|
|
||||||
} ?: return
|
|
||||||
|
|
||||||
val state = snapshot.engineSession?.saveState()
|
|
||||||
val isSelected = tab.id == requireComponents.core.store.state.selectedTabId ?: false
|
|
||||||
|
|
||||||
val snackbarMessage = if (snapshot.session.private) {
|
|
||||||
getString(R.string.snackbar_private_tab_closed)
|
|
||||||
} else {
|
|
||||||
getString(R.string.snackbar_tab_closed)
|
|
||||||
}
|
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.allowUndo(
|
|
||||||
requireView(),
|
|
||||||
snackbarMessage,
|
|
||||||
getString(R.string.snackbar_deleted_undo),
|
|
||||||
{
|
|
||||||
sessionManager.add(snapshot.session, isSelected, engineSessionState = state)
|
|
||||||
},
|
|
||||||
operation = { },
|
|
||||||
anchorView = view?.tab_tray_controls
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTabSelected(tab: Tab) {
|
|
||||||
(activity as HomeActivity).openToBrowser(BrowserDirection.FromTabTray)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getListOfSessions(): List<Session> {
|
|
||||||
val isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate
|
|
||||||
return sessionManager.sessionsOfType(private = isPrivate)
|
|
||||||
.toList()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun share(tabs: List<Session>) {
|
|
||||||
val data = tabs.map {
|
|
||||||
ShareData(url = it.url, title = it.title)
|
|
||||||
}
|
|
||||||
val directions = TabTrayFragmentDirections.actionGlobalShareFragment(
|
|
||||||
data = data.toTypedArray()
|
|
||||||
)
|
|
||||||
nav(R.id.tabTrayFragment, directions)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onTabsChanged() {
|
|
||||||
val hasNoTabs = getListOfSessions().toList().isEmpty()
|
|
||||||
val isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate
|
|
||||||
|
|
||||||
view?.tab_tray_empty_view?.isVisible = hasNoTabs
|
|
||||||
view?.tabsTray?.asView()?.isVisible = !hasNoTabs
|
|
||||||
view?.save_to_collection_button?.isVisible = !hasNoTabs && !isPrivate
|
|
||||||
|
|
||||||
setHasOptionsMenu(!hasNoTabs)
|
|
||||||
|
|
||||||
if (hasNoTabs) {
|
|
||||||
view?.announceForAccessibility(view?.context?.getString(R.string.no_open_tabs_description))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,9 +10,9 @@ import android.view.ViewGroup
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
|
import kotlinx.android.synthetic.main.component_tabstray.*
|
||||||
import kotlinx.android.synthetic.main.component_tabstray.view.*
|
import kotlinx.android.synthetic.main.component_tabstray.view.*
|
||||||
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
|
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
|
||||||
import kotlinx.android.synthetic.main.fragment_tab_tray.*
|
|
||||||
import mozilla.components.browser.state.state.TabSessionState
|
import mozilla.components.browser.state.state.TabSessionState
|
||||||
import mozilla.components.browser.tabstray.BrowserTabsTray
|
import mozilla.components.browser.tabstray.BrowserTabsTray
|
||||||
import mozilla.components.concept.tabstray.Tab
|
import mozilla.components.concept.tabstray.Tab
|
||||||
|
@ -21,7 +21,6 @@ import mozilla.components.feature.tabs.tabstray.TabsFeature
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
|
|
||||||
|
|
||||||
interface TabTrayInteractor {
|
interface TabTrayInteractor {
|
||||||
fun onTabSelected(tab: Tab)
|
fun onTabSelected(tab: Tab)
|
||||||
fun onNewTabTapped(private: Boolean)
|
fun onNewTabTapped(private: Boolean)
|
||||||
|
@ -48,11 +47,11 @@ class TabTrayView(
|
||||||
get() = container
|
get() = container
|
||||||
|
|
||||||
init {
|
init {
|
||||||
fabView.new_tab_button.compatElevation = 41.0f
|
fabView.new_tab_button.compatElevation = ELEVATION
|
||||||
|
|
||||||
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||||
if (slideOffset > -0.4) {
|
if (slideOffset > SLIDE_OFFSET) {
|
||||||
fabView.new_tab_button.show()
|
fabView.new_tab_button.show()
|
||||||
} else {
|
} else {
|
||||||
fabView.new_tab_button.hide()
|
fabView.new_tab_button.hide()
|
||||||
|
@ -67,9 +66,9 @@ class TabTrayView(
|
||||||
})
|
})
|
||||||
|
|
||||||
val selectedTabIndex = if (!isPrivate) {
|
val selectedTabIndex = if (!isPrivate) {
|
||||||
0
|
DEFAULT_TAB_ID
|
||||||
} else {
|
} else {
|
||||||
1
|
PRIVATE_TAB_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
view.tab_layout.getTabAt(selectedTabIndex)?.also {
|
view.tab_layout.getTabAt(selectedTabIndex)?.also {
|
||||||
|
@ -97,22 +96,12 @@ class TabTrayView(
|
||||||
tabsFeature.start()
|
tabsFeature.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTabClosed(tab: Tab) {}
|
|
||||||
|
|
||||||
override fun onTabSelected(tab: Tab) {
|
override fun onTabSelected(tab: Tab) {
|
||||||
interactor.onTabSelected(tab)
|
interactor.onTabSelected(tab)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTabReselected(tab: TabLayout.Tab?) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTabUnselected(tab: TabLayout.Tab?) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||||
// Todo: We need a better way to determine which tab was selected.
|
// We need a better way to determine which tab was selected.
|
||||||
val filter: (TabSessionState) -> Boolean = when (tab?.position) {
|
val filter: (TabSessionState) -> Boolean = when (tab?.position) {
|
||||||
1 -> { state -> state.content.private }
|
1 -> { state -> state.content.private }
|
||||||
else -> { state -> !state.content.private }
|
else -> { state -> !state.content.private }
|
||||||
|
@ -120,4 +109,15 @@ class TabTrayView(
|
||||||
|
|
||||||
tabsFeature.filterTabs(filter)
|
tabsFeature.filterTabs(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onTabClosed(tab: Tab) { /*noop*/ }
|
||||||
|
override fun onTabReselected(tab: TabLayout.Tab?) { /*noop*/ }
|
||||||
|
override fun onTabUnselected(tab: TabLayout.Tab?) { /*noop*/ }
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val DEFAULT_TAB_ID = 0
|
||||||
|
private const val PRIVATE_TAB_ID = 1
|
||||||
|
private const val SLIDE_OFFSET = 0.4
|
||||||
|
private const val ELEVATION = 41f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
android:contentDescription="@string/open_tabs_menu"
|
android:contentDescription="@string/open_tabs_menu"
|
||||||
app:srcCompat="@drawable/ic_menu"
|
app:srcCompat="@drawable/ic_menu"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/tab_layout"
|
app:layout_constraintTop_toTopOf="@id/tab_layout"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tab_layout"/>
|
app:layout_constraintBottom_toBottomOf="@id/tab_layout"/>
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?tabTrayItemBackground">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tab_tray_empty_view"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/no_open_tabs_description"
|
|
||||||
android:textColor="?secondaryText"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<mozilla.components.concept.tabstray.TabsTray
|
|
||||||
android:id="@+id/tabsTray"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/save_to_collection_button"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/save_to_collection_button"
|
|
||||||
android:id="@+id/save_to_collection_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/bottomBarShadow"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tabsTray" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/bottomBarShadow"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="@color/bottom_bar_shadow"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/tab_tray_controls"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/tab_tray_controls"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="@dimen/browser_toolbar_height"
|
|
||||||
android:background="?tabTrayToolbarBackground"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/private_browsing_button"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginStart="32dp"
|
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="@string/content_description_private_browsing_button"
|
|
||||||
app:srcCompat="@drawable/private_browsing_button"
|
|
||||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/tab_tray_controls"
|
|
||||||
app:layout_constraintDimensionRatio="1.0"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/tab_tray_controls"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/tab_tray_go_home"
|
|
||||||
app:layout_constraintStart_toStartOf="@id/tab_tray_controls" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/tab_tray_go_home"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="@string/tab_tray_menu_home"
|
|
||||||
app:srcCompat="@drawable/ic_home"
|
|
||||||
app:layout_constraintDimensionRatio="1.0"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/tab_tray_controls"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/tab_tray_controls"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/tab_tray_open_new_tab"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/private_browsing_button" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/tab_tray_open_new_tab"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
|
||||||
android:contentDescription="@string/tab_tray_menu_open_new_tab"
|
|
||||||
app:srcCompat="@drawable/ic_new"
|
|
||||||
app:layout_constraintDimensionRatio="1.0"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/tab_tray_controls"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/tab_tray_controls"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/tab_tray_controls"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/tab_tray_go_home" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
|
@ -49,17 +49,6 @@
|
||||||
<action android:id="@+id/action_global_accountSettingsFragment" app:destination="@id/accountSettingsFragment" />
|
<action android:id="@+id/action_global_accountSettingsFragment" app:destination="@id/accountSettingsFragment" />
|
||||||
<action android:id="@+id/action_global_trackingProtectionPanelDialogFragment" app:destination="@id/trackingProtectionPanelDialogFragment" />
|
<action android:id="@+id/action_global_trackingProtectionPanelDialogFragment" app:destination="@id/trackingProtectionPanelDialogFragment" />
|
||||||
<action android:id="@+id/action_global_quickSettingsSheetDialogFragment" app:destination="@id/quickSettingsSheetDialogFragment"/>
|
<action android:id="@+id/action_global_quickSettingsSheetDialogFragment" app:destination="@id/quickSettingsSheetDialogFragment"/>
|
||||||
<action android:id="@+id/action_global_tabTrayFragment" app:destination="@id/tabTrayFragment"/>
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/tabTrayFragment"
|
|
||||||
android:name="org.mozilla.fenix.tabtray.TabTrayFragment">
|
|
||||||
<action
|
|
||||||
android:id="@+id/action_tabTrayFragment_to_createCollectionFragment"
|
|
||||||
app:destination="@+id/collectionCreationFragment"
|
|
||||||
app:exitAnim="@anim/fade_out"
|
|
||||||
app:popEnterAnim="@anim/fade_in" />
|
|
||||||
</fragment>
|
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/homeFragment"
|
android:id="@+id/homeFragment"
|
||||||
|
|
|
@ -114,7 +114,8 @@ class DefaultBrowserToolbarControllerTest {
|
||||||
bookmarkTapped = mockk(),
|
bookmarkTapped = mockk(),
|
||||||
readerModeController = readerModeController,
|
readerModeController = readerModeController,
|
||||||
sessionManager = mockk(),
|
sessionManager = mockk(),
|
||||||
sharedViewModel = mockk()
|
sharedViewModel = mockk(),
|
||||||
|
onTabCounterClicked = { }
|
||||||
)
|
)
|
||||||
|
|
||||||
mockkStatic(
|
mockkStatic(
|
||||||
|
@ -207,7 +208,8 @@ class DefaultBrowserToolbarControllerTest {
|
||||||
bookmarkTapped = mockk(),
|
bookmarkTapped = mockk(),
|
||||||
readerModeController = mockk(),
|
readerModeController = mockk(),
|
||||||
sessionManager = mockk(),
|
sessionManager = mockk(),
|
||||||
sharedViewModel = mockk()
|
sharedViewModel = mockk(),
|
||||||
|
onTabCounterClicked = { }
|
||||||
)
|
)
|
||||||
|
|
||||||
controller.handleBrowserMenuDismissed(itemList)
|
controller.handleBrowserMenuDismissed(itemList)
|
||||||
|
@ -370,7 +372,8 @@ class DefaultBrowserToolbarControllerTest {
|
||||||
bookmarkTapped = mockk(),
|
bookmarkTapped = mockk(),
|
||||||
readerModeController = mockk(),
|
readerModeController = mockk(),
|
||||||
sessionManager = mockk(),
|
sessionManager = mockk(),
|
||||||
sharedViewModel = mockk()
|
sharedViewModel = mockk(),
|
||||||
|
onTabCounterClicked = { }
|
||||||
)
|
)
|
||||||
controller.ioScope = this
|
controller.ioScope = this
|
||||||
|
|
||||||
|
@ -574,7 +577,8 @@ class DefaultBrowserToolbarControllerTest {
|
||||||
bookmarkTapped = mockk(),
|
bookmarkTapped = mockk(),
|
||||||
readerModeController = mockk(),
|
readerModeController = mockk(),
|
||||||
sessionManager = mockk(),
|
sessionManager = mockk(),
|
||||||
sharedViewModel = mockk()
|
sharedViewModel = mockk(),
|
||||||
|
onTabCounterClicked = { }
|
||||||
)
|
)
|
||||||
|
|
||||||
val sessionManager: SessionManager = mockk(relaxed = true)
|
val sessionManager: SessionManager = mockk(relaxed = true)
|
||||||
|
@ -613,7 +617,8 @@ class DefaultBrowserToolbarControllerTest {
|
||||||
bookmarkTapped = mockk(),
|
bookmarkTapped = mockk(),
|
||||||
readerModeController = mockk(),
|
readerModeController = mockk(),
|
||||||
sessionManager = mockk(),
|
sessionManager = mockk(),
|
||||||
sharedViewModel = mockk()
|
sharedViewModel = mockk(),
|
||||||
|
onTabCounterClicked = { }
|
||||||
)
|
)
|
||||||
|
|
||||||
controller.handleToolbarItemInteraction(item)
|
controller.handleToolbarItemInteraction(item)
|
||||||
|
|
Loading…
Reference in New Issue