Ui

interface Ui(source)

Declarative plugin UI. Obtained from ui. Text is never rejected for length: the runtime truncates it. Exceeding a count limit throws IllegalStateException; a missing or invalid argument throws IllegalArgumentException.

A missing feature is not an error. When the unit lacks the feature (the SDK UI is off this boot, or the unit has no such slot) each method still returns a handle, but an inert one: update, open, set and cancel are accepted and show nothing. Count limits and argument checks apply as usual, so a plugin that works with the UI on works the same with it off. Use has to tell the two apart.

Properties

Link copied to clipboard
val MAX_CAR_ROWS: Int = 2
The most Car-menu rows one plugin may have live at once; one more carMenuRow throws IllegalStateException.
Link copied to clipboard
The longest confirm text; the runtime truncates longer text.
Link copied to clipboard
val MAX_PAGES: Int = 8
The most pages one plugin may have live at once; one more page throws IllegalStateException.
Link copied to clipboard
val MAX_SPELLER: Int = 32
The largest spellermaxLen.
Link copied to clipboard
The most status items one plugin may have live at once; one more statusItem throws IllegalStateException.
Link copied to clipboard
The largest textInputmaxLen.
Link copied to clipboard
val MAX_TOAST: Int = 20
The longest toast text; the runtime truncates longer text.
Link copied to clipboard
The largest Car-row icon, in pixels, either way.
Link copied to clipboard
val TOAST_MS: Int = 3000
How long a toast shows, in milliseconds.

Functions

Link copied to clipboard
abstract fun carMenuRow(label: String, opens: Page): Subscription
A row in the Car menu that opens opens, a live page from page.
abstract fun carMenuRow(label: String, opens: Page, icon: Icon): Subscription
carMenuRow with an icon; a null icon means none.
Link copied to clipboard
abstract fun confirm(title: String, text: String, yes: String, no: String, onAnswer: Listener<UiAction>): Subscription
Asks a yes/no question over this plugin's open page.
Link copied to clipboard
abstract fun icon(name: String): Icon
An icon this plugin declared by name in its manifest's "icons" (needs "api": 3); the package carries it as icons/<name>.png, and mibpkg installs it as icons/<id>/<sha16>.png (the first 16 hex digits of its SHA-256).
abstract fun icon(name: String, colour: Int): Icon
icon drawn either TINTED or in its OWN_COLOURS; any other colour throws IllegalArgumentException.
Link copied to clipboard
abstract fun page(spec: PageSpec, onAction: Listener<UiAction>): Page
Registers a page under this plugin's Plugins-menu entry; actions arrive on the plugin's executor.
Link copied to clipboard
abstract fun speller(title: String, initial: String, maxLen: Int, onDone: Listener<UiAction>): Subscription
EXPERIMENTAL.
Link copied to clipboard
abstract fun statusItem(text: String): StatusItem
One short status-line item; set(null|"") hides it.
abstract fun statusItem(text: String, icon: Icon): StatusItem
statusItem with an icon; a null icon means none.
Link copied to clipboard
abstract fun stockIcon(name: String): Icon
One of the SDK's built-in icons, named by a StockIcons constant; any other name throws IllegalArgumentException.
Link copied to clipboard
abstract fun textInput(title: String, initial: String, maxLen: Int, secret: Boolean, onDone: Listener<UiAction>): Subscription
As speller, with an optional secret field.
Link copied to clipboard
abstract fun toast(text: String, icon: Icon)
Shows text (at most MAX_TOAST characters) with an optional icon for TOAST_MS in a short popup at the top of the screen.