1
0
Fork 0

For #9365: Partially reverse menu items order when using top toolbar

master
mcarare 2020-04-01 13:43:35 +03:00 committed by Jeff Boek
parent b119700820
commit 8c398c86ef
1 changed files with 40 additions and 17 deletions

View File

@ -21,6 +21,7 @@ import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.support.ktx.android.content.getColorFromAttr import mozilla.components.support.ktx.android.content.getColorFromAttr
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.theme.ThemeManager import org.mozilla.fenix.theme.ThemeManager
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
import org.mozilla.fenix.whatsnew.WhatsNew import org.mozilla.fenix.whatsnew.WhatsNew
@ -50,6 +51,7 @@ class HomeMenu(
private val menuCategoryTextColor = private val menuCategoryTextColor =
ThemeManager.resolveAttribute(R.attr.menuCategoryText, context) ThemeManager.resolveAttribute(R.attr.menuCategoryText, context)
private val shouldUseBottomToolbar = context.settings().shouldUseBottomToolbar
// 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary. // 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary.
private val reconnectToSyncItem by lazy { private val reconnectToSyncItem by lazy {
@ -102,7 +104,8 @@ class HomeMenu(
val historyItem = BrowserMenuImageText( val historyItem = BrowserMenuImageText(
context.getString(R.string.library_history), context.getString(R.string.library_history),
R.drawable.ic_history, R.drawable.ic_history,
primaryTextColor) { primaryTextColor
) {
onItemTapped.invoke(Item.History) onItemTapped.invoke(Item.History)
} }
@ -130,22 +133,42 @@ class HomeMenu(
null null
} }
listOfNotNull( if (shouldUseBottomToolbar) {
accountAuthItem, listOfNotNull(
whatsNewItem, accountAuthItem,
BrowserMenuDivider(), whatsNewItem,
BrowserMenuCategory( BrowserMenuDivider(),
context.getString(R.string.browser_menu_library), BrowserMenuCategory(
textColorResource = menuCategoryTextColor context.getString(R.string.browser_menu_library),
), textColorResource = menuCategoryTextColor
bookmarksItem, ),
historyItem, bookmarksItem,
BrowserMenuDivider(), historyItem,
settingsItem, BrowserMenuDivider(),
helpItem, settingsItem,
if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) quitItem else null helpItem,
).also { items -> if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) quitItem else null
items.getHighlight()?.let { onHighlightPresent(it) } ).also { items ->
items.getHighlight()?.let { onHighlightPresent(it) }
}
} else {
listOfNotNull(
if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) quitItem else null,
helpItem,
settingsItem,
accountAuthItem,
BrowserMenuDivider(),
BrowserMenuCategory(
context.getString(R.string.browser_menu_library),
textColorResource = menuCategoryTextColor
),
bookmarksItem,
historyItem,
BrowserMenuDivider(),
whatsNewItem
).also { items ->
items.getHighlight()?.let { onHighlightPresent(it) }
}
} }
} }