public class WidgetKind

  1. Object
  2. WidgetKind

Declares one kind of home-screen widget the app offers (an app may offer several). The kind id must match an entry in the surfaces.json file kept in the project’s resources: widget kinds are compiled into the native app (the widget gallery entries, the iOS widget bundle and the Android receivers are all static), so the build needs them at build time while this runtime declaration drives publishing and validation. A mismatch logs a prominent warning.

Ids are restricted to [a-z][a-z0-9_]* because they are used to derive native type and resource names.

Constructors

public WidgetKind(String id)Creates a widget kind declaration.

Methods

public WidgetKind setDisplayName(String displayName)Sets the title shown in the platform widget gallery.
public WidgetKind setDescription(String description)Sets the description shown in the platform widget gallery.
public WidgetKind addSupportedSize(WidgetSize size)Adds a supported size family.
public String getId()Returns the stable kind identifier.
public String getDisplayName()Returns the gallery title, or null.
public String getDescription()Returns the gallery description, or null.
public List<WidgetSize> getSupportedSizes()Returns the supported size families; SMALL and MEDIUM when none were added explicitly.

Inherited methods

Constructor details

WidgetKind

public WidgetKind(String id)
Creates a widget kind declaration.

Parameters

id String
the stable kind identifier, [a-z][a-z0-9_]*

Method details

setDisplayName

public WidgetKind setDisplayName(String displayName)
Sets the title shown in the platform widget gallery.

Parameters

displayName String
the gallery title

Returns

this kind, for chaining

setDescription

public WidgetKind setDescription(String description)
Sets the description shown in the platform widget gallery.

Parameters

description String
the gallery description

Returns

this kind, for chaining

addSupportedSize

public WidgetKind addSupportedSize(WidgetSize size)
Adds a supported size family. When no size is added the kind defaults to SMALL and MEDIUM.

Parameters

size WidgetSize
the size family to support

Returns

this kind, for chaining

getId

public String getId()
Returns the stable kind identifier.

getDisplayName

public String getDisplayName()
Returns the gallery title, or null.

getDescription

public String getDescription()
Returns the gallery description, or null.

getSupportedSizes

public List<WidgetSize> getSupportedSizes()
Returns the supported size families; SMALL and MEDIUM when none were added explicitly.