Loading components/browser/menu/src/main/java/mozilla/components/browser/menu/ext/BrowserMenuItem.kt +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package mozilla.components.browser.menu.ext import android.content.Context import mozilla.components.browser.menu.BrowserMenuHighlight import mozilla.components.browser.menu.BrowserMenuItem import mozilla.components.browser.menu.HighlightableMenuItem Loading @@ -26,3 +27,9 @@ fun List<BrowserMenuItem>.getHighlight() = asSequence() is BrowserMenuHighlight.ClassicHighlight -> 0 } } /** * Converts the menu items into a menu candidate list. */ fun List<BrowserMenuItem>.asCandidateList(context: Context) = mapNotNull { it.asCandidate(context) } components/browser/menu/src/main/java/mozilla/components/browser/menu/item/BackPressMenuItem.kt +15 −0 Original line number Diff line number Diff line Loading @@ -4,10 +4,13 @@ package mozilla.components.browser.menu.item import android.content.Context import android.view.View import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import mozilla.components.browser.menu.BrowserMenu import mozilla.components.concept.menu.candidate.NestedMenuCandidate import mozilla.components.concept.menu.candidate.TextMenuCandidate /** * A back press menu item for a nested sub menu entry. Loading Loading @@ -42,4 +45,16 @@ class BackPressMenuItem( fun setListener(onClickListener: () -> Unit) { backPressListener = onClickListener } override fun asCandidate(context: Context): NestedMenuCandidate { val parentCandidate = super.asCandidate(context) as TextMenuCandidate return NestedMenuCandidate( id = hashCode(), text = parentCandidate.text, start = parentCandidate.start, subMenuItems = null, textStyle = parentCandidate.textStyle, containerStyle = parentCandidate.containerStyle ) } } components/browser/menu/src/main/java/mozilla/components/browser/menu/item/BrowserMenuHighlightableItem.kt +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ class BrowserMenuHighlightableItem( } override fun asCandidate(context: Context): TextMenuCandidate { val base = super.asCandidate(context) val base = super.asCandidate(context) as TextMenuCandidate if (!isHighlighted()) return base @Suppress("Deprecation") Loading components/browser/menu/src/main/java/mozilla/components/browser/menu/item/BrowserMenuImageText.kt +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import mozilla.components.browser.menu.BrowserMenuItem import mozilla.components.browser.menu.R import mozilla.components.concept.menu.candidate.ContainerStyle import mozilla.components.concept.menu.candidate.DrawableMenuIcon import mozilla.components.concept.menu.candidate.MenuCandidate import mozilla.components.concept.menu.candidate.TextMenuCandidate import mozilla.components.concept.menu.candidate.TextStyle Loading Loading @@ -84,7 +85,7 @@ open class BrowserMenuImageText( } } override fun asCandidate(context: Context) = TextMenuCandidate( override fun asCandidate(context: Context): MenuCandidate = TextMenuCandidate( label, start = DrawableMenuIcon( context, Loading components/browser/menu/src/main/java/mozilla/components/browser/menu/item/ParentBrowserMenuItem.kt +6 −3 Original line number Diff line number Diff line Loading @@ -13,9 +13,10 @@ import androidx.appcompat.widget.AppCompatImageView import androidx.core.content.ContextCompat import mozilla.components.browser.menu.BrowserMenu import mozilla.components.browser.menu.R import mozilla.components.browser.menu.ext.asCandidateList import mozilla.components.concept.menu.candidate.ContainerStyle import mozilla.components.concept.menu.candidate.DrawableMenuIcon import mozilla.components.concept.menu.candidate.TextMenuCandidate import mozilla.components.concept.menu.candidate.NestedMenuCandidate import mozilla.components.concept.menu.candidate.TextStyle /** Loading Loading @@ -81,13 +82,15 @@ class ParentBrowserMenuItem( } } override fun asCandidate(context: Context) = TextMenuCandidate( label, override fun asCandidate(context: Context) = NestedMenuCandidate( id = hashCode(), text = label, start = DrawableMenuIcon( context, resource = imageResource, tint = if (iconTintColorResource == NO_ID) null else ContextCompat.getColor(context, iconTintColorResource) ), subMenuItems = subMenu.adapter.visibleItems.asCandidateList(context), textStyle = TextStyle( color = if (textColorResource == NO_ID) null else ContextCompat.getColor(context, textColorResource) ), Loading Loading
components/browser/menu/src/main/java/mozilla/components/browser/menu/ext/BrowserMenuItem.kt +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package mozilla.components.browser.menu.ext import android.content.Context import mozilla.components.browser.menu.BrowserMenuHighlight import mozilla.components.browser.menu.BrowserMenuItem import mozilla.components.browser.menu.HighlightableMenuItem Loading @@ -26,3 +27,9 @@ fun List<BrowserMenuItem>.getHighlight() = asSequence() is BrowserMenuHighlight.ClassicHighlight -> 0 } } /** * Converts the menu items into a menu candidate list. */ fun List<BrowserMenuItem>.asCandidateList(context: Context) = mapNotNull { it.asCandidate(context) }
components/browser/menu/src/main/java/mozilla/components/browser/menu/item/BackPressMenuItem.kt +15 −0 Original line number Diff line number Diff line Loading @@ -4,10 +4,13 @@ package mozilla.components.browser.menu.item import android.content.Context import android.view.View import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import mozilla.components.browser.menu.BrowserMenu import mozilla.components.concept.menu.candidate.NestedMenuCandidate import mozilla.components.concept.menu.candidate.TextMenuCandidate /** * A back press menu item for a nested sub menu entry. Loading Loading @@ -42,4 +45,16 @@ class BackPressMenuItem( fun setListener(onClickListener: () -> Unit) { backPressListener = onClickListener } override fun asCandidate(context: Context): NestedMenuCandidate { val parentCandidate = super.asCandidate(context) as TextMenuCandidate return NestedMenuCandidate( id = hashCode(), text = parentCandidate.text, start = parentCandidate.start, subMenuItems = null, textStyle = parentCandidate.textStyle, containerStyle = parentCandidate.containerStyle ) } }
components/browser/menu/src/main/java/mozilla/components/browser/menu/item/BrowserMenuHighlightableItem.kt +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ class BrowserMenuHighlightableItem( } override fun asCandidate(context: Context): TextMenuCandidate { val base = super.asCandidate(context) val base = super.asCandidate(context) as TextMenuCandidate if (!isHighlighted()) return base @Suppress("Deprecation") Loading
components/browser/menu/src/main/java/mozilla/components/browser/menu/item/BrowserMenuImageText.kt +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import mozilla.components.browser.menu.BrowserMenuItem import mozilla.components.browser.menu.R import mozilla.components.concept.menu.candidate.ContainerStyle import mozilla.components.concept.menu.candidate.DrawableMenuIcon import mozilla.components.concept.menu.candidate.MenuCandidate import mozilla.components.concept.menu.candidate.TextMenuCandidate import mozilla.components.concept.menu.candidate.TextStyle Loading Loading @@ -84,7 +85,7 @@ open class BrowserMenuImageText( } } override fun asCandidate(context: Context) = TextMenuCandidate( override fun asCandidate(context: Context): MenuCandidate = TextMenuCandidate( label, start = DrawableMenuIcon( context, Loading
components/browser/menu/src/main/java/mozilla/components/browser/menu/item/ParentBrowserMenuItem.kt +6 −3 Original line number Diff line number Diff line Loading @@ -13,9 +13,10 @@ import androidx.appcompat.widget.AppCompatImageView import androidx.core.content.ContextCompat import mozilla.components.browser.menu.BrowserMenu import mozilla.components.browser.menu.R import mozilla.components.browser.menu.ext.asCandidateList import mozilla.components.concept.menu.candidate.ContainerStyle import mozilla.components.concept.menu.candidate.DrawableMenuIcon import mozilla.components.concept.menu.candidate.TextMenuCandidate import mozilla.components.concept.menu.candidate.NestedMenuCandidate import mozilla.components.concept.menu.candidate.TextStyle /** Loading Loading @@ -81,13 +82,15 @@ class ParentBrowserMenuItem( } } override fun asCandidate(context: Context) = TextMenuCandidate( label, override fun asCandidate(context: Context) = NestedMenuCandidate( id = hashCode(), text = label, start = DrawableMenuIcon( context, resource = imageResource, tint = if (iconTintColorResource == NO_ID) null else ContextCompat.getColor(context, iconTintColorResource) ), subMenuItems = subMenu.adapter.visibleItems.asCandidateList(context), textStyle = TextStyle( color = if (textColorResource == NO_ID) null else ContextCompat.getColor(context, textColorResource) ), Loading