1
0
Fork 0

For #7352: integrate highlightable browser menu changes (#7353)

* For #7352: integrate highlightable browser menu changes

* For 7352: invalidate menu when reader mode availability changes

* For 7352: removed highlight from reader mode appearance per UX
master
Severin Rudie 2019-12-27 12:15:21 -08:00 committed by GitHub
parent e22d092f5d
commit 26b7909214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -14,6 +14,7 @@ import mozilla.components.browser.menu.BrowserMenuBuilder
import mozilla.components.browser.menu.BrowserMenuHighlight
import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
import mozilla.components.browser.menu.item.BrowserMenuHighlightableSwitch
import mozilla.components.browser.menu.item.BrowserMenuImageSwitch
import mozilla.components.browser.menu.item.BrowserMenuImageText
import mozilla.components.browser.menu.item.BrowserMenuItemToolbar
@ -277,10 +278,15 @@ class DefaultToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.Quit)
}
private val readerMode = BrowserMenuImageSwitch(
private val readerMode = BrowserMenuHighlightableSwitch(
label = context.getString(R.string.browser_menu_read),
imageResource = R.drawable.ic_readermode,
initialState = readerModeStateProvider
startImageResource = R.drawable.ic_readermode,
initialState = readerModeStateProvider,
highlight = BrowserMenuHighlight.LowPriority(
label = context.getString(R.string.browser_menu_read),
notificationTint = getColor(context, R.color.whats_new_notification_color)
),
isHighlighted = { true }
) { checked ->
onItemTapped.invoke(ToolbarMenu.Item.ReaderMode(checked))
}
@ -293,10 +299,15 @@ class DefaultToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.ReaderModeAppearance)
}
private val openInApp = BrowserMenuImageText(
private val openInApp = BrowserMenuHighlightableItem(
label = context.getString(R.string.browser_menu_open_app_link),
imageResource = R.drawable.ic_app_links,
iconTintColorResource = primaryTextColor()
startImageResource = R.drawable.ic_app_links,
iconTintColorResource = primaryTextColor(),
highlight = BrowserMenuHighlight.LowPriority(
label = context.getString(R.string.browser_menu_open_app_link),
notificationTint = getColor(context, R.color.whats_new_notification_color)
),
isHighlighted = { true }
) {
onItemTapped.invoke(ToolbarMenu.Item.OpenInApp)
}

View File

@ -34,4 +34,8 @@ class MenuPresenter(
override fun onWebAppManifestChanged(session: Session, manifest: WebAppManifest?) {
menuToolbar.invalidateActions()
}
override fun onReaderableStateUpdated(session: Session, readerable: Boolean) {
menuToolbar.invalidateActions()
}
}