Commit 2ffbecae authored by mcarare's avatar mcarare Committed by Emily Kager
Browse files

For #8474 Reorganize browser menu items

parent ce4293c8
......@@ -26,7 +26,6 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.browser.BrowserAnimator
import org.mozilla.fenix.browser.BrowserFragment
import org.mozilla.fenix.browser.BrowserFragmentDirections
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager
import org.mozilla.fenix.browser.readermode.ReaderModeController
import org.mozilla.fenix.collections.SaveCollectionStep
......@@ -183,24 +182,7 @@ class DefaultBrowserToolbarController(
)
navController.navigate(directions)
}
ToolbarMenu.Item.NewTab -> {
val directions = BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
sessionId = null
)
// Do not adjustBackground here or an exception gets thrown as we switch themes
navController.nav(R.id.browserFragment, directions)
browsingModeManager.mode = BrowsingMode.Normal
}
ToolbarMenu.Item.NewPrivateTab -> {
val directions = BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
sessionId = null
)
// Do not adjustBackground here or an exception gets thrown as we switch themes
navController.nav(R.id.browserFragment, directions)
browsingModeManager.mode = BrowsingMode.Private
}
ToolbarMenu.Item.FindInPage -> {
findInPageLauncher()
activity.components.analytics.metrics.track(Event.FindInPageOpened)
......@@ -212,9 +194,7 @@ class DefaultBrowserToolbarController(
activity.components.useCases.tabsUseCases.addTab.invoke(reportUrl)
}
}
ToolbarMenu.Item.Help -> {
activity.components.useCases.tabsUseCases.addTab.invoke(getSupportUrl())
}
ToolbarMenu.Item.AddonsManager -> {
navController.nav(
R.id.browserFragment,
......@@ -331,11 +311,8 @@ class DefaultBrowserToolbarController(
Event.BrowserMenuItemTapped.Item.DESKTOP_VIEW_OFF
}
ToolbarMenu.Item.NewPrivateTab -> Event.BrowserMenuItemTapped.Item.NEW_PRIVATE_TAB
ToolbarMenu.Item.FindInPage -> Event.BrowserMenuItemTapped.Item.FIND_IN_PAGE
ToolbarMenu.Item.ReportIssue -> Event.BrowserMenuItemTapped.Item.REPORT_SITE_ISSUE
ToolbarMenu.Item.Help -> Event.BrowserMenuItemTapped.Item.HELP
ToolbarMenu.Item.NewTab -> Event.BrowserMenuItemTapped.Item.NEW_TAB
ToolbarMenu.Item.OpenInFenix -> Event.BrowserMenuItemTapped.Item.OPEN_IN_FENIX
ToolbarMenu.Item.Share -> Event.BrowserMenuItemTapped.Item.SHARE
ToolbarMenu.Item.SaveToCollection -> Event.BrowserMenuItemTapped.Item.SAVE_TO_COLLECTION
......
......@@ -128,7 +128,7 @@ class DefaultToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.Bookmark)
}
BrowserMenuItemToolbar(listOf(forward, bookmark, share, refresh))
BrowserMenuItemToolbar(listOf(bookmark, share, forward, refresh))
}
private val menuItems by lazy {
......@@ -153,22 +153,20 @@ class DefaultToolbarMenu(
fun shouldShowReaderAppearance(): Boolean = session?.readerMode ?: false
val menuItems = listOfNotNull(
help,
settings,
library,
desktopMode,
addToTopSites,
addToHomescreen.apply { visible = ::shouldShowAddToHomescreen },
addons,
findInPage,
privateTab,
newTab,
settings,
if (shouldDeleteDataOnQuit) deleteDataOnQuit else null,
BrowserMenuDivider(),
if (shouldShowWebcompatReporter) reportIssue else null,
findInPage,
addToTopSites,
addToHomescreen.apply { visible = ::shouldShowAddToHomescreen },
if (shouldShowSaveToCollection) saveToCollection else null,
if (shouldDeleteDataOnQuit) deleteDataOnQuit else null,
desktopMode,
openInApp.apply { visible = ::shouldShowOpenInApp },
readerMode.apply { visible = ::shouldShowReaderMode },
readerAppearance.apply { visible = ::shouldShowReaderAppearance },
openInApp.apply { visible = ::shouldShowOpenInApp },
BrowserMenuDivider(),
menuToolbar
)
......@@ -184,14 +182,6 @@ class DefaultToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.AddonsManager)
}
private val help = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_help),
imageResource = R.drawable.ic_help,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.Help)
}
private val settings = BrowserMenuHighlightableItem(
label = context.getString(R.string.browser_menu_settings),
startImageResource = R.drawable.ic_settings,
......@@ -260,22 +250,6 @@ class DefaultToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.FindInPage)
}
private val privateTab = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_private_tab),
imageResource = R.drawable.ic_private_browsing,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.NewPrivateTab)
}
private val newTab = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_new_tab),
imageResource = R.drawable.ic_new,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.NewTab)
}
private val reportIssue = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_report_issue),
imageResource = R.drawable.ic_report_issues,
......
......@@ -9,13 +9,10 @@ import mozilla.components.browser.menu.item.BrowserMenuItemToolbar
interface ToolbarMenu {
sealed class Item {
object Help : Item()
object Settings : Item()
object Library : Item()
data class RequestDesktop(val isChecked: Boolean) : Item()
object FindInPage : Item()
object NewPrivateTab : Item()
object NewTab : Item()
object Share : Item()
object Back : Item()
object Forward : Item()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment