Verified Commit f7375e03 authored by Matthew Finkel's avatar Matthew Finkel Committed by boklm
Browse files

Bug 40005: Modify Default toolbar menu

parent a93fecbb
......@@ -9,7 +9,6 @@ import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import mozilla.components.browser.menu.item.BackPressMenuItem
import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuImageText
import mozilla.components.browser.menu.item.NO_ID
import mozilla.components.browser.menu.item.ParentBrowserMenuItem
import mozilla.components.browser.menu.item.WebExtensionPlaceholderMenuItem
......@@ -68,20 +67,10 @@ class WebExtensionBrowserMenuBuilder(
iconTintColorResource = style.webExtIconTintColorResource
)
val addonsManagerMenuItem = BrowserMenuImageText(
label = context.getString(R.string.mozac_browser_menu_addons_manager),
imageResource = style.addonsManagerMenuItemDrawableRes,
iconTintColorResource = style.webExtIconTintColorResource
) {
onAddonsManagerTapped.invoke()
}
val webExtSubMenuItems = if (appendExtensionSubMenuAtStart) {
listOf(backPressMenuItem) + BrowserMenuDivider() +
filteredExtensionMenuItems +
BrowserMenuDivider() + addonsManagerMenuItem
filteredExtensionMenuItems
} else {
listOf(addonsManagerMenuItem) + BrowserMenuDivider() +
filteredExtensionMenuItems +
BrowserMenuDivider() + backPressMenuItem
}
......@@ -97,13 +86,7 @@ class WebExtensionBrowserMenuBuilder(
endOfMenuAlwaysVisible = endOfMenuAlwaysVisible
)
} else {
BrowserMenuImageText(
label = context.getString(R.string.mozac_browser_menu_addons),
imageResource = style.addonsManagerMenuItemDrawableRes,
iconTintColorResource = style.webExtIconTintColorResource
) {
onAddonsManagerTapped.invoke()
}
null
}
val mainMenuIndex = finalList.indexOfFirst { browserMenuItem ->
......@@ -111,12 +94,14 @@ class WebExtensionBrowserMenuBuilder(
WebExtensionPlaceholderMenuItem.MAIN_EXTENSIONS_MENU_ID
}
val menuItems = if (mainMenuIndex != -1) {
val menuItems = if (mainMenuIndex != -1 && webExtMenuItem != null) {
finalList[mainMenuIndex] = webExtMenuItem
finalList
// if we do not have a placeholder we should add the extension submenu at top or bottom
} else {
if (appendExtensionSubMenuAtStart) {
if (webExtMenuItem == null) {
finalList
} else if (appendExtensionSubMenuAtStart) {
listOf(webExtMenuItem) + finalList
} else {
finalList + webExtMenuItem
......
Supports Markdown
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