android-components / mozilla.components.browser.toolbar / BrowserToolbar


class BrowserToolbar : Toolbar (source)

A customizable toolbar for browsers.

The toolbar can switch between two modes: display and edit. The display mode displays the current URL and controls for navigation. In edit mode the current URL can be edited. Those two modes are implemented by the DisplayToolbar and EditToolbar classes.

             | BrowserToolbar |
              |               |
    +---------v------+ +-------v--------+
    | DisplayToolbar | |   EditToolbar  |
    +----------------+ +----------------+


Name Summary
Button class Button : ActionButton
An action button to be added to the toolbar.
ToggleButton class ToggleButton : ActionToggleButton
An action button with two states, selected and unselected. When the button is pressed, the state changes automatically.
TwoStateButton class TwoStateButton : Button
An action that either shows an active button or an inactive button based on the provided isEnabled lambda.


Name Summary
<init> BrowserToolbar(context: <ERROR CLASS>, attrs: <ERROR CLASS>? = null, defStyleAttr: Int = 0)
A customizable toolbar for browsers.


Name Summary
display var display: DisplayToolbar
Toolbar in “display mode”.
edit var edit: EditToolbar
Toolbar in “edit mode”.
private var private: Boolean
Sets/gets private mode.
siteSecure var siteSecure: SiteSecurity
Sets/Gets the site security to be displayed on the toolbar.
siteTrackingProtection var siteTrackingProtection: SiteTrackingProtection
Sets/Gets the site tracking protection state to be displayed on the toolbar.
title var title: String
Sets/Gets the title to be displayed on the toolbar.
url var url: CharSequence
Sets/Gets the URL to be displayed on the toolbar.


Name Summary
addBrowserAction fun addBrowserAction(action: Action): Unit
Adds an action to be displayed on the right side of the toolbar (outside of the URL bounding box) in display mode.
addEditAction fun addEditAction(action: Action): Unit
Adds an action to be displayed on the right of the URL in edit mode.
addNavigationAction fun addNavigationAction(action: Action): Unit
Adds an action to be display on the far left side of the toolbar. This area is usually used on larger devices for navigation actions like “back” and “forward”.
addPageAction fun addPageAction(action: Action): Unit
Adds an action to be displayed on the right side of the URL in display mode.
displayMode fun displayMode(): Unit
Switches to URL displaying mode.
displayProgress fun displayProgress(progress: Int): Unit
Displays the given loading progress. Expects values in the range 0,100.
editMode fun editMode(): Unit
Switches to URL editing mode.
invalidateActions fun invalidateActions(): Unit
Declare that the actions (navigation actions, browser actions, page actions) have changed and should be updated if needed.
onBackPressed fun onBackPressed(): Boolean
Should be called by an activity when the user pressed the back key of the device.
onLayout fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit
onMeasure fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit
onStop fun onStop(): Unit
Should be called by the host activity when it enters the stop state.
setAutocompleteListener fun setAutocompleteListener(filter: suspend (String, AutocompleteDelegate) -> Unit): Unit
Registers the given function to be invoked when users changes text in the toolbar.
setOnEditListener fun setOnEditListener(listener: OnEditListener): Unit
Registers the given listener to be invoked when the user edits the URL.
setOnUrlCommitListener fun setOnUrlCommitListener(listener: (String) -> Boolean): Unit
Registers the given function to be invoked when the user selected a new URL i.e. is done editing.
setSearchTerms fun setSearchTerms(searchTerms: String): Unit
Displays the currently used search terms as part of this Toolbar.

Inherited Functions

Name Summary
asView open fun asView(): <ERROR CLASS>
Casts this toolbar to an Android View object.

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.