android-components / mozilla.components.feature.prompts / PromptFeature

PromptFeature

class PromptFeature : LifecycleAwareFeature, PermissionsFeature (source)

Feature for displaying native dialogs for html elements like: input type date, file, time, color, option, menu, authentication, confirmation and alerts.

There are some requests that are handled with intents instead of dialogs, like file choosers and others. For this reason, you have to keep the feature aware of the flow of requesting data from other apps, overriding onActivityResult in your Activity or Fragment and forward its calls to onActivityResult.

This feature will subscribe to the currently selected Session and display a suitable native dialog based on Session.Observer.onPromptRequested events. Once the dialog is closed or the user selects an item from the dialog the related PromptRequest will be consumed.

Constructors

Name Summary
<init> PromptFeature(activity: <ERROR CLASS>, store: BrowserStore, sessionId: String? = null, fragmentManager: FragmentManager, onNeedToRequestPermissions: OnNeedToRequestPermissions)
PromptFeature(fragment: Fragment, store: BrowserStore, sessionId: String? = null, fragmentManager: FragmentManager, onNeedToRequestPermissions: OnNeedToRequestPermissions)PromptFeature(activity: <ERROR CLASS>? = null, fragment: Fragment? = null, store: BrowserStore, customTabId: String? = null, fragmentManager: FragmentManager, onNeedToRequestPermissions: OnNeedToRequestPermissions)
Feature for displaying native dialogs for html elements like: input type date, file, time, color, option, menu, authentication, confirmation and alerts.

Properties

Name Summary
onNeedToRequestPermissions val onNeedToRequestPermissions: <ERROR CLASS>
a callback invoked when permissions need to be requested before a prompt (e.g. a file picker) can be displayed. Once the request is completed, onPermissionsResult needs to be invoked.

Functions

Name Summary
onActivityResult fun onActivityResult(requestCode: Int, resultCode: Int, intent: <ERROR CLASS>?): Unit
Notifies the feature of intent results for prompt requests handled by other apps like file chooser requests.
onPermissionsResult fun onPermissionsResult(permissions: Array<String>, grantResults: IntArray): Unit
Notifies the feature that the permissions request was completed. It will then either process or dismiss the prompt request.
start fun start(): Unit
Starts observing the selected session to listen for prompt requests and displays a dialog when needed.
stop fun stop(): Unit
Stops observing the selected session for incoming prompt requests.

Companion Object Properties

Name Summary
FILE_PICKER_ACTIVITY_REQUEST_CODE const val FILE_PICKER_ACTIVITY_REQUEST_CODE: Int