-
Notifications
You must be signed in to change notification settings - Fork 473
Closes #2316: Adds BrowserMenuCaption #2317
Conversation
val item = BrowserMenuCaption("Powered by Mozilla") | ||
assertEquals(R.layout.mozac_browser_menu_item_caption, item.getLayoutResource()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a test to check the text is actually set? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't think there was a way to test this, but I looked at BrowserMenuImageTextTest
for some inspiration. I've added a few more, but please let me know if that's not sufficient!
Codecov Report
@@ Coverage Diff @@
## master #2317 +/- ##
=========================================
Coverage ? 84.52%
Complexity ? 2631
=========================================
Files ? 315
Lines ? 10658
Branches ? 1555
=========================================
Hits ? 9009
Misses ? 997
Partials ? 652
Continue to review full report at Codecov.
|
@sblatz what is the difference between |
@Amejia481 Yes, those are the only differences. I'm happy to add a |
@sblatz we could make the listener optional and only set the click listener when is not null class SimpleBrowserMenuItem(
private val label: String,
@ColorRes
private val textColorResource: Int = NO_ID,
private val listener: (() -> Unit)? = null
) : BrowserMenuItem {
override var visible: () -> Boolean = { true }
override fun getLayoutResource() = R.layout.mozac_browser_menu_item_simple
override fun bind(menu: BrowserMenu, view: View) {
(view as TextView).text = label
if (textColorResource != NO_ID) {
view.setTextColor(ContextCompat.getColor(view.context, textColorResource))
}
if (listener != null) {
view.setOnClickListener {
listener.invoke()
menu.dismiss()
}
} else {
// This will remove the ripple effect.
view.background = null
}
}
} |
@Amejia481 seems like a great solution. I'll make that change! |
components/browser/menu/src/main/res/layout/mozac_browser_menu_item_caption.xml
Outdated
Show resolved
Hide resolved
b5821e0
to
a1a1e35
Compare
beb0bfd
to
2726c54
Compare
Pull Request checklist