android-components / mozilla.components.feature.customtabs / CustomTabsToolbarFeature

CustomTabsToolbarFeature

class CustomTabsToolbarFeature : LifecycleAwareFeature, UserInteractionHandler (source)

Initializes and resets the Toolbar for a Custom Tab based on the CustomTabConfig.

Parameters

toolbar - Reference to the browser toolbar, so that the color and menu items can be set.

sessionId - ID of the custom tab session. No-op if null or invalid.

menuBuilder - Menu builder reference to pull menu options from.

menuItemIndex - Location to insert any custom menu options into the predefined menu list.

window - Reference to the window so the navigation bar color can be set.

shareListener - Invoked when the share button is pressed.

closeListener - Invoked when the close button is pressed.

Constructors

Name Summary
<init> CustomTabsToolbarFeature(sessionManager: SessionManager, toolbar: BrowserToolbar, sessionId: String? = null, menuBuilder: BrowserMenuBuilder? = null, menuItemIndex: Int = menuBuilder?.items?.size ?: 0, window: <ERROR CLASS>? = null, shareListener: () -> Unit = null, closeListener: () -> Unit)
Initializes and resets the Toolbar for a Custom Tab based on the CustomTabConfig.

Functions

Name Summary
onBackPressed fun onBackPressed(): Boolean
When the back button is pressed if not initialized returns false, when initialized removes the current Custom Tabs session and returns true. Should be called when the back button is pressed.
start fun start(): Unit
Initializes the feature and registers the CustomTabSessionTitleObserver.
stop fun stop(): Unit
Unregisters the CustomTabSessionTitleObserver.

Inherited Functions

Name Summary
onHomePressed open fun onHomePressed(): Boolean
In most cases, when the home button is pressed, we invoke this callback to inform the app that the user is going to leave the app.

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.