android-components / mozilla.components.feature.downloads / DownloadsFeature

DownloadsFeature

class DownloadsFeature : LifecycleAwareFeature, PermissionsFeature (source)

Feature implementation to provide download functionality for the selected session. The feature will subscribe to the selected session and listen for downloads.

Types

Name Summary
PromptsStyling data class PromptsStyling
Styling for the download dialog prompt

Constructors

| Name | Summary | |—|—| | <init> | DownloadsFeature(applicationContext: <ERROR CLASS>, store: BrowserStore, useCases: DownloadsUseCases, onNeedToRequestPermissions: OnNeedToRequestPermissions = { }, onDownloadStopped: onDownloadStopped = noop, downloadManager: DownloadManager = AndroidDownloadManager(applicationContext), customTabId: String? = null, fragmentManager: FragmentManager? = null, promptsStyling: PromptsStyling? = null, dialog: DownloadDialogFragment = SimpleDownloadDialogFragment.newInstance( promptsStyling = promptsStyling ))
Feature implementation to provide download functionality for the selected session. The feature will subscribe to the selected session and listen for downloads. |

Properties

Name Summary
onDownloadStopped var onDownloadStopped: onDownloadStopped
a callback invoked when a download is paused or completed.
onNeedToRequestPermissions var onNeedToRequestPermissions: OnNeedToRequestPermissions
a callback invoked when permissions need to be requested before a download can be performed. Once the request is completed, onPermissionsResult needs to be invoked.

Functions

Name Summary
onPermissionsResult fun onPermissionsResult(permissions: Array<String>, grantResults: IntArray): Unit
Notifies the feature that the permissions request was completed. It will then either trigger or clear the pending download.
start fun start(): Unit
Starts observing downloads on the selected session and sends them to the DownloadManager to be processed.
stop fun stop(): Unit
Stops observing downloads on the selected session.
tryAgain fun tryAgain(id: Long): Unit
Calls the tryAgain function of the corresponding DownloadManager

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.