android-components / mozilla.components.browser.toolbar.display / DisplayToolbar

DisplayToolbar

class DisplayToolbar (source)

Sub-component of the browser toolbar responsible for displaying the URL and related controls (“display mode”).

Structure:

+-------------+------------+-----------------------+----------+------+
| navigation  | indicators | url       [ page    ] | browser  | menu |
|   actions   |            |           [ actions ] | actions  |      |
+-------------+------------+-----------------------+----------+------+
+------------------------progress------------------------------------+

Navigation actions (optional): A dynamic list of clickable icons usually used for navigation on larger devices (e.g. “back”/”forward” buttons.)

Indicators (optional): Tracking protection indicator icon (e.g. “shield” icon) that may show a doorhanger when clicked. Separator icon: a vertical line that separate the above and below icons. Site security indicator icon (e.g. “Lock” icon) that may show a doorhanger when clicked. Empty indicator: Icon that will be displayed if the URL is empty.

URL: Section that displays the current URL (read-only)

Page actions (optional): A dynamic list of clickable icons inside the URL section (e.g. “reader mode” icon)

Browser actions (optional): A list of dynamic clickable icons on the toolbar (e.g. tabs tray button)

Menu (optional): A button that shows an overflow menu when clicked (constructed using the browser-menu component)

Progress (optional): A horizontal progress bar showing the loading progress (at the top or bottom of the toolbar).

Types

Name Summary
Colors data class Colors
Data class holding the customizable colors in “display mode”.
Gravity enum class Gravity
Gravity enum for positioning the progress bar.
Icons data class Icons
Data class holding the customizable icons in “display mode”.
Indicators enum class Indicators
Enum of indicators that can be displayed in the toolbar.

Properties

Name Summary
colors var colors: Colors
Customizable colors in “display mode”.
displayIndicatorSeparator var displayIndicatorSeparator: Boolean
hint var hint: String
Sets the text to be displayed when the URL of the toolbar is empty.
icons var icons: Icons
Customizable icons in “edit mode”.
indicators var indicators: List<Indicators>
List of indicators that should be displayed next to the URL.
menuBuilder var menuBuilder: BrowserMenuBuilder?
Sets a BrowserMenuBuilder that will be used to create a menu when the menu button is clicked. The menu button will only be visible if a builder or controller has been set.
menuController var menuController: MenuController?
Sets a MenuController that will be used to create a menu when the menu button is clicked. The menu button will only be visible if a builder or controller has been set. If both a menuBuilder and controller are present, only the controller will be used.
onUrlClicked var onUrlClicked: () -> Boolean
Sets a lambda that will be invoked whenever the URL in display mode was clicked. Only if this lambda returns true the toolbar will switch to editing mode. Return false to not switch to editing mode and handle the click manually.
progressGravity var progressGravity: Gravity
Whether the progress bar should be drawn at the top or bottom of the toolbar.
textSize var textSize: Float
Sets the size of the text for the URL/search term displayed in the toolbar.
titleTextSize var titleTextSize: Float
Sets the size of the text for the title displayed in the toolbar.
typeface var typeface: <ERROR CLASS>
Sets the typeface of the text for the URL/search term displayed in the toolbar.
urlFormatter var urlFormatter: (CharSequence) -> CharSequence
Allows customization of URL for display purposes.

Functions

Name Summary
setMenuDismissAction fun setMenuDismissAction(onDismiss: () -> Unit): Unit
Sets a lambda to be invoked when the menu is dismissed
setOnSiteSecurityClickedListener fun setOnSiteSecurityClickedListener(listener: () -> Unit): Unit
Sets a listener to be invoked when the site security indicator icon is clicked.
setOnTrackingProtectionClickedListener fun setOnTrackingProtectionClickedListener(listener: () -> Unit): Unit
Sets a listener to be invoked when the site tracking protection indicator icon is clicked.
setOnUrlLongClickListener fun setOnUrlLongClickListener(handler: (<ERROR CLASS>) -> Boolean): Unit
Set a LongClickListener to the urlView of the toolbar.
setUrlBackground fun setUrlBackground(background: <ERROR CLASS>?): Unit
Sets the background that should be drawn behind the URL, page actions an indicators.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.