2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/15324 - Show tab settings and recently closed items in menu when no tabs

This commit is contained in:
ekager 2020-09-28 12:05:27 -07:00
parent 8caf149ab7
commit 1429c5ddaf
2 changed files with 14 additions and 10 deletions

View File

@ -262,11 +262,11 @@ class TabbedBrowsingTest {
}.openTabTray { }.openTabTray {
verifyNoTabsOpened() verifyNoTabsOpened()
verifyNewTabButton() verifyNewTabButton()
verifyTabTrayOverflowMenu(false) verifyTabTrayOverflowMenu(true)
}.toggleToPrivateTabs { }.toggleToPrivateTabs {
verifyNoTabsOpened() verifyNoTabsOpened()
verifyNewTabButton() verifyNewTabButton()
verifyTabTrayOverflowMenu(false) verifyTabTrayOverflowMenu(true)
} }
} }

View File

@ -89,7 +89,8 @@ class TabTrayView(
private var tabsTouchHelper: TabsTouchHelper private var tabsTouchHelper: TabsTouchHelper
private val collectionsButtonAdapter = SaveToCollectionsButtonAdapter(interactor, isPrivate) private val collectionsButtonAdapter = SaveToCollectionsButtonAdapter(interactor, isPrivate)
private val syncedTabsController = SyncedTabsController(lifecycleOwner, view, store, concatAdapter) private val syncedTabsController =
SyncedTabsController(lifecycleOwner, view, store, concatAdapter)
private val syncedTabsFeature = ViewBoundFeatureWrapper<SyncedTabsFeature>() private val syncedTabsFeature = ViewBoundFeatureWrapper<SyncedTabsFeature>()
private var hasLoaded = false private var hasLoaded = false
@ -211,7 +212,10 @@ class TabTrayView(
} }
tabTrayItemMenu = tabTrayItemMenu =
TabTrayItemMenu(view.context, { view.tab_layout.selectedTabPosition == 0 }) { TabTrayItemMenu(
view.context,
{ tabs.isNotEmpty() && view.tab_layout.selectedTabPosition == 0 },
{ tabs.isNotEmpty() }) {
when (it) { when (it) {
is TabTrayItemMenu.Item.ShareAllTabs -> interactor.onShareTabsClicked( is TabTrayItemMenu.Item.ShareAllTabs -> interactor.onShareTabsClicked(
isPrivateModeSelected isPrivateModeSelected
@ -431,7 +435,6 @@ class TabTrayView(
} else { } else {
View.VISIBLE View.VISIBLE
} }
view.tab_tray_overflow.isVisible = !hasNoTabs
counter_text.text = updateTabCounter(browserState.normalTabs.size) counter_text.text = updateTabCounter(browserState.normalTabs.size)
updateTabCounterContentDescription(browserState.normalTabs.size) updateTabCounterContentDescription(browserState.normalTabs.size)
@ -592,9 +595,9 @@ class TabTrayView(
// We add the offset, because the layoutManager is initialized with `reverseLayout`. // We add the offset, because the layoutManager is initialized with `reverseLayout`.
// We also add 1 to display the tab item above the selected browser tab. // We also add 1 to display the tab item above the selected browser tab.
val recyclerViewIndex = selectedBrowserTabIndex + val recyclerViewIndex = selectedBrowserTabIndex +
collectionsButtonAdapter.itemCount + collectionsButtonAdapter.itemCount +
syncedTabsController.adapter.itemCount + syncedTabsController.adapter.itemCount +
1 1
layoutManager?.scrollToPosition(recyclerViewIndex) layoutManager?.scrollToPosition(recyclerViewIndex)
} }
@ -614,6 +617,7 @@ class TabTrayView(
class TabTrayItemMenu( class TabTrayItemMenu(
private val context: Context, private val context: Context,
private val shouldShowSaveToCollection: () -> Boolean, private val shouldShowSaveToCollection: () -> Boolean,
private val hasOpenTabs: () -> Boolean,
private val onItemTapped: (Item) -> Unit = {} private val onItemTapped: (Item) -> Unit = {}
) { ) {
@ -643,7 +647,7 @@ class TabTrayItemMenu(
) { ) {
context.components.analytics.metrics.track(Event.TabsTrayShareAllTabsPressed) context.components.analytics.metrics.track(Event.TabsTrayShareAllTabsPressed)
onItemTapped.invoke(Item.ShareAllTabs) onItemTapped.invoke(Item.ShareAllTabs)
}, }.apply { visible = hasOpenTabs },
SimpleBrowserMenuItem( SimpleBrowserMenuItem(
context.getString(R.string.tab_tray_menu_tab_settings), context.getString(R.string.tab_tray_menu_tab_settings),
@ -665,7 +669,7 @@ class TabTrayItemMenu(
) { ) {
context.components.analytics.metrics.track(Event.TabsTrayCloseAllTabsPressed) context.components.analytics.metrics.track(Event.TabsTrayCloseAllTabsPressed)
onItemTapped.invoke(Item.CloseAllTabs) onItemTapped.invoke(Item.CloseAllTabs)
} }.apply { visible = hasOpenTabs }
) )
} }
} }