2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/3523 Add Firefox Sync error states also to Settings in Home menu

This commit is contained in:
mcarare 2019-11-04 12:15:37 +02:00 committed by Emily Kager
parent e75264272f
commit 5285283d76

View File

@ -11,6 +11,7 @@ import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
import mozilla.components.browser.menu.item.BrowserMenuImageText import mozilla.components.browser.menu.item.BrowserMenuImageText
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
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
@ -31,17 +32,24 @@ class HomeMenu(
val menuBuilder by lazy { BrowserMenuBuilder(menuItems) } val menuBuilder by lazy { BrowserMenuBuilder(menuItems) }
private val hasAccountProblem = context.components.backgroundServices.accountManager.accountNeedsReauth()
private val primaryTextColor =
ThemeManager.resolveAttribute(R.attr.primaryText, context)
private val menuCategoryTextColor =
ThemeManager.resolveAttribute(R.attr.menuCategoryText, context)
private val menuItems by lazy { private val menuItems by lazy {
val items = mutableListOf( val items = mutableListOf(
BrowserMenuCategory( BrowserMenuCategory(
context.getString(R.string.browser_menu_your_library), context.getString(R.string.browser_menu_your_library),
textColorResource = ThemeManager.resolveAttribute(R.attr.menuCategoryText, context) textColorResource = menuCategoryTextColor
), ),
BrowserMenuImageText( BrowserMenuImageText(
context.getString(R.string.library_bookmarks), context.getString(R.string.library_bookmarks),
R.drawable.ic_bookmark_outline, R.drawable.ic_bookmark_outline,
ThemeManager.resolveAttribute(R.attr.primaryText, context) primaryTextColor
) { ) {
onItemTapped.invoke(Item.Bookmarks) onItemTapped.invoke(Item.Bookmarks)
}, },
@ -49,17 +57,29 @@ class HomeMenu(
BrowserMenuImageText( BrowserMenuImageText(
context.getString(R.string.library_history), context.getString(R.string.library_history),
R.drawable.ic_history, R.drawable.ic_history,
ThemeManager.resolveAttribute(R.attr.primaryText, context) primaryTextColor
) { ) {
onItemTapped.invoke(Item.History) onItemTapped.invoke(Item.History)
}, },
BrowserMenuDivider(), BrowserMenuDivider(),
BrowserMenuImageText( BrowserMenuHighlightableItem(
context.getString(R.string.browser_menu_settings), label = context.getString(R.string.browser_menu_settings),
R.drawable.ic_settings, imageResource = R.drawable.ic_settings,
ThemeManager.resolveAttribute(R.attr.primaryText, context) iconTintColorResource =
if (hasAccountProblem) R.color.sync_error_text_color else primaryTextColor,
textColorResource =
if (hasAccountProblem) R.color.sync_error_text_color else primaryTextColor,
highlight = if (hasAccountProblem) {
BrowserMenuHighlightableItem.Highlight(
endImageResource = R.drawable.ic_alert,
backgroundResource = R.drawable.sync_error_background_with_ripple,
colorResource = R.color.sync_error_background_color
)
} else null
) { ) {
onItemTapped.invoke(Item.Settings) onItemTapped.invoke(Item.Settings)
}, },
@ -83,19 +103,19 @@ class HomeMenu(
BrowserMenuImageText( BrowserMenuImageText(
context.getString(R.string.browser_menu_help), context.getString(R.string.browser_menu_help),
R.drawable.ic_help, R.drawable.ic_help,
ThemeManager.resolveAttribute(R.attr.primaryText, context) primaryTextColor
) { ) {
onItemTapped.invoke(Item.Help) onItemTapped.invoke(Item.Help)
} }
) )
if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) { if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) {
items.add( items.add(
BrowserMenuImageText( BrowserMenuImageText(
context.getString(R.string.delete_browsing_data_on_quit_action), context.getString(R.string.delete_browsing_data_on_quit_action),
R.drawable.ic_exit, R.drawable.ic_exit,
ThemeManager.resolveAttribute(R.attr.primaryText, context) primaryTextColor
) { ) {
onItemTapped.invoke(Item.Quit) onItemTapped.invoke(Item.Quit)
} }