For #15324 - Show tab settings and recently closed items in menu when no tabs

pull/184/head
ekager 4 years ago
parent e49cd9c558
commit 01e802fef0

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

@ -89,7 +89,8 @@ class TabTrayView(
private var tabsTouchHelper: TabsTouchHelper
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 var hasLoaded = false
@ -211,7 +212,10 @@ class TabTrayView(
}
tabTrayItemMenu =
TabTrayItemMenu(view.context, { view.tab_layout.selectedTabPosition == 0 }) {
TabTrayItemMenu(
view.context,
{ tabs.isNotEmpty() && view.tab_layout.selectedTabPosition == 0 },
{ tabs.isNotEmpty() }) {
when (it) {
is TabTrayItemMenu.Item.ShareAllTabs -> interactor.onShareTabsClicked(
isPrivateModeSelected
@ -431,7 +435,6 @@ class TabTrayView(
} else {
View.VISIBLE
}
view.tab_tray_overflow.isVisible = !hasNoTabs
counter_text.text = updateTabCounter(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 also add 1 to display the tab item above the selected browser tab.
val recyclerViewIndex = selectedBrowserTabIndex +
collectionsButtonAdapter.itemCount +
syncedTabsController.adapter.itemCount +
1
collectionsButtonAdapter.itemCount +
syncedTabsController.adapter.itemCount +
1
layoutManager?.scrollToPosition(recyclerViewIndex)
}
@ -614,6 +617,7 @@ class TabTrayView(
class TabTrayItemMenu(
private val context: Context,
private val shouldShowSaveToCollection: () -> Boolean,
private val hasOpenTabs: () -> Boolean,
private val onItemTapped: (Item) -> Unit = {}
) {
@ -643,7 +647,7 @@ class TabTrayItemMenu(
) {
context.components.analytics.metrics.track(Event.TabsTrayShareAllTabsPressed)
onItemTapped.invoke(Item.ShareAllTabs)
},
}.apply { visible = hasOpenTabs },
SimpleBrowserMenuItem(
context.getString(R.string.tab_tray_menu_tab_settings),
@ -665,7 +669,7 @@ class TabTrayItemMenu(
) {
context.components.analytics.metrics.track(Event.TabsTrayCloseAllTabsPressed)
onItemTapped.invoke(Item.CloseAllTabs)
}
}.apply { visible = hasOpenTabs }
)
}
}

Loading…
Cancel
Save