Sawyer Blatz 5 years ago committed by GitHub
parent de3429789c
commit 418fae40b5

@ -22,6 +22,7 @@ import mozilla.components.browser.icons.IconRequest
import mozilla.components.browser.menu.BrowserMenu import mozilla.components.browser.menu.BrowserMenu
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import org.mozilla.fenix.DefaultThemeManager
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.increaseTapArea import org.mozilla.fenix.ext.increaseTapArea
@ -182,8 +183,13 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
private fun setColorsAndIcons(selected: Boolean, item: BookmarkNode) { private fun setColorsAndIcons(selected: Boolean, item: BookmarkNode) {
val backgroundTint = val backgroundTint =
if (selected) R.color.bookmark_selection_appbar_background else R.color.bookmark_favicon_background if (selected) {
val backgroundTintList = ContextCompat.getColorStateList(containerView!!.context, backgroundTint) DefaultThemeManager.resolveAttribute(R.attr.accent, containerView!!.context)
} else {
DefaultThemeManager.resolveAttribute(R.attr.neutral, containerView!!.context)
}
val backgroundTintList = ContextCompat.getColorStateList(containerView.context, backgroundTint)
bookmark_favicon.backgroundTintList = backgroundTintList bookmark_favicon.backgroundTintList = backgroundTintList
if (selected) bookmark_favicon.setImageResource(R.drawable.mozac_ic_check) if (selected) bookmark_favicon.setImageResource(R.drawable.mozac_ic_check)
@ -249,8 +255,12 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
setMenu(item, containerView!!) setMenu(item, containerView!!)
val backgroundTint = val backgroundTint = if (selected) {
if (selected) R.color.bookmark_selection_appbar_background else R.color.bookmark_favicon_background DefaultThemeManager.resolveAttribute(R.attr.accent, containerView.context)
} else {
DefaultThemeManager.resolveAttribute(R.attr.neutral, containerView.context)
}
val backgroundTintList = ContextCompat.getColorStateList(containerView.context, backgroundTint) val backgroundTintList = ContextCompat.getColorStateList(containerView.context, backgroundTint)
bookmark_favicon.backgroundTintList = backgroundTintList bookmark_favicon.backgroundTintList = backgroundTintList
val res = if (selected) R.drawable.mozac_ic_check else R.drawable.ic_folder_icon val res = if (selected) R.drawable.mozac_ic_check else R.drawable.ic_folder_icon

@ -39,10 +39,11 @@ import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile import mozilla.components.concept.sync.Profile
import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.BackHandler
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.BrowsingModeManager import org.mozilla.fenix.BrowsingModeManager
import org.mozilla.fenix.DefaultThemeManager
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.ext.allowUndo import org.mozilla.fenix.ext.allowUndo
import org.mozilla.fenix.ext.getColorFromAttr import org.mozilla.fenix.ext.getColorFromAttr
@ -95,6 +96,14 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
job.cancel() job.cancel()
// Reset the toolbar color
val toolbar = (activity as AppCompatActivity).findViewById<Toolbar>(R.id.navigationToolbar)
val colorFilter = PorterDuffColorFilter(
R.attr.primaryText.getColorFromAttr(context!!), PorterDuff.Mode.SRC_IN)
themeToolbar(toolbar, DefaultThemeManager.resolveAttribute(R.attr.primaryText, context!!),
DefaultThemeManager.resolveAttribute(R.attr.foundation, context!!), colorFilter)
} }
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -113,8 +122,8 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
} }
is BookmarkState.Mode.Selecting -> { is BookmarkState.Mode.Selecting -> {
inflater.inflate(R.menu.bookmarks_select_multi, menu) inflater.inflate(R.menu.bookmarks_select_multi, menu)
val colorFilter = val colorFilter = PorterDuffColorFilter(
PorterDuffColorFilter(R.attr.primaryText.getColorFromAttr(context!!), PorterDuff.Mode.SRC_IN) ContextCompat.getColor(context!!, R.color.white_color), PorterDuff.Mode.SRC_IN)
val enableEditButton = mode.selectedItems.size == 1 val enableEditButton = mode.selectedItems.size == 1
menu.findItem(R.id.edit_bookmark_multi_select).run { menu.findItem(R.id.edit_bookmark_multi_select).run {
@ -125,17 +134,25 @@ class BookmarkFragment : Fragment(), CoroutineScope, BackHandler, AccountObserve
} }
activity?.title = getString(R.string.bookmarks_multi_select_title, mode.selectedItems.size) activity?.title = getString(R.string.bookmarks_multi_select_title, mode.selectedItems.size)
themeToolbar(toolbar, colorFilter) themeToolbar(toolbar, R.color.white_color,
DefaultThemeManager.resolveAttribute(R.attr.accentBright, context!!), colorFilter)
} }
} }
} }
private fun themeToolbar( private fun themeToolbar(
toolbar: Toolbar, toolbar: Toolbar,
colorFilter: PorterDuffColorFilter textColor: Int,
backgroundColor: Int,
colorFilter: PorterDuffColorFilter? = null
) { ) {
toolbar.setBackgroundColor(ContextCompat.getColor(context!!, R.color.bookmark_multi_select_actionbar)) toolbar.setTitleTextColor(ContextCompat.getColor(context!!, textColor))
toolbar.setTitleTextColor(R.attr.primaryText.getColorFromAttr(context!!)) toolbar.setBackgroundColor(ContextCompat.getColor(context!!, backgroundColor))
if (colorFilter == null) {
return
}
toolbar.overflowIcon?.colorFilter = colorFilter toolbar.overflowIcon?.colorFilter = colorFilter
(0 until toolbar.childCount).forEach { (0 until toolbar.childCount).forEach {
when (val item = toolbar.getChildAt(it)) { when (val item = toolbar.getChildAt(it)) {

@ -15,6 +15,7 @@ import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.support.ktx.android.content.res.pxToDp import mozilla.components.support.ktx.android.content.res.pxToDp
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getColorFromAttr
import org.mozilla.fenix.library.bookmarks.BookmarksSharedViewModel import org.mozilla.fenix.library.bookmarks.BookmarksSharedViewModel
class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedViewModel) : class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedViewModel) :
@ -84,8 +85,13 @@ class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedVi
fun bind(folder: BookmarkNodeWithDepth, selected: Boolean, selectionInterface: SelectionInterface) { fun bind(folder: BookmarkNodeWithDepth, selected: Boolean, selectionInterface: SelectionInterface) {
val backgroundTint = val backgroundTint =
if (selected) R.color.bookmark_selection_appbar_background else R.color.bookmark_favicon_background if (selected) {
val backgroundTintList = ContextCompat.getColorStateList(containerView!!.context, backgroundTint) R.attr.accent.getColorFromAttr(containerView!!.context)
} else {
R.attr.neutral.getColorFromAttr(containerView!!.context)
}
val backgroundTintList = ContextCompat.getColorStateList(containerView.context, backgroundTint)
bookmark_favicon.backgroundTintList = backgroundTintList bookmark_favicon.backgroundTintList = backgroundTintList
val res = if (selected) R.drawable.mozac_ic_check else R.drawable.ic_folder_icon val res = if (selected) R.drawable.mozac_ic_check else R.drawable.ic_folder_icon
bookmark_favicon.setImageResource(res) bookmark_favicon.setImageResource(res)

@ -45,9 +45,6 @@
<!-- Bookmark buttons --> <!-- Bookmark buttons -->
<color name="bookmark_favicon_background">#DFDFE3</color> <color name="bookmark_favicon_background">#DFDFE3</color>
<color name="bookmark_multi_select_actionbar">#592ACB</color>
<color name="bookmark_snackbar_background">#2E0EC1</color>
<color name="bookmark_selection_appbar_background">#2E0EC1</color>
<!-- Session placeholder icons--> <!-- Session placeholder icons-->
<color name="session_placeholder_blue">#00B3F4</color> <color name="session_placeholder_blue">#00B3F4</color>
@ -85,4 +82,5 @@
<!-- Misc colors applied universally--> <!-- Misc colors applied universally-->
<color name="suggestion_highlight_color">#5C592ACB</color> <color name="suggestion_highlight_color">#5C592ACB</color>
<color name="delete_color">@color/photonRed60</color> <color name="delete_color">@color/photonRed60</color>
<color name="white_color">#FBFBFE</color>
</resources> </resources>

Loading…
Cancel
Save