android-components / mozilla.components.concept.engine.manifest / WebAppManifest

WebAppManifest

data class WebAppManifest (source)

The web app manifest provides information about an application (such as its name, author, icon, and description).

Web app manifests are part of a collection of web technologies called progressive web apps, which are websites that can be installed to a device’s homescreen without an app store, along with other capabilities like working offline and receiving push notifications.

https://developer.mozilla.org/en-US/docs/Web/Manifest https://www.w3.org/TR/appmanifest/ https://developers.google.com/web/fundamentals/web-app-manifest/

Types

Name Summary
DisplayMode enum class DisplayMode
Defines the developers’ preferred display mode for the website.
ExternalApplicationResource data class ExternalApplicationResource
An external native application that is related to the web app.
Icon data class Icon
An image file that can serve as application icon.
Orientation enum class Orientation
Defines the default orientation for all the website’s top level browsing contexts.
ShareTarget data class ShareTarget
Used to define how the web app receives share data. If present, a share target should be created so that other Android apps can share to this web app.
TextDirection enum class TextDirection
Specifies the primary text direction for the name, short_name, and description members. Together with the lang member, it helps the correct display of right-to-left languages.

Constructors

Name Summary
<init> WebAppManifest(name: String, startUrl: String, shortName: String? = null, display: DisplayMode = DisplayMode.BROWSER, backgroundColor: Int? = null, description: String? = null, icons: List<Icon> = emptyList(), dir: TextDirection = TextDirection.AUTO, lang: String? = null, orientation: Orientation = Orientation.ANY, scope: String? = null, themeColor: Int? = null, relatedApplications: List<ExternalApplicationResource> = emptyList(), preferRelatedApplications: Boolean = false, shareTarget: ShareTarget? = null)
The web app manifest provides information about an application (such as its name, author, icon, and description).

Properties

Name Summary
backgroundColor val backgroundColor: Int?
Defines the expected “background color” for the website. This value repeats what is already available in the site’s CSS, but can be used by browsers to draw the background color of a shortcut when the manifest is available before the stylesheet has loaded. This creates a smooth transition between launching the web application and loading the site’s content.
description val description: String?
Provides a general description of what the pinned website does.
dir val dir: TextDirection
Specifies the primary text direction for the name, short_name, and description members. Together with the lang member, it helps the correct display of right-to-left languages.
display val display: DisplayMode
Defines the developers’ preferred display mode for the website.
icons val icons: List<Icon>
Specifies a list of image files that can serve as application icons, depending on context. For example, they can be used to represent the web application amongst a list of other applications, or to integrate the web application with an OS’s task switcher and/or system preferences.
lang val lang: String?
Specifies the primary language for the values in the name and short_name members. This value is a string containing a single language tag (e.g. en-US).
name val name: String
Provides a human-readable name for the site when displayed to the user. For example, among a list of other applications or as a label for an icon.
orientation val orientation: Orientation
Defines the default orientation for all the website’s top level browsing contexts.
preferRelatedApplications val preferRelatedApplications: Boolean
If true, related applications should be preferred over the web app.
relatedApplications val relatedApplications: List<ExternalApplicationResource>
List of native applications related to the web app.
scope val scope: String?
Defines the navigation scope of this website’s context. This restricts what web pages can be viewed while the manifest is applied. If the user navigates outside the scope, it returns to a normal web page inside a browser tab/window.
shareTarget val shareTarget: ShareTarget?
shortName val shortName: String?
Provides a short human-readable name for the application. This is intended for when there is insufficient space to display the full name of the web application, like device homescreens.
startUrl val startUrl: String
The URL that loads when a user launches the application (e.g. when added to home screen), typically the index. Note that this has to be a relative URL, relative to the manifest url.
themeColor val themeColor: Int?
Defines the default theme color for an application. This sometimes affects how the OS displays the site (e.g., on Android’s task switcher, the theme color surrounds the site).

Extension Functions

Name Summary
getTrustedScope fun WebAppManifest.getTrustedScope(): <ERROR CLASS>?
Returns the scope of the manifest as a Uri for use with mozilla.components.feature.pwa.feature.WebAppHideToolbarFeature.
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.
toCustomTabConfig fun WebAppManifest.toCustomTabConfig(): CustomTabConfig
Creates a CustomTabConfig that styles a custom tab toolbar to match the manifest theme.
toIconRequest fun WebAppManifest.toIconRequest(): IconRequest
Creates an IconRequest for retrieving the icon specified in the manifest.
toTaskDescription fun WebAppManifest.toTaskDescription(icon: <ERROR CLASS>?): <ERROR CLASS>
Creates a TaskDescription for the activity manager based on the manifest.